reworked Mark function to handle Clear function, fixed Goal class to adjusted address format, added shufflecellsfunction
This commit is contained in:
@@ -20,7 +20,7 @@ public partial class Actor : Sprite2D
|
||||
|
||||
// CALLABLE ACTIONS
|
||||
|
||||
public bool RotateCells(int ROTATIONS = 1, bool JUST_MARKS = false)
|
||||
public bool RotateCells(int ROTATIONS = 1)
|
||||
{
|
||||
List<Vector2> positions = new(_board._cells.Select(c=>c.Position).ToList());
|
||||
List<int> addresses = new(_board._cells.Select(c=>c._address).ToList());
|
||||
@@ -54,6 +54,18 @@ public partial class Actor : Sprite2D
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ShuffleCells()
|
||||
{
|
||||
List<Vector2> positions = new(_board._cells.Select(c=>c.Position).ToList());
|
||||
Globals.Shuffle(positions);
|
||||
for (int i = 0; i < _board._cells.Count; i++)
|
||||
{
|
||||
_board._cells[i].Position = positions[i];
|
||||
}
|
||||
_board.RenumberCells();
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ShiftMarks(int COLUMNS = 0, int ROWS = 0)
|
||||
{
|
||||
List<Actor> markers = new(_board._cells.Select(c=>c._marker).ToList());
|
||||
@@ -73,31 +85,14 @@ public partial class Actor : Sprite2D
|
||||
if (_board._cells[fromI]._marker != null)
|
||||
{
|
||||
_board._cells[toI].Mark(_board._cells[fromI]._marker);
|
||||
_board._cells[fromI].Clear();
|
||||
_board._cells[fromI].Mark();
|
||||
}
|
||||
else
|
||||
{
|
||||
_board._cells[toI].Clear();
|
||||
_board._cells[toI].Mark();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// int actualIndex =
|
||||
// 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();
|
||||
|
||||
@@ -150,10 +145,6 @@ public partial class Actor : Sprite2D
|
||||
|
||||
//MoveMark
|
||||
|
||||
//ShiftColumns
|
||||
|
||||
//ShiftRows
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public partial class Board : Sprite2D
|
||||
public void ClearBoard(){
|
||||
foreach (Cell cell in _cells)
|
||||
{
|
||||
cell.Clear();
|
||||
cell.Mark();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,9 +88,7 @@ public partial class Board : Sprite2D
|
||||
|
||||
public void RenumberCells()
|
||||
{
|
||||
GD.Print(string.Join(", ", _cells.Select(c=>c._address)));
|
||||
_cells = _cells.OrderBy(c => c.Position.Y).ThenBy(c => c.Position.X).ToList();
|
||||
GD.Print(string.Join(", ", _cells.Select(c=>c._address)));
|
||||
|
||||
for (int i = 0; i < _cells.Count; i++)
|
||||
{
|
||||
|
||||
@@ -45,6 +45,7 @@ public partial class BusinessCard : TextureButton
|
||||
_goalMet = addresses.All(a=>ownedCells.Select(c=>c._address).ToList().IndexOf(a)>-1);
|
||||
if (_goalMet)
|
||||
{
|
||||
GD.Print(_goalName);
|
||||
Modulate = new Color(1,1,1,1);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -33,19 +33,14 @@ public partial class Cell : TextureButton
|
||||
SetProcess(!DISABLED);
|
||||
}
|
||||
|
||||
public void Mark(Actor MARKER)
|
||||
public void Mark(Actor MARKER = null)
|
||||
{
|
||||
_marker = MARKER;
|
||||
TextureNormal = MARKER._markNormal.Texture;
|
||||
TexturePressed = MARKER._markPressed.Texture;
|
||||
TextureHover = MARKER._markHovered.Texture;
|
||||
TextureDisabled = MARKER._markDisabled.Texture;
|
||||
TextureFocused = MARKER._markFocused.Texture;
|
||||
TextureNormal = (MARKER == null ? _defaultMark : MARKER._markNormal).Texture;
|
||||
TexturePressed = (MARKER == null ? _defaultMark : MARKER._markPressed).Texture;
|
||||
TextureHover = (MARKER == null ? _defaultMark : MARKER._markHovered).Texture;
|
||||
TextureDisabled = (MARKER == null ? _defaultMark : MARKER._markDisabled).Texture;
|
||||
TextureFocused = (MARKER == null ? _defaultMark : MARKER._markFocused).Texture;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_marker = null;
|
||||
TextureNormal = TexturePressed = TextureHover = TextureDisabled = TextureFocused = _defaultMark.Texture;
|
||||
}
|
||||
}
|
||||
|
||||
7
Gameplay/Contacts/ShuffleCells.cs
Normal file
7
Gameplay/Contacts/ShuffleCells.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
public partial class ShuffleCells : Contact
|
||||
{
|
||||
public override void CallAction()
|
||||
{
|
||||
_player.ShuffleCells();
|
||||
}
|
||||
}
|
||||
1
Gameplay/Contacts/ShuffleCells.cs.uid
Normal file
1
Gameplay/Contacts/ShuffleCells.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dshwao6it1ltt
|
||||
110
Gameplay/Goal.cs
110
Gameplay/Goal.cs
@@ -8,61 +8,61 @@ public partial class Goal : Node
|
||||
{
|
||||
public Dictionary<GoalName, List<int>> _conditions = new()
|
||||
{
|
||||
{GoalName.TopRow, new (){1,2,3}},
|
||||
{GoalName.MiddleRow, new (){4,5,6}},
|
||||
{GoalName.BottomRow, new (){7,8,9}},
|
||||
{GoalName.LeftColumn, new (){1,4,7}},
|
||||
{GoalName.MiddleColumn, new (){2,5,8}},
|
||||
{GoalName.RightColumn, new (){3,6,9}},
|
||||
{GoalName.Diagonal1To9, new (){1,5,9}},
|
||||
{GoalName.Diagonal3To7, new (){3,5,7}},
|
||||
{GoalName.Number1, new (){1,2,5,7,8,9}},
|
||||
{GoalName.Number2, new (){1,2,4,5,8,9}},
|
||||
{GoalName.Number3, new (){1,2,5,6,7,8}},
|
||||
{GoalName.Number4, new (){1,3,4,5,6,9}},
|
||||
{GoalName.Number5, new (){2,3,4,5,7,8}},
|
||||
{GoalName.Number6, new (){1,4,5,6,7,8,9}},
|
||||
{GoalName.Number7, new (){1,2,3,6,9}},
|
||||
{GoalName.Number8, new (){2,3,4,5,6,7,8}},
|
||||
{GoalName.Number9, new (){1,2,3,4,5,6,8,9}},
|
||||
{GoalName.Number0, new (){2,3,4,6,7,8}},
|
||||
{GoalName.LetterA, new (){2,4,5,6,7,9}},
|
||||
{GoalName.LetterB, new (){1,2,4,5,6,7,8,9}},
|
||||
{GoalName.LetterC, new (){1,2,3,4,7,8,9}},
|
||||
{GoalName.LetterD, new (){1,2,4,6,7,8}},
|
||||
{GoalName.LetterE, new (){1,2,3,4,5,7,8,9}},
|
||||
{GoalName.LetterF, new (){1,2,3,4,5,7}},
|
||||
{GoalName.LetterG, new (){1,2,4,6,7,8,9}},
|
||||
{GoalName.LetterH, new (){1,3,4,5,6,7,9}},
|
||||
{GoalName.LetterI, new (){1,2,3,5,7,8,9}},
|
||||
{GoalName.LetterJ, new (){1,2,3,5,7,8}},
|
||||
{GoalName.LetterK, new (){1,3,4,5,7,9}},
|
||||
{GoalName.LetterL, new (){3,5,7,8,9}},
|
||||
{GoalName.LetterM, new (){1,2,3,4,5,6,7,9}},
|
||||
{GoalName.LetterN, new (){1,2,3,4,6,7,9}},
|
||||
{GoalName.LetterO, new (){1,2,3,4,6,7,8,9}},
|
||||
{GoalName.LetterP, new (){1,2,3,4,5,6,7}},
|
||||
{GoalName.LetterQ, new (){1,2,3,4,6,7,8}},
|
||||
{GoalName.LetterR, new (){1,2,3,4,5,7,9}},
|
||||
{GoalName.LetterS, new (){2,3,5,7,8}},
|
||||
{GoalName.LetterT, new (){1,2,3,5,8}},
|
||||
{GoalName.LetterU, new (){1,3,4,6,7,8,9}},
|
||||
{GoalName.LetterV, new (){1,3,4,6,8}},
|
||||
{GoalName.LetterW, new (){1,3,4,5,6,7,8,9}},
|
||||
{GoalName.LetterX, new (){1,3,5,7,9}},
|
||||
{GoalName.LetterY, new (){1,3,5,8}},
|
||||
{GoalName.LetterZ, new (){1,2,5,8,9}},
|
||||
{GoalName.LongRightAngleAt1, new (){1,2,3,4,7}},
|
||||
{GoalName.LongRightAngleAt3, new (){1,2,3,6,9}},
|
||||
{GoalName.LongRightAngleAt7, new (){1,4,7,8,9}},
|
||||
{GoalName.LongRightAngleAt9, new (){3,6,7,8,9}},
|
||||
{GoalName.ShortRightAngleAt1, new (){1,2,4}},
|
||||
{GoalName.ShortRightAngleAt3, new (){2,3,6}},
|
||||
{GoalName.ShortRightAngleAt7, new (){4,7,8}},
|
||||
{GoalName.ShortRightAngleAt9, new (){6,8,9}},
|
||||
{GoalName.Corners, new (){1,4,7,9}},
|
||||
{GoalName.Diamond, new (){2,4,6,8}},
|
||||
{GoalName.Blackout, new (){1,2,3,4,5,6,7,8,9}},
|
||||
{GoalName.TopRow, new (){0,1,2}},
|
||||
{GoalName.MiddleRow, new (){3,4,5}},
|
||||
{GoalName.BottomRow, new (){6,7,8}},
|
||||
{GoalName.LeftColumn, new (){0,3,6}},
|
||||
{GoalName.MiddleColumn, new (){1,4,7}},
|
||||
{GoalName.RightColumn, new (){2,5,8}},
|
||||
{GoalName.Diagonal1To9, new (){0,4,8}},
|
||||
{GoalName.Diagonal3To7, new (){2,4,6}},
|
||||
{GoalName.Number1, new (){0,1,4,6,7,8}},
|
||||
{GoalName.Number2, new (){0,1,3,4,7,8}},
|
||||
{GoalName.Number3, new (){0,1,4,5,6,7}},
|
||||
{GoalName.Number4, new (){0,2,3,4,5,8}},
|
||||
{GoalName.Number5, new (){1,2,3,4,6,7}},
|
||||
{GoalName.Number6, new (){0,3,4,5,6,7,8}},
|
||||
{GoalName.Number7, new (){0,1,2,5,8}},
|
||||
{GoalName.Number8, new (){1,2,3,4,5,6,7}},
|
||||
{GoalName.Number9, new (){0,1,2,3,4,5,7,8}},
|
||||
{GoalName.Number0, new (){1,2,3,5,6,7}},
|
||||
{GoalName.LetterA, new (){1,3,4,5,6,8}},
|
||||
{GoalName.LetterB, new (){0,1,3,4,5,6,7,8}},
|
||||
{GoalName.LetterC, new (){0,1,2,3,6,7,8}},
|
||||
{GoalName.LetterD, new (){0,1,3,5,6,7}},
|
||||
{GoalName.LetterE, new (){0,1,2,3,4,6,7,8}},
|
||||
{GoalName.LetterF, new (){0,1,2,3,4,6}},
|
||||
{GoalName.LetterG, new (){0,1,3,5,6,7,8}},
|
||||
{GoalName.LetterH, new (){0,2,3,4,5,6,8}},
|
||||
{GoalName.LetterI, new (){0,1,2,4,6,7,8}},
|
||||
{GoalName.LetterJ, new (){0,1,2,4,6,7}},
|
||||
{GoalName.LetterK, new (){0,2,3,4,6,8}},
|
||||
{GoalName.LetterL, new (){2,4,6,7,8}},
|
||||
{GoalName.LetterM, new (){0,1,2,3,4,5,6,8}},
|
||||
{GoalName.LetterN, new (){0,1,2,3,5,6,8}},
|
||||
{GoalName.LetterO, new (){0,1,2,3,5,6,7,8}},
|
||||
{GoalName.LetterP, new (){0,1,2,3,4,5,6}},
|
||||
{GoalName.LetterQ, new (){0,1,2,3,5,6,7}},
|
||||
{GoalName.LetterR, new (){0,1,2,3,4,6,8}},
|
||||
{GoalName.LetterS, new (){1,2,4,6,7}},
|
||||
{GoalName.LetterT, new (){0,1,2,4,7}},
|
||||
{GoalName.LetterU, new (){0,2,3,5,6,7,8}},
|
||||
{GoalName.LetterV, new (){0,2,3,5,7}},
|
||||
{GoalName.LetterW, new (){0,2,3,4,5,6,7,8}},
|
||||
{GoalName.LetterX, new (){0,2,4,6,8}},
|
||||
{GoalName.LetterY, new (){0,2,4,7}},
|
||||
{GoalName.LetterZ, new (){0,1,4,7,8}},
|
||||
{GoalName.LongRightAngleAt1, new (){0,1,2,3,6}},
|
||||
{GoalName.LongRightAngleAt3, new (){0,1,2,5,8}},
|
||||
{GoalName.LongRightAngleAt7, new (){0,3,6,7,8}},
|
||||
{GoalName.LongRightAngleAt9, new (){2,5,6,7,8}},
|
||||
{GoalName.ShortRightAngleAt1, new (){0,1,3}},
|
||||
{GoalName.ShortRightAngleAt3, new (){1,2,5}},
|
||||
{GoalName.ShortRightAngleAt7, new (){3,6,7}},
|
||||
{GoalName.ShortRightAngleAt9, new (){5,7,8}},
|
||||
{GoalName.Corners, new (){0,3,6,8}},
|
||||
{GoalName.Diamond, new (){1,3,5,7}},
|
||||
{GoalName.Blackout, new (){0,1,2,3,4,5,6,7,8}},
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ public partial class Phone : Sprite2D
|
||||
_phoneButtons[1]._contact = new Rotate90();
|
||||
_phoneButtons[2]._contact = new Swap1And6();
|
||||
_phoneButtons[3]._contact = new Shift1ColumnRight();
|
||||
_phoneButtons[4]._contact = new ShuffleCells();
|
||||
}
|
||||
|
||||
public override void _Process(double DELTA_)
|
||||
|
||||
Reference in New Issue
Block a user