This commit is contained in:
2026-01-25 21:04:47 -05:00
parent 2fdf0d6442
commit 2c74f67abe
16 changed files with 90 additions and 43 deletions

View File

@@ -1,6 +1,7 @@
using Godot; using Godot;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data;
using System.Linq; using System.Linq;
@@ -53,7 +54,32 @@ public partial class Actor : Sprite2D
return true; 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()); List<Vector2> positions = new(_board._cells.Select(c=>c.Position).ToList());
int start = SHIFT_SPOTS > 0 ? 0 : 9; 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) 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; return false;
} }
List<Vector2> positions = new(_board._cells.Select(c=>c.Position).ToList()); List<Vector2> positions = new(_board._cells.Select(c=>c.Position).ToList());
Random random = new ();
if (CELL_A_ADDRESS == -1) 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) 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) 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]; _board._cells[CELL_A_ADDRESS].Position = positions[CELL_B_ADDRESS];
@@ -93,4 +122,13 @@ public partial class Actor : Sprite2D
return true; return true;
} }
//MoveMark
//ShiftColumns
//ShiftRows
} }

View File

@@ -45,7 +45,7 @@ public partial class Cell : TextureButton
public void Clear() public void Clear()
{ {
_marker = null; // _marker = null;
TextureNormal = TexturePressed = TextureHover = TextureDisabled = TextureFocused = _defaultMark.Texture; TextureNormal = TexturePressed = TextureHover = TextureDisabled = TextureFocused = _defaultMark.Texture;
} }
} }

View File

@@ -0,0 +1,7 @@
public partial class Shift1ColumnRight : Contact
{
public override void CallAction()
{
_player.ShiftMarks(1,0);
}
}

View File

@@ -0,0 +1 @@
uid://ciphg323a14cs

View File

@@ -1,7 +0,0 @@
public partial class ShiftBack2 : Contact
{
public override void CallAction()
{
_player.ShiftCells(-2);
}
}

View File

@@ -0,0 +1,7 @@
public partial class SlideBack2 : Contact
{
public override void CallAction()
{
_player.SlideCells(-2);
}
}

26
Gameplay/Globals.cs Normal file
View 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
View File

@@ -0,0 +1 @@
uid://ljqms5o2g2rb

View File

@@ -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
}
}

View File

@@ -1 +0,0 @@
uid://631085nn2jpc

View File

@@ -21,9 +21,10 @@ public partial class Phone : Sprite2D
{ {
_phoneButtons[i]._phone = this; _phoneButtons[i]._phone = this;
} }
_phoneButtons[0]._contact = new ShiftBack2(); _phoneButtons[0]._contact = new SlideBack2();
_phoneButtons[1]._contact = new Rotate90(); _phoneButtons[1]._contact = new Rotate90();
_phoneButtons[2]._contact = new Swap1And6(); _phoneButtons[2]._contact = new Swap1And6();
_phoneButtons[3]._contact = new Shift1ColumnRight();
} }
public override void _Process(double DELTA_) public override void _Process(double DELTA_)

View File

@@ -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="."]

View File

@@ -1,7 +1,7 @@
[gd_scene load_steps=8 format=3 uid="uid://b7vhq2dkltsv"] [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="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://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://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"] [ext_resource type="PackedScene" uid="uid://bmy783a4c0tal" path="res://Gameplay/boss.tscn" id="5_lfxdo"]