diff --git a/Gameplay/Actor.cs b/Gameplay/Actor.cs index 7c72a66..f31701e 100644 --- a/Gameplay/Actor.cs +++ b/Gameplay/Actor.cs @@ -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 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 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 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 + + } diff --git a/Gameplay/Cell.cs b/Gameplay/Cell.cs index 666c9cc..d3a796a 100644 --- a/Gameplay/Cell.cs +++ b/Gameplay/Cell.cs @@ -45,7 +45,7 @@ public partial class Cell : TextureButton public void Clear() { - _marker = null; + // _marker = null; TextureNormal = TexturePressed = TextureHover = TextureDisabled = TextureFocused = _defaultMark.Texture; } } diff --git a/Gameplay/Contacts/Shift1ColumnRight.cs b/Gameplay/Contacts/Shift1ColumnRight.cs new file mode 100644 index 0000000..45a24b3 --- /dev/null +++ b/Gameplay/Contacts/Shift1ColumnRight.cs @@ -0,0 +1,7 @@ +public partial class Shift1ColumnRight : Contact +{ + public override void CallAction() + { + _player.ShiftMarks(1,0); + } +} \ No newline at end of file diff --git a/Gameplay/Contacts/Shift1ColumnRight.cs.uid b/Gameplay/Contacts/Shift1ColumnRight.cs.uid new file mode 100644 index 0000000..3dc26da --- /dev/null +++ b/Gameplay/Contacts/Shift1ColumnRight.cs.uid @@ -0,0 +1 @@ +uid://ciphg323a14cs diff --git a/Gameplay/Contacts/ShiftBack2.cs b/Gameplay/Contacts/ShiftBack2.cs deleted file mode 100644 index da6b159..0000000 --- a/Gameplay/Contacts/ShiftBack2.cs +++ /dev/null @@ -1,7 +0,0 @@ -public partial class ShiftBack2 : Contact -{ - public override void CallAction() - { - _player.ShiftCells(-2); - } -} \ No newline at end of file diff --git a/Gameplay/Contacts/SlideBack2.cs b/Gameplay/Contacts/SlideBack2.cs new file mode 100644 index 0000000..4da797d --- /dev/null +++ b/Gameplay/Contacts/SlideBack2.cs @@ -0,0 +1,7 @@ +public partial class SlideBack2 : Contact +{ + public override void CallAction() + { + _player.SlideCells(-2); + } +} \ No newline at end of file diff --git a/Gameplay/Contacts/ShiftBack2.cs.uid b/Gameplay/Contacts/SlideBack2.cs.uid similarity index 100% rename from Gameplay/Contacts/ShiftBack2.cs.uid rename to Gameplay/Contacts/SlideBack2.cs.uid diff --git a/Gameplay/Globals.cs b/Gameplay/Globals.cs new file mode 100644 index 0000000..f9827a3 --- /dev/null +++ b/Gameplay/Globals.cs @@ -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 _addressTranslation = new(){"NW","N","NE","W","C","E","SW","S","SE"}; + + public static void Shuffle(this IList 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); + } +} \ No newline at end of file diff --git a/Gameplay/Globals.cs.uid b/Gameplay/Globals.cs.uid new file mode 100644 index 0000000..f656953 --- /dev/null +++ b/Gameplay/Globals.cs.uid @@ -0,0 +1 @@ +uid://ljqms5o2g2rb diff --git a/Gameplay/Opponent.cs b/Gameplay/Opponent.cs deleted file mode 100644 index 7a959f4..0000000 --- a/Gameplay/Opponent.cs +++ /dev/null @@ -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 - } -} diff --git a/Gameplay/Opponent.cs.uid b/Gameplay/Opponent.cs.uid deleted file mode 100644 index 60c85a7..0000000 --- a/Gameplay/Opponent.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://631085nn2jpc diff --git a/Gameplay/Phone.cs b/Gameplay/Phone.cs index 4c0e3eb..923cf3c 100644 --- a/Gameplay/Phone.cs +++ b/Gameplay/Phone.cs @@ -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_) diff --git a/Player.cs b/Gameplay/Player.cs similarity index 100% rename from Player.cs rename to Gameplay/Player.cs diff --git a/Player.cs.uid b/Gameplay/Player.cs.uid similarity index 100% rename from Player.cs.uid rename to Gameplay/Player.cs.uid diff --git a/Gameplay/opponent.tscn b/Gameplay/opponent.tscn deleted file mode 100644 index 0205397..0000000 --- a/Gameplay/opponent.tscn +++ /dev/null @@ -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="."] diff --git a/Gameplay/player.tscn b/Gameplay/player.tscn index bc26602..b9b6278 100644 --- a/Gameplay/player.tscn +++ b/Gameplay/player.tscn @@ -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"]