lil upd
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
|
||||
|
||||
@@ -53,7 +54,32 @@ public partial class Actor : Sprite2D
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ShiftCells(int SHIFT_SPOTS = 1)
|
||||
public bool ShiftMarks(int COLUMNS = 0, int ROWS = 0)
|
||||
{
|
||||
List<Actor> markers = new(_board._cells.Select(c=>c._marker).ToList());
|
||||
for (int i = 0; i < _board._cells.Count; i++)
|
||||
{
|
||||
int cellCol = i % 3;
|
||||
int cellRow = (int)Math.Floor(i / 3f);
|
||||
int newCol = cellCol + COLUMNS;
|
||||
int newRow = cellRow + ROWS;
|
||||
if (newCol >= 0 && newRow >= 0 && newCol <= 2 && newRow <= 2)
|
||||
{
|
||||
int newAddress = newRow*3 + newCol;
|
||||
GD.Print(i, cellCol, cellRow, newCol, newRow, newAddress);
|
||||
if (_board._cells[i]._marker != null)
|
||||
{
|
||||
_board._cells[newAddress].Mark(_board._cells[i]._marker);
|
||||
}
|
||||
// _board._cells[i].Clear();
|
||||
}
|
||||
}
|
||||
_board.RenumberCells();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool SlideCells(int SHIFT_SPOTS = 1)
|
||||
{
|
||||
List<Vector2> positions = new(_board._cells.Select(c=>c.Position).ToList());
|
||||
int start = SHIFT_SPOTS > 0 ? 0 : 9;
|
||||
@@ -68,22 +94,25 @@ public partial class Actor : Sprite2D
|
||||
|
||||
public bool SwapCells(int CELL_A_ADDRESS = -1, int CELL_B_ADDRESS = -1)
|
||||
{
|
||||
if (CELL_A_ADDRESS < -1 || CELL_A_ADDRESS > 8 || CELL_B_ADDRESS < -1 || CELL_B_ADDRESS > 8)
|
||||
if (CELL_A_ADDRESS < -1 || CELL_A_ADDRESS > 8 || CELL_B_ADDRESS < -1 || CELL_B_ADDRESS > 8 || CELL_A_ADDRESS == CELL_B_ADDRESS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
List<Vector2> positions = new(_board._cells.Select(c=>c.Position).ToList());
|
||||
Random random = new ();
|
||||
if (CELL_A_ADDRESS == -1)
|
||||
{
|
||||
CELL_A_ADDRESS = random.Next(8);
|
||||
CELL_A_ADDRESS = Globals._rng.Next(0,8);
|
||||
while (CELL_A_ADDRESS == CELL_B_ADDRESS)
|
||||
{
|
||||
CELL_A_ADDRESS = Globals._rng.Next(0,8);
|
||||
}
|
||||
}
|
||||
if (CELL_B_ADDRESS == -1)
|
||||
{
|
||||
CELL_B_ADDRESS = random.Next(8);
|
||||
CELL_B_ADDRESS = Globals._rng.Next(0,8);
|
||||
while (CELL_B_ADDRESS == CELL_A_ADDRESS)
|
||||
{
|
||||
CELL_B_ADDRESS = random.Next(8);
|
||||
CELL_B_ADDRESS = Globals._rng.Next(0,8);
|
||||
}
|
||||
}
|
||||
_board._cells[CELL_A_ADDRESS].Position = positions[CELL_B_ADDRESS];
|
||||
@@ -92,5 +121,14 @@ public partial class Actor : Sprite2D
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//MoveMark
|
||||
|
||||
//ShiftColumns
|
||||
|
||||
//ShiftRows
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public partial class Cell : TextureButton
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_marker = null;
|
||||
// _marker = null;
|
||||
TextureNormal = TexturePressed = TextureHover = TextureDisabled = TextureFocused = _defaultMark.Texture;
|
||||
}
|
||||
}
|
||||
|
||||
7
Gameplay/Contacts/Shift1ColumnRight.cs
Normal file
7
Gameplay/Contacts/Shift1ColumnRight.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
public partial class Shift1ColumnRight : Contact
|
||||
{
|
||||
public override void CallAction()
|
||||
{
|
||||
_player.ShiftMarks(1,0);
|
||||
}
|
||||
}
|
||||
1
Gameplay/Contacts/Shift1ColumnRight.cs.uid
Normal file
1
Gameplay/Contacts/Shift1ColumnRight.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ciphg323a14cs
|
||||
@@ -1,7 +0,0 @@
|
||||
public partial class ShiftBack2 : Contact
|
||||
{
|
||||
public override void CallAction()
|
||||
{
|
||||
_player.ShiftCells(-2);
|
||||
}
|
||||
}
|
||||
7
Gameplay/Contacts/SlideBack2.cs
Normal file
7
Gameplay/Contacts/SlideBack2.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
public partial class SlideBack2 : Contact
|
||||
{
|
||||
public override void CallAction()
|
||||
{
|
||||
_player.SlideCells(-2);
|
||||
}
|
||||
}
|
||||
26
Gameplay/Globals.cs
Normal file
26
Gameplay/Globals.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public static partial class Globals
|
||||
{
|
||||
public static bool _animationRunning;
|
||||
public static Random _rng = new();
|
||||
public static List<string> _addressTranslation = new(){"NW","N","NE","W","C","E","SW","S","SE"};
|
||||
|
||||
public static void Shuffle<T>(this IList<T> list)
|
||||
{
|
||||
int n = list.Count;
|
||||
while (n > 1) {
|
||||
n--;
|
||||
int k = _rng.Next(n + 1);
|
||||
T value = list[k];
|
||||
list[k] = list[n];
|
||||
list[n] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadSeed(int SEED)
|
||||
{
|
||||
_rng = new(SEED);
|
||||
}
|
||||
}
|
||||
1
Gameplay/Globals.cs.uid
Normal file
1
Gameplay/Globals.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ljqms5o2g2rb
|
||||
@@ -1,13 +0,0 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public partial class Opponent : Player
|
||||
{
|
||||
|
||||
public void MakeMove()
|
||||
{
|
||||
// CREATE CODE TO MAKE ENEMY MOVES
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://631085nn2jpc
|
||||
@@ -21,9 +21,10 @@ public partial class Phone : Sprite2D
|
||||
{
|
||||
_phoneButtons[i]._phone = this;
|
||||
}
|
||||
_phoneButtons[0]._contact = new ShiftBack2();
|
||||
_phoneButtons[0]._contact = new SlideBack2();
|
||||
_phoneButtons[1]._contact = new Rotate90();
|
||||
_phoneButtons[2]._contact = new Swap1And6();
|
||||
_phoneButtons[3]._contact = new Shift1ColumnRight();
|
||||
}
|
||||
|
||||
public override void _Process(double DELTA_)
|
||||
|
||||
116
Gameplay/Player.cs
Normal file
116
Gameplay/Player.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
public partial class Player : Actor
|
||||
{
|
||||
public bool _isTurn = false;
|
||||
public string _name;
|
||||
public Phone _phone;
|
||||
public Boss _boss;
|
||||
public Enemy _activeEnemy;
|
||||
public RichTextLabel _debug, _busDebug;
|
||||
public List<BusinessCard> _businessCards;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
|
||||
_debug = GetNode<RichTextLabel>("Debug");
|
||||
_busDebug = GetNode<RichTextLabel>("BusDebug");
|
||||
|
||||
_phone = GetNode<Phone>("Phone");
|
||||
_phone.PassPlayer(this);
|
||||
|
||||
_boss = GetNode<Boss>("Boss");
|
||||
_boss.PassPlayer(this);
|
||||
|
||||
_businessCards = GetChildren().Where(c=>c is BusinessCard).Cast<BusinessCard>().ToList();
|
||||
for (int i = 0; i < _businessCards.Count; i++)
|
||||
{
|
||||
_businessCards[i].PassPlayer(this);
|
||||
if (_businessCards[i].Name.ToString().IndexOf("Default") > -1)
|
||||
{
|
||||
string goalNameString = _businessCards[i].Name.ToString().Replace("Default","").Replace("Alt","");
|
||||
GoalName goalName;
|
||||
Enum.TryParse(goalNameString, out goalName);
|
||||
_businessCards[i].AssignGoal(goalName);
|
||||
}
|
||||
else
|
||||
{
|
||||
_businessCards[i].AssignRandomGoal();
|
||||
}
|
||||
}
|
||||
|
||||
Challenge(_boss);
|
||||
}
|
||||
|
||||
public void Challenge(Enemy ENEMY)
|
||||
{
|
||||
_board?.Deactivate();
|
||||
ENEMY._board.Activate();
|
||||
_board = ENEMY._board;
|
||||
_activeEnemy = ENEMY;
|
||||
CheckGoals();
|
||||
|
||||
string text = "";
|
||||
if (_activeEnemy is Mook)
|
||||
{
|
||||
text = "dragon " + _activeEnemy._owner._number + "\nmook " + _activeEnemy._number;
|
||||
}
|
||||
else if (_activeEnemy is Dragon)
|
||||
{
|
||||
text = "dragon " + _activeEnemy._number;
|
||||
}
|
||||
_debug.Text = text;
|
||||
}
|
||||
|
||||
public void CheckGoals()
|
||||
{
|
||||
_businessCards.ForEach(b=>b.CheckGoal());
|
||||
}
|
||||
|
||||
public void RunLost()
|
||||
{
|
||||
_debug.Text = "YOU LOSE!!";
|
||||
}
|
||||
|
||||
public void RunWon()
|
||||
{
|
||||
_debug.Text = "YOU WIN!!";
|
||||
}
|
||||
|
||||
// public bool CheckWin(List<Cell> CELLS)
|
||||
// {
|
||||
// foreach (Goal.GoalName cond in _goal._eligibleGoals)
|
||||
// {
|
||||
// foreach (List<int> condList in _goal._conditions[cond])
|
||||
// {
|
||||
// // if (condList.All(a=>CELLS.FirstOrDefault<Cell>(c=>c._address == a, null)?._owner == this))
|
||||
// // {
|
||||
// // return true;
|
||||
// // }
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// public void MarkCell(Cell CELL)
|
||||
// {
|
||||
// CELL._mark.Texture = _mark.Texture;
|
||||
// // CELL._owner = this;
|
||||
// }
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (Input.IsActionJustReleased("backspace"))
|
||||
{
|
||||
if (_board._owner._owner != null)
|
||||
{
|
||||
Challenge(_board._owner._owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
1
Gameplay/Player.cs.uid
Normal file
1
Gameplay/Player.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dth2vcgkp7iq0
|
||||
@@ -1,13 +0,0 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://12dh7l7eucb4"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://631085nn2jpc" path="res://Gameplay/Opponent.cs" id="1_h046w"]
|
||||
[ext_resource type="Texture2D" uid="uid://c51oi06i4yrvv" path="res://Art/x.png" id="2_7tesw"]
|
||||
|
||||
[node name="Opponent" type="Node2D"]
|
||||
script = ExtResource("1_h046w")
|
||||
|
||||
[node name="Mark" type="Sprite2D" parent="."]
|
||||
visible = false
|
||||
texture = ExtResource("2_7tesw")
|
||||
|
||||
[node name="Sprite" type="Sprite2D" parent="."]
|
||||
@@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://b7vhq2dkltsv"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://c51oi06i4yrvv" path="res://Art/x.png" id="1_c6108"]
|
||||
[ext_resource type="Script" uid="uid://dth2vcgkp7iq0" path="res://Player.cs" id="1_enp12"]
|
||||
[ext_resource type="Script" uid="uid://dth2vcgkp7iq0" path="res://Gameplay/Player.cs" id="1_enp12"]
|
||||
[ext_resource type="PackedScene" uid="uid://yaybgshgeb3d" path="res://Gameplay/phone.tscn" id="4_1d6nn"]
|
||||
[ext_resource type="PackedScene" uid="uid://b0ks34m6smjfd" path="res://Gameplay/business_card.tscn" id="5_ek8wa"]
|
||||
[ext_resource type="PackedScene" uid="uid://bmy783a4c0tal" path="res://Gameplay/boss.tscn" id="5_lfxdo"]
|
||||
|
||||
Reference in New Issue
Block a user