add default goal business cards, allow Board.GetCellsByOwner to accept actor instead of player, rework BusinessCard click to be accepted based on _goalMet instead of Disabled, add default goals to enemy class,
This commit is contained in:
@@ -7,7 +7,6 @@ using System.Security.Cryptography.X509Certificates;
|
|||||||
public partial class Actor : Sprite2D
|
public partial class Actor : Sprite2D
|
||||||
{
|
{
|
||||||
public Sprite2D _markNormal, _markPressed, _markHovered, _markDisabled, _markFocused;
|
public Sprite2D _markNormal, _markPressed, _markHovered, _markDisabled, _markFocused;
|
||||||
public Goal _goal;
|
|
||||||
public Board _board;
|
public Board _board;
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -71,9 +71,9 @@ public partial class Board : Sprite2D
|
|||||||
return _cells.Single(c=>c._address == ADDRESS);
|
return _cells.Single(c=>c._address == ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Cell> GetCellsByOwner(Player PLAYER)
|
public List<Cell> GetCellsByOwner(Actor ACTOR)
|
||||||
{
|
{
|
||||||
return _cells.Where(c=>c._marker == PLAYER).ToList();
|
return _cells.Where(c=>c._marker == ACTOR).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
//THIS SHOULD BE MOVED INTO ACTION LOGIC
|
//THIS SHOULD BE MOVED INTO ACTION LOGIC
|
||||||
|
|||||||
@@ -19,24 +19,30 @@ public partial class BusinessCard : TextureButton
|
|||||||
public override void _Pressed()
|
public override void _Pressed()
|
||||||
{
|
{
|
||||||
base._Pressed();
|
base._Pressed();
|
||||||
GD.Print("Pressed");
|
_player._busDebug.Text = _goalName.ToString() + (_goalMet ? "": " NOT") + " MET";
|
||||||
|
if (_goalMet)
|
||||||
|
{
|
||||||
_player._activeEnemy.Defeat(_goalName);
|
_player._activeEnemy.Defeat(_goalName);
|
||||||
_player.Challenge(_player._activeEnemy._owner._board._owner);
|
_player.Challenge(_player._activeEnemy._owner._board._owner);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void AssignGoal(GoalName GOALNAME)
|
public void AssignGoal(GoalName GOALNAME)
|
||||||
{
|
{
|
||||||
_goalName = GOALNAME;
|
_goalName = GOALNAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AssignRandomGoal()
|
||||||
|
{
|
||||||
|
Random r = new Random();
|
||||||
|
AssignGoal(_goal._conditions.Keys.ElementAt(r.Next(_goal._conditions.Keys.Count)));
|
||||||
|
}
|
||||||
|
|
||||||
public void CheckGoal()
|
public void CheckGoal()
|
||||||
{
|
{
|
||||||
List<Cell> ownedCells = _player._board.GetCellsByOwner(_player);
|
List<Cell> ownedCells = _player._board.GetCellsByOwner(_player);
|
||||||
List<int> addresses = _goal.GetAddresses(_goalName);
|
List<int> addresses = _goal.GetAddresses(_goalName);
|
||||||
_goalMet = addresses.All(a=>ownedCells.Select(c=>c._address).ToList().IndexOf(a)>-1);
|
_goalMet = addresses.All(a=>ownedCells.Select(c=>c._address).ToList().IndexOf(a)>-1);
|
||||||
GD.Print(_goalMet);
|
|
||||||
Disabled = !_goalMet;
|
|
||||||
GD.Print(Disabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PassPlayer(Player PLAYER)
|
public void PassPlayer(Player PLAYER)
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ public partial class Cell : TextureButton
|
|||||||
public override void _Pressed()
|
public override void _Pressed()
|
||||||
{
|
{
|
||||||
base._Pressed();
|
base._Pressed();
|
||||||
// GD.Print(_tenant.GetType().ToString() + " " + _tenant._number + " Pressed");
|
|
||||||
// GD.Print(_board._owner.GetType().ToString() + " " + _board._owner._number + " Pressed");
|
|
||||||
_owner.ClickCell(this);
|
_owner.ClickCell(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
public partial class Enemy : Actor
|
public partial class Enemy : Actor
|
||||||
{
|
{
|
||||||
@@ -7,6 +9,7 @@ public partial class Enemy : Actor
|
|||||||
public Player _playerOpponent;
|
public Player _playerOpponent;
|
||||||
public Cell _cell;
|
public Cell _cell;
|
||||||
public Enemy _owner;
|
public Enemy _owner;
|
||||||
|
public List<GoalName> _defaultGoals = new();
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
@@ -14,6 +17,14 @@ public partial class Enemy : Actor
|
|||||||
_board = GetNode<Board>("Board");
|
_board = GetNode<Board>("Board");
|
||||||
_board.ClaimOwnership(this);
|
_board.ClaimOwnership(this);
|
||||||
_board.Disable(true);
|
_board.Disable(true);
|
||||||
|
_defaultGoals.Add(GoalName.TopRow);
|
||||||
|
_defaultGoals.Add(GoalName.MiddleRow);
|
||||||
|
_defaultGoals.Add(GoalName.BottomRow);
|
||||||
|
_defaultGoals.Add(GoalName.LeftColumn);
|
||||||
|
_defaultGoals.Add(GoalName.MiddleColumn);
|
||||||
|
_defaultGoals.Add(GoalName.RightColumn);
|
||||||
|
_defaultGoals.Add(GoalName.Diagonal1To9);
|
||||||
|
_defaultGoals.Add(GoalName.Diagonal3To7);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void PassPlayer(Player PLAYER)
|
public virtual void PassPlayer(Player PLAYER)
|
||||||
@@ -21,6 +32,23 @@ public partial class Enemy : Actor
|
|||||||
_playerOpponent = PLAYER;
|
_playerOpponent = PLAYER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CheckGoals()
|
||||||
|
{
|
||||||
|
List<Cell> ownedCells = _board.GetCellsByOwner(this);
|
||||||
|
Goal goal = new Goal();
|
||||||
|
for (int i = 0; i < _defaultGoals.Count; i++)
|
||||||
|
{
|
||||||
|
GoalName goalName = _defaultGoals[i];
|
||||||
|
List<int> addresses = goal.GetAddresses(goalName);
|
||||||
|
bool goalMet = addresses.All(a=>ownedCells.Select(c=>c._address).ToList().IndexOf(a)>-1);
|
||||||
|
if (goalMet)
|
||||||
|
{
|
||||||
|
Victory(goalName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void ClickCell(Cell CLICKEDCELL)
|
public virtual void ClickCell(Cell CLICKEDCELL)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ public partial class Goal : Node
|
|||||||
{GoalName.LeftColumn, new (){1,4,7}},
|
{GoalName.LeftColumn, new (){1,4,7}},
|
||||||
{GoalName.MiddleColumn, new (){2,5,8}},
|
{GoalName.MiddleColumn, new (){2,5,8}},
|
||||||
{GoalName.RightColumn, new (){3,6,9}},
|
{GoalName.RightColumn, new (){3,6,9}},
|
||||||
{GoalName.ForwardDiagonal, new (){3,5,7}},
|
{GoalName.Diagonal1To9, new (){1,5,9}},
|
||||||
{GoalName.BackwardDiagonal, new (){1,5,9}},
|
{GoalName.Diagonal3To7, new (){3,5,7}},
|
||||||
{GoalName.Number1, new (){1,2,5,7,8,9}},
|
{GoalName.Number1, new (){1,2,5,7,8,9}},
|
||||||
{GoalName.Number2, new (){1,2,4,5,8,9}},
|
{GoalName.Number2, new (){1,2,4,5,8,9}},
|
||||||
{GoalName.Number3, new (){1,2,5,6,7,8}},
|
{GoalName.Number3, new (){1,2,5,6,7,8}},
|
||||||
@@ -62,6 +62,8 @@ public partial class Goal : Node
|
|||||||
{GoalName.ShortRightAngleAt9, new (){6,8,9}},
|
{GoalName.ShortRightAngleAt9, new (){6,8,9}},
|
||||||
{GoalName.Corners, new (){1,4,7,9}},
|
{GoalName.Corners, new (){1,4,7,9}},
|
||||||
{GoalName.Diamond, new (){2,4,6,8}},
|
{GoalName.Diamond, new (){2,4,6,8}},
|
||||||
|
{GoalName.Blackout, new (){1,2,3,4,5,6,7,8,9}},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public List<int> GetAddresses(GoalName NAME)
|
public List<int> GetAddresses(GoalName NAME)
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ public enum GoalName
|
|||||||
LeftColumn,
|
LeftColumn,
|
||||||
MiddleColumn,
|
MiddleColumn,
|
||||||
RightColumn,
|
RightColumn,
|
||||||
ForwardDiagonal,
|
Diagonal1To9,
|
||||||
BackwardDiagonal,
|
Diagonal3To7,
|
||||||
Number1,
|
Number1,
|
||||||
Number2,
|
Number2,
|
||||||
Number3,
|
Number3,
|
||||||
@@ -54,5 +54,6 @@ public enum GoalName
|
|||||||
ShortRightAngleAt9,
|
ShortRightAngleAt9,
|
||||||
Corners,
|
Corners,
|
||||||
Diamond,
|
Diamond,
|
||||||
Plus
|
Plus,
|
||||||
|
Blackout
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,6 @@ public partial class Mook : Enemy
|
|||||||
public override void ClickCell(Cell CLICKEDCELL)
|
public override void ClickCell(Cell CLICKEDCELL)
|
||||||
{
|
{
|
||||||
CLICKEDCELL.Mark(_playerOpponent);
|
CLICKEDCELL.Mark(_playerOpponent);
|
||||||
_playerOpponent.CheckBusinessCards();
|
_playerOpponent.CheckGoals();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
[node name="BusinessCard" type="TextureButton"]
|
[node name="BusinessCard" type="TextureButton"]
|
||||||
modulate = Color(1, 1, 1, 0.2)
|
modulate = Color(1, 1, 1, 0.2)
|
||||||
disabled = true
|
|
||||||
texture_normal = ExtResource("1_8xr8s")
|
texture_normal = ExtResource("1_8xr8s")
|
||||||
texture_pressed = ExtResource("1_8xr8s")
|
texture_pressed = ExtResource("1_8xr8s")
|
||||||
texture_hover = ExtResource("1_8xr8s")
|
texture_hover = ExtResource("1_8xr8s")
|
||||||
|
|||||||
@@ -49,3 +49,108 @@ offset_left = 98.0
|
|||||||
offset_top = 769.0
|
offset_top = 769.0
|
||||||
offset_right = 298.0
|
offset_right = 298.0
|
||||||
offset_bottom = 969.0
|
offset_bottom = 969.0
|
||||||
|
|
||||||
|
[node name="DefaultDiagonal1To9" parent="." instance=ExtResource("5_ek8wa")]
|
||||||
|
offset_left = 461.0
|
||||||
|
offset_top = 41.0
|
||||||
|
offset_right = 661.0
|
||||||
|
offset_bottom = 241.0
|
||||||
|
|
||||||
|
[node name="DefaultTopRow" parent="." instance=ExtResource("5_ek8wa")]
|
||||||
|
offset_left = 467.0
|
||||||
|
offset_top = 236.0
|
||||||
|
offset_right = 667.0
|
||||||
|
offset_bottom = 436.0
|
||||||
|
|
||||||
|
[node name="DefaultMiddleRow" parent="." instance=ExtResource("5_ek8wa")]
|
||||||
|
offset_left = 461.0
|
||||||
|
offset_top = 437.0
|
||||||
|
offset_right = 661.0
|
||||||
|
offset_bottom = 637.0
|
||||||
|
|
||||||
|
[node name="DefaultBottomRow" parent="." instance=ExtResource("5_ek8wa")]
|
||||||
|
offset_left = 458.0
|
||||||
|
offset_top = 637.0
|
||||||
|
offset_right = 658.0
|
||||||
|
offset_bottom = 837.0
|
||||||
|
|
||||||
|
[node name="DefaultLeftColumn" parent="." instance=ExtResource("5_ek8wa")]
|
||||||
|
offset_left = 665.0
|
||||||
|
offset_top = 38.0
|
||||||
|
offset_right = 865.0
|
||||||
|
offset_bottom = 238.0
|
||||||
|
|
||||||
|
[node name="DefaultMiddleColumn" parent="." instance=ExtResource("5_ek8wa")]
|
||||||
|
offset_left = 863.0
|
||||||
|
offset_top = 35.0
|
||||||
|
offset_right = 1063.0
|
||||||
|
offset_bottom = 235.0
|
||||||
|
|
||||||
|
[node name="DefaultRightColumn" parent="." instance=ExtResource("5_ek8wa")]
|
||||||
|
offset_left = 1061.0
|
||||||
|
offset_top = 41.0
|
||||||
|
offset_right = 1261.0
|
||||||
|
offset_bottom = 241.0
|
||||||
|
|
||||||
|
[node name="DefaultDiagonal3To7" parent="." instance=ExtResource("5_ek8wa")]
|
||||||
|
offset_left = 1264.0
|
||||||
|
offset_top = 44.0
|
||||||
|
offset_right = 1464.0
|
||||||
|
offset_bottom = 244.0
|
||||||
|
|
||||||
|
[node name="DefaultTopRowAlt" parent="." instance=ExtResource("5_ek8wa")]
|
||||||
|
offset_left = 1261.0
|
||||||
|
offset_top = 236.0
|
||||||
|
offset_right = 1461.0
|
||||||
|
offset_bottom = 436.0
|
||||||
|
|
||||||
|
[node name="DefaultMiddleRowAlt" parent="." instance=ExtResource("5_ek8wa")]
|
||||||
|
offset_left = 1255.0
|
||||||
|
offset_top = 434.0
|
||||||
|
offset_right = 1455.0
|
||||||
|
offset_bottom = 634.0
|
||||||
|
|
||||||
|
[node name="DefaultBottomRowAlt" parent="." instance=ExtResource("5_ek8wa")]
|
||||||
|
offset_left = 1261.0
|
||||||
|
offset_top = 628.0
|
||||||
|
offset_right = 1461.0
|
||||||
|
offset_bottom = 828.0
|
||||||
|
|
||||||
|
[node name="DefaultDiagonal1To9Alt" parent="." instance=ExtResource("5_ek8wa")]
|
||||||
|
offset_left = 1264.0
|
||||||
|
offset_top = 826.0
|
||||||
|
offset_right = 1464.0
|
||||||
|
offset_bottom = 1026.0
|
||||||
|
|
||||||
|
[node name="DefaultDiagonal3To7Alt" parent="." instance=ExtResource("5_ek8wa")]
|
||||||
|
offset_left = 467.0
|
||||||
|
offset_top = 829.0
|
||||||
|
offset_right = 667.0
|
||||||
|
offset_bottom = 1029.0
|
||||||
|
|
||||||
|
[node name="DefaultLeftColumnAlt" parent="." instance=ExtResource("5_ek8wa")]
|
||||||
|
offset_left = 665.0
|
||||||
|
offset_top = 838.0
|
||||||
|
offset_right = 865.0
|
||||||
|
offset_bottom = 1038.0
|
||||||
|
|
||||||
|
[node name="DefaultMiddleColumnAlt" parent="." instance=ExtResource("5_ek8wa")]
|
||||||
|
offset_left = 869.0
|
||||||
|
offset_top = 838.0
|
||||||
|
offset_right = 1069.0
|
||||||
|
offset_bottom = 1038.0
|
||||||
|
|
||||||
|
[node name="DefaultRightColumnAlt" parent="." instance=ExtResource("5_ek8wa")]
|
||||||
|
offset_left = 1064.0
|
||||||
|
offset_top = 838.0
|
||||||
|
offset_right = 1264.0
|
||||||
|
offset_bottom = 1038.0
|
||||||
|
|
||||||
|
[node name="BusDebug" type="RichTextLabel" parent="."]
|
||||||
|
offset_top = 276.0
|
||||||
|
offset_right = 322.0
|
||||||
|
offset_bottom = 429.0
|
||||||
|
theme_override_font_sizes/normal_font_size = 32
|
||||||
|
text = "BusDEBUG"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
|||||||
20
Player.cs
20
Player.cs
@@ -11,7 +11,7 @@ public partial class Player : Actor
|
|||||||
public Phone _phone;
|
public Phone _phone;
|
||||||
public Boss _boss;
|
public Boss _boss;
|
||||||
public Enemy _activeEnemy;
|
public Enemy _activeEnemy;
|
||||||
public RichTextLabel _debug;
|
public RichTextLabel _debug, _busDebug;
|
||||||
public List<BusinessCard> _businessCards;
|
public List<BusinessCard> _businessCards;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
@@ -19,6 +19,7 @@ public partial class Player : Actor
|
|||||||
base._Ready();
|
base._Ready();
|
||||||
|
|
||||||
_debug = GetNode<RichTextLabel>("Debug");
|
_debug = GetNode<RichTextLabel>("Debug");
|
||||||
|
_busDebug = GetNode<RichTextLabel>("BusDebug");
|
||||||
|
|
||||||
_phone = GetNode<Phone>("Phone");
|
_phone = GetNode<Phone>("Phone");
|
||||||
_phone.PassPlayer(this);
|
_phone.PassPlayer(this);
|
||||||
@@ -30,9 +31,18 @@ public partial class Player : Actor
|
|||||||
for (int i = 0; i < _businessCards.Count; i++)
|
for (int i = 0; i < _businessCards.Count; i++)
|
||||||
{
|
{
|
||||||
_businessCards[i].PassPlayer(this);
|
_businessCards[i].PassPlayer(this);
|
||||||
_businessCards[i].AssignGoal(GoalName.MiddleColumn);
|
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);
|
Challenge(_boss);
|
||||||
}
|
}
|
||||||
@@ -43,7 +53,7 @@ public partial class Player : Actor
|
|||||||
ENEMY._board.Activate();
|
ENEMY._board.Activate();
|
||||||
_board = ENEMY._board;
|
_board = ENEMY._board;
|
||||||
_activeEnemy = ENEMY;
|
_activeEnemy = ENEMY;
|
||||||
CheckBusinessCards();
|
CheckGoals();
|
||||||
|
|
||||||
string text = "";
|
string text = "";
|
||||||
if (_activeEnemy is Mook)
|
if (_activeEnemy is Mook)
|
||||||
@@ -57,7 +67,7 @@ public partial class Player : Actor
|
|||||||
_debug.Text = text;
|
_debug.Text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckBusinessCards()
|
public void CheckGoals()
|
||||||
{
|
{
|
||||||
_businessCards.ForEach(b=>b.CheckGoal());
|
_businessCards.ForEach(b=>b.CheckGoal());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user