diff --git a/Art/broken_shield.png b/Art/broken_shield.png new file mode 100644 index 0000000..4c9819c Binary files /dev/null and b/Art/broken_shield.png differ diff --git a/Art/broken_shield.png.import b/Art/broken_shield.png.import new file mode 100644 index 0000000..91d9ead --- /dev/null +++ b/Art/broken_shield.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b5oc4f3gxijq5" +path="res://.godot/imported/broken_shield.png-18bca4dc3aa93b7e622d775255883827.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Art/broken_shield.png" +dest_files=["res://.godot/imported/broken_shield.png-18bca4dc3aa93b7e622d775255883827.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Art/reg_shield.png b/Art/reg_shield.png new file mode 100644 index 0000000..33e885b Binary files /dev/null and b/Art/reg_shield.png differ diff --git a/Art/reg_shield.png.import b/Art/reg_shield.png.import new file mode 100644 index 0000000..78cabd4 --- /dev/null +++ b/Art/reg_shield.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://3agkku8rqvmj" +path="res://.godot/imported/reg_shield.png-707495a71352fd3f05b6fd7cddacd9a5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Art/reg_shield.png" +dest_files=["res://.godot/imported/reg_shield.png-707495a71352fd3f05b6fd7cddacd9a5.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Gameplay/Action.cs b/Gameplay/Action.cs new file mode 100644 index 0000000..b40c714 --- /dev/null +++ b/Gameplay/Action.cs @@ -0,0 +1,12 @@ +using Godot; +using System; + +public partial class Action : Node +{ + public float _timerSeconds, _cooldownSeconds; + public Actor _owner; + public virtual void Fire() + { + + } +} diff --git a/Gameplay/Action.cs.uid b/Gameplay/Action.cs.uid new file mode 100644 index 0000000..362af40 --- /dev/null +++ b/Gameplay/Action.cs.uid @@ -0,0 +1 @@ +uid://cac8dbhhcrjfe diff --git a/Gameplay/Actions/Example1.cs b/Gameplay/Actions/Example1.cs new file mode 100644 index 0000000..bbc1beb --- /dev/null +++ b/Gameplay/Actions/Example1.cs @@ -0,0 +1,25 @@ +using Godot; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; + +public partial class Example1 : Action +{ + + public override void _Ready() + { + base._Ready(); + } + + public override void Fire() + { + base.Fire(); + // GD.Print(_owner); + List unbrokenShields = [.. _owner._board._shields.Where(s=>!s._broken)]; + int shieldNumber = Globals._rng.Next(0, unbrokenShields.Count); + int damageAmount = Globals._rng.Next(-12,-8); + _owner._board._shields[shieldNumber].ChangeHealth(damageAmount); + ((Player)_owner)._phone._debug.Text = "Shield " + shieldNumber + " damaged " + damageAmount + "hp"; + } +} diff --git a/Gameplay/Actions/Example1.cs.uid b/Gameplay/Actions/Example1.cs.uid new file mode 100644 index 0000000..897d0b9 --- /dev/null +++ b/Gameplay/Actions/Example1.cs.uid @@ -0,0 +1 @@ +uid://bgl77ljlxm6xf diff --git a/Gameplay/Actor.cs b/Gameplay/Actor.cs index 61df053..c46c958 100644 --- a/Gameplay/Actor.cs +++ b/Gameplay/Actor.cs @@ -17,204 +17,5 @@ public partial class Actor : Sprite2D _markDisabled = GetNode("MarkDisabled"); _markFocused = GetNode("MarkFocused"); } - - // CALLABLE ACTIONS - - public bool RotateCells(int ROTATIONS = 1) - { - List positions = new(_board._cells.Select(c=>c.Position).ToList()); - List addresses = new(_board._cells.Select(c=>c._address).ToList()); - Dictionary cwShifts = new() - { - {0,1}, {1,2}, {2,5}, {3,0}, {4,4}, {5,8}, {6,3}, {7,6}, {8,7} - }; - Dictionary ccwShifts = new() - { - {0,3}, {1,0}, {2,1}, {3,6}, {4,4}, {5,2}, {6,7}, {7,8}, {8,5} - }; - Dictionary shifts = ROTATIONS > 0 ? cwShifts : ccwShifts; - - for (int i = 0; i < Math.Abs(ROTATIONS); i++) - { - for (int j = 0; j < addresses.Count; j++) - { - int address = addresses[j]; - int newAddress = shifts[address]; - addresses[j] = newAddress; - } - } - - for (int i = 0; i < _board._cells.Count; i++) - { - int newCellAddress = addresses[i]; - _board._cells[i].Position = positions[newCellAddress]; - } - - _board.RenumberCells(); - return true; - } - - public bool RotateMarks(int ROTATIONS = 1) - { - List cells = new(_board._cells); - List addresses = new(_board._cells.Select(c=>c._address).ToList()); - Dictionary cwShifts = new() - { - {0,1}, {1,2}, {2,5}, {3,0}, {4,4}, {5,8}, {6,3}, {7,6}, {8,7} - }; - Dictionary ccwShifts = new() - { - {0,3}, {1,0}, {2,1}, {3,6}, {4,4}, {5,2}, {6,7}, {7,8}, {8,5} - }; - Dictionary shifts = ROTATIONS > 0 ? cwShifts : ccwShifts; - - for (int i = 0; i < Math.Abs(ROTATIONS); i++) - { - for (int j = 0; j < addresses.Count; j++) - { - int address = addresses[j]; - int newAddress = shifts[address]; - addresses[j] = newAddress; - } - } - - for (int i = 0; i < _board._cells.Count; i++) - { - int newCellAddress = addresses[i]; - _board._cells[i].Mark(cells[newCellAddress]._marker); - } - - return true; - } - - public bool ShuffleCells() - { - List 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 ShuffleMarks() - { - List cells = new(_board._cells); - Globals.Shuffle(cells); - for (int i = 0; i < _board._cells.Count; i++) - { - _board._cells[i].Mark(cells[i]._marker); - } - - return true; - } - - public bool ShiftCells(int SHIFT_ROWS_BY = 0,int SHIFT_COLUMNS_BY = 0) - { - List positions = new(_board._cells.Select(c=>c.Position).ToList()); - int[,] addressTable = {{0,1,2},{3,4,5},{6,7,8}}; - List rows = new(){0,1,2}; - List columns = new(){0,1,2}; - - rows = Globals.ShiftList(rows, SHIFT_ROWS_BY); - columns = Globals.ShiftList(columns, SHIFT_COLUMNS_BY); - - for (int i = 0; i < rows.Count; i++) - { - for (int j = 0; j < columns.Count; j++) - { - _board._cells[addressTable[rows[i],columns[j]]].Position = positions[addressTable[i,j]]; - } - - } - - return true; - } - - public bool ShiftMarks(int SHIFT_ROWS_BY = 0,int SHIFT_COLUMNS_BY = 0) - { - List markers = new(_board._cells.Select(c=>c._marker).ToList()); - int[,] addressTable = {{0,1,2},{3,4,5},{6,7,8}}; - List rows = new(){0,1,2}; - List columns = new(){0,1,2}; - - rows = Globals.ShiftList(rows, SHIFT_ROWS_BY); - columns = Globals.ShiftList(columns, SHIFT_COLUMNS_BY); - - for (int i = 0; i < rows.Count; i++) - { - for (int j = 0; j < columns.Count; j++) - { - _board._cells[addressTable[rows[i],columns[j]]].Mark(markers[addressTable[i,j]]); - } - - } - - 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; - for (int i = 0; i < _board._cells.Count; i++) - { - int newSpot = (start + i + SHIFT_SPOTS) % 9; - _board._cells[i].Position = positions[newSpot]; - } - _board.RenumberCells(); - return true; - } - - public bool SlideMarks(int SHIFT_SPOTS = 1) - { - List positions = new(_board._cells.Select(c=>c.Position).ToList()); - int start = SHIFT_SPOTS > 0 ? 0 : 9; - for (int i = 0; i < _board._cells.Count; i++) - { - int newSpot = (start + i + SHIFT_SPOTS) % 9; - _board._cells[i].Position = positions[newSpot]; - } - _board.RenumberCells(); - return true; - } - - 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 || CELL_A_ADDRESS == CELL_B_ADDRESS) - { - return false; - } - List positions = new(_board._cells.Select(c=>c.Position).ToList()); - if (CELL_A_ADDRESS == -1) - { - 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 = Globals._rng.Next(0,8); - while (CELL_B_ADDRESS == CELL_A_ADDRESS) - { - CELL_B_ADDRESS = Globals._rng.Next(0,8); - } - } - _board._cells[CELL_A_ADDRESS].Position = positions[CELL_B_ADDRESS]; - _board._cells[CELL_B_ADDRESS].Position = positions[CELL_A_ADDRESS]; - _board.RenumberCells(); - - return true; - } - - - //MoveMark - - } diff --git a/Gameplay/Board.cs b/Gameplay/Board.cs index 4932f6f..ad34f3e 100644 --- a/Gameplay/Board.cs +++ b/Gameplay/Board.cs @@ -2,22 +2,33 @@ using Godot; using System; using System.Collections.Generic; using System.Diagnostics; +using System.Drawing; using System.Linq; using System.Runtime.Serialization; public partial class Board : Sprite2D { public bool _active = false, _moveMade = false, _won = false; - public List _cells = new(); + public List _shields = new(); public Enemy _owner; public Actor _winner = null; public GoalName _winningPattern; public override void _Ready() { - _cells = GetChildren().Where(c=>c is Cell).Cast().ToList(); - for (int i = 0; i < _cells.Count; i++) + _shields = GetChildren().Where(c=>c is Shield).Cast().ToList(); + int xSize = (int)Texture.GetSize().X; + int ySize = (int)Texture.GetSize().Y; + for (int i = 0; i < _shields.Count; i++) { - _cells[i]._address = i; + _shields[i]._address = i; + float shieldX = _shields[i].TextureNormal.GetSize().X; + float shieldY = _shields[i].TextureNormal.GetSize().Y; + + _shields[i].Scale = new Vector2(shieldX / (xSize/3), shieldY / (ySize/3)); + int c = i % 3 - 1; + int r = (int)(i/3) - 1; + + _shields[i].Position = new Vector2(xSize / 3f * c - shieldX / 2, ySize / 3f * r - shieldY / 2); } } @@ -45,14 +56,14 @@ public partial class Board : Sprite2D public void ClaimOwnership(Enemy OWNER) { _owner = OWNER; - _cells.ForEach(c=>c._owner = OWNER); - _cells.ForEach(c=>c._board = this); + _shields.ForEach(c=>c._owner = OWNER); + _shields.ForEach(c=>c._board = this); } public void ClearBoard(){ - foreach (Cell cell in _cells) + foreach (Shield shield in _shields) { - cell.Mark(); + // shield.Mark(); } } @@ -61,19 +72,19 @@ public partial class Board : Sprite2D Disable(true); } - public Cell GetCellByTenant(Enemy TENANT) + public Shield GetShieldByTenant(Enemy TENANT) { - return _cells.Single(c=>c._tenant == TENANT); + return _shields.Single(c=>c._tenant == TENANT); } - public Cell GetCellByAddress(int ADDRESS) + public Shield GetShieldByAddress(int ADDRESS) { - return _cells.Single(c=>c._address == ADDRESS); + return _shields.Single(c=>c._address == ADDRESS); } - public List GetCellsByOwner(Actor ACTOR) + public List GetShieldsByOwner(Actor ACTOR) { - return _cells.Where(c=>c._marker == ACTOR).ToList(); + return _shields.Where(c=>c._marker == ACTOR).ToList(); } //THIS SHOULD BE MOVED INTO ACTION LOGIC @@ -82,17 +93,17 @@ public partial class Board : Sprite2D // for (int i = 0; i < REPEAT; i++) // { // Rotation += DEGREES * ((float)Math.PI / 180); - // RenumberCells(); + // RenumberShields(); // } // } - public void RenumberCells() + public void RenumberShields() { - _cells = _cells.OrderBy(c => c.Position.Y).ThenBy(c => c.Position.X).ToList(); + _shields = _shields.OrderBy(c => c.Position.Y).ThenBy(c => c.Position.X).ToList(); - for (int i = 0; i < _cells.Count; i++) + for (int i = 0; i < _shields.Count; i++) { - _cells[i]._address = i; + _shields[i]._address = i; } } @@ -108,6 +119,6 @@ public partial class Board : Sprite2D _active = !DISABLED; Visible = !DISABLED; SetProcess(!DISABLED); - _cells.ForEach(c=>c.Disable(DISABLED)); + _shields.ForEach(c=>c.Disable(DISABLED)); } } diff --git a/Gameplay/Boss.cs b/Gameplay/Boss.cs index 237ae7c..a9415cd 100644 --- a/Gameplay/Boss.cs +++ b/Gameplay/Boss.cs @@ -15,8 +15,8 @@ public partial class Boss : Enemy for (int i = 0; i < _dragons.Count; i++) { _dragons[i]._owner = this; - _dragons[i]._number = _board._cells[i]._address; - _board._cells[i]._tenant = _dragons[i]; + _dragons[i]._number = _board._shields[i]._address; + _board._shields[i]._tenant = _dragons[i]; } } @@ -26,9 +26,9 @@ public partial class Boss : Enemy _dragons.ForEach(d=>d.PassPlayer(PLAYER)); } - public override void ClickCell(Cell CLICKED_CELL) + public override void ClickShield(Shield CLICKED_SHIELD) { - _playerOpponent.Challenge(CLICKED_CELL._tenant); + _playerOpponent.Challenge(CLICKED_SHIELD._tenant); } } diff --git a/Gameplay/BusinessCard.cs b/Gameplay/BusinessCard.cs index 1861f14..471589e 100644 --- a/Gameplay/BusinessCard.cs +++ b/Gameplay/BusinessCard.cs @@ -40,12 +40,11 @@ public partial class BusinessCard : TextureButton public void CheckGoal() { - List ownedCells = _player._board.GetCellsByOwner(_player); + List ownedShields = _player._board.GetShieldsByOwner(_player); List addresses = _goal.GetAddresses(_goalName); - _goalMet = addresses.All(a=>ownedCells.Select(c=>c._address).ToList().IndexOf(a)>-1); + _goalMet = addresses.All(a=>ownedShields.Select(c=>c._address).ToList().IndexOf(a)>-1); if (_goalMet) { - GD.Print(_goalName); Modulate = new Color(1,1,1,1); } else diff --git a/Gameplay/CallButton.cs b/Gameplay/CallButton.cs index 2abbe44..0cf4a21 100644 --- a/Gameplay/CallButton.cs +++ b/Gameplay/CallButton.cs @@ -14,6 +14,6 @@ public partial class CallButton : TextureButton public override void _Pressed() { base._Pressed(); - _phone.CallLoadedContact(); + _phone._player.StartBattle(); } } diff --git a/Gameplay/Cell.cs b/Gameplay/Cell.cs deleted file mode 100644 index 1a06adb..0000000 --- a/Gameplay/Cell.cs +++ /dev/null @@ -1,46 +0,0 @@ -using Godot; -using System; -using System.Diagnostics; -using System.Runtime.CompilerServices; - -public partial class Cell : TextureButton -{ - public bool _isHovered = false, _isPressed = false, _isDisabled = false, _isFocused = false, _locked = false, _destroyed = false; - public int _address; - public Enemy _owner, _tenant; - public Actor _marker; - public Sprite2D _defaultMark; - public Board _board; - - public override void _Ready() - { - _defaultMark = GetNode("DefaultMark"); - } - - public override void _Pressed() - { - base._Pressed(); - _owner.ClickCell(this); - } - - public override void _Process(double DELTA) - { - base._Process(DELTA); - } - - public void Disable(bool DISABLED) - { - SetProcess(!DISABLED); - } - - public void Mark(Actor MARKER = null) - { - _marker = MARKER; - 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; - } - -} diff --git a/Gameplay/Contact.cs b/Gameplay/Contact.cs index 072407f..5a26a19 100644 --- a/Gameplay/Contact.cs +++ b/Gameplay/Contact.cs @@ -1,27 +1,73 @@ using Godot; using System; +using System.Runtime.CompilerServices; public partial class Contact : Sprite2D { - public Player _player; - public int _number; + public bool _clickable, _interval; + public int _number, _calls = 0, _maxCalls = 0; + public Timer _timer, _cooldown; + public Action _action; + public Actor _owner; public override void _Ready() { - + _timer = GetNode("Timer"); + _cooldown = GetNode("Cooldown"); + _action = GetNode("Action"); } public virtual void CallAction() { - + if (_cooldown.TimeLeft > 0 || _action._cooldownSeconds == 0) + { + GD.Print("Action fired!!"); + _action.Fire(); + } } public void PassNumber(int NUMBER) { _number = NUMBER; } - public void PassPlayer(Player PLAYER) + public void PassOwner(Actor OWNER) { - _player = PLAYER; + _owner = OWNER; + _action._owner = OWNER; + } + + public void SetTimer(float SECONDS) + { + _action._timerSeconds = SECONDS; + } + + public void SetCooldown(int SECONDS) + { + _action._cooldownSeconds = SECONDS; + } + + public void Start() + { + // GD.Print(_action._timerSeconds); + if (_action._timerSeconds > 0) + { + _timer.Start(_action._timerSeconds); + _calls = 0; + } + } + + private void OnTimerTimeout() + { + if (_calls <= _maxCalls || _maxCalls == 0) + { + CallAction(); + _timer.Start(_action._timerSeconds); + _calls++; + } + } + + private void OnCooldownTimeout() + { + } } diff --git a/Gameplay/Contacts/Rotate90.cs b/Gameplay/Contacts/Rotate90.cs deleted file mode 100644 index 61cf504..0000000 --- a/Gameplay/Contacts/Rotate90.cs +++ /dev/null @@ -1,7 +0,0 @@ -public partial class Rotate90 : Contact -{ - public override void CallAction() - { - _player.RotateCells(2); - } -} \ No newline at end of file diff --git a/Gameplay/Contacts/Rotate90.cs.uid b/Gameplay/Contacts/Rotate90.cs.uid deleted file mode 100644 index 7eb66ed..0000000 --- a/Gameplay/Contacts/Rotate90.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://dtv3bqpuf0y33 diff --git a/Gameplay/Contacts/Shift1ColumnRight.cs b/Gameplay/Contacts/Shift1ColumnRight.cs deleted file mode 100644 index 2d86ab1..0000000 --- a/Gameplay/Contacts/Shift1ColumnRight.cs +++ /dev/null @@ -1,7 +0,0 @@ -public partial class Shift1ColumnRight : Contact -{ - public override void CallAction() - { - _player.ShiftCells(0,1); - } -} \ No newline at end of file diff --git a/Gameplay/Contacts/Shift1ColumnRight.cs.uid b/Gameplay/Contacts/Shift1ColumnRight.cs.uid deleted file mode 100644 index 3dc26da..0000000 --- a/Gameplay/Contacts/Shift1ColumnRight.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://ciphg323a14cs diff --git a/Gameplay/Contacts/ShuffleCells.cs b/Gameplay/Contacts/ShuffleCells.cs deleted file mode 100644 index 0be9c1b..0000000 --- a/Gameplay/Contacts/ShuffleCells.cs +++ /dev/null @@ -1,7 +0,0 @@ -public partial class ShuffleCells : Contact -{ - public override void CallAction() - { - _player.ShuffleCells(); - } -} \ No newline at end of file diff --git a/Gameplay/Contacts/ShuffleCells.cs.uid b/Gameplay/Contacts/ShuffleCells.cs.uid deleted file mode 100644 index 4558425..0000000 --- a/Gameplay/Contacts/ShuffleCells.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://dshwao6it1ltt diff --git a/Gameplay/Contacts/SlideBack2.cs b/Gameplay/Contacts/SlideBack2.cs deleted file mode 100644 index 4da797d..0000000 --- a/Gameplay/Contacts/SlideBack2.cs +++ /dev/null @@ -1,7 +0,0 @@ -public partial class SlideBack2 : Contact -{ - public override void CallAction() - { - _player.SlideCells(-2); - } -} \ No newline at end of file diff --git a/Gameplay/Contacts/SlideBack2.cs.uid b/Gameplay/Contacts/SlideBack2.cs.uid deleted file mode 100644 index be11010..0000000 --- a/Gameplay/Contacts/SlideBack2.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://c14om0rrrui02 diff --git a/Gameplay/Contacts/Swap1And6.cs b/Gameplay/Contacts/Swap1And6.cs deleted file mode 100644 index 2412c80..0000000 --- a/Gameplay/Contacts/Swap1And6.cs +++ /dev/null @@ -1,7 +0,0 @@ -public partial class Swap1And6 : Contact -{ - public override void CallAction() - { - _player.SwapCells(1-1,6-1); - } -} \ No newline at end of file diff --git a/Gameplay/Contacts/Swap1And6.cs.uid b/Gameplay/Contacts/Swap1And6.cs.uid deleted file mode 100644 index d3d3d24..0000000 --- a/Gameplay/Contacts/Swap1And6.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bl37rkfpucd5e diff --git a/Gameplay/Dragon.cs b/Gameplay/Dragon.cs index b10611f..7125f9a 100644 --- a/Gameplay/Dragon.cs +++ b/Gameplay/Dragon.cs @@ -9,7 +9,7 @@ public partial class Dragon : Enemy // public Board _board; public List _mooks; // public Player _playerOpponent; - // public Cell _cell; + // public Shield _shield; public override void _Ready() { @@ -18,8 +18,8 @@ public partial class Dragon : Enemy for (int i = 0; i < _mooks.Count; i++) { _mooks[i]._owner = this; - _mooks[i]._number = _board._cells[i]._address; - _board._cells[i]._tenant = _mooks[i]; + _mooks[i]._number = _board._shields[i]._address; + _board._shields[i]._tenant = _mooks[i]; } } @@ -35,8 +35,8 @@ public partial class Dragon : Enemy } - public override void ClickCell(Cell CLICKED_CELL) + public override void ClickShield(Shield CLICKED_SHIELD) { - _playerOpponent.Challenge(CLICKED_CELL._tenant); + _playerOpponent.Challenge(CLICKED_SHIELD._tenant); } } diff --git a/Gameplay/Enemy.cs b/Gameplay/Enemy.cs index 8e84e3c..bf5e6ae 100644 --- a/Gameplay/Enemy.cs +++ b/Gameplay/Enemy.cs @@ -7,7 +7,7 @@ public partial class Enemy : Actor { public int _number; public Player _playerOpponent; - public Cell _cell; + public Shield _shield; public Enemy _owner; public List _defaultGoals = new(); public List _goals = new(); @@ -36,13 +36,13 @@ public partial class Enemy : Actor public void CheckGoals() { - List ownedCells = _board.GetCellsByOwner(this); + List ownedShields = _board.GetShieldsByOwner(this); Goal goal = new Goal(); for (int i = 0; i < _defaultGoals.Count; i++) { GoalName goalName = _defaultGoals[i]; List addresses = goal.GetAddresses(goalName); - bool goalMet = addresses.All(a=>ownedCells.Select(c=>c._address).ToList().IndexOf(a)>-1); + bool goalMet = addresses.All(a=>ownedShields.Select(c=>c._address).ToList().IndexOf(a)>-1); if (goalMet) { Victory(goalName); @@ -51,7 +51,7 @@ public partial class Enemy : Actor } } - public virtual void ClickCell(Cell CLICKED_CELL) + public virtual void ClickShield(Shield CLICKED_SHIELD) { } @@ -61,7 +61,7 @@ public partial class Enemy : Actor _board._winningPattern = WINNING_PATTERN; if (_owner != null) { - _owner._board.GetCellByTenant(this).Mark(_playerOpponent); + // _owner._board.GetShieldByTenant(this).Mark(_playerOpponent); } else { @@ -74,7 +74,7 @@ public partial class Enemy : Actor _board._winningPattern = WINNING_PATTERN; if (_owner != null) { - _owner._board.GetCellByTenant(this).Mark(this); + _owner._board.GetShieldByTenant(this).Break(); } else { diff --git a/Gameplay/Mook.cs b/Gameplay/Mook.cs index 945b351..6aa70f2 100644 --- a/Gameplay/Mook.cs +++ b/Gameplay/Mook.cs @@ -12,9 +12,9 @@ public partial class Mook : Enemy } - public override void ClickCell(Cell CLICKED_CELL) + public override void ClickShield(Shield CLICKED_SHIELD) { - CLICKED_CELL.Mark(_playerOpponent); + // CLICKED_SHIELD.Mark(_playerOpponent); _playerOpponent.CheckGoals(); } } diff --git a/Gameplay/Phone.cs b/Gameplay/Phone.cs index 2adf6a7..068e433 100644 --- a/Gameplay/Phone.cs +++ b/Gameplay/Phone.cs @@ -21,11 +21,9 @@ public partial class Phone : Sprite2D { _phoneButtons[i]._phone = this; } - _phoneButtons[0]._contact = new SlideBack2(); - _phoneButtons[1]._contact = new Rotate90(); - _phoneButtons[2]._contact = new Swap1And6(); - _phoneButtons[3]._contact = new Shift1ColumnRight(); - _phoneButtons[4]._contact = new ShuffleCells(); + _phoneButtons[0]._contact._action = new Example1(); + _phoneButtons[0]._contact._action._owner = _player; + _phoneButtons[0]._contact.SetTimer(1.5f); } public override void _Process(double DELTA_) @@ -33,17 +31,17 @@ public partial class Phone : Sprite2D // _hoveredButton = _phoneButtons.FirstOrDefault(c => c._isHovered, null); } - public void CallLoadedContact() - { - _loadedContact.CallAction(); - ResetContact(); - } + // public void CallLoadedContact() + // { + // _loadedContact.CallAction(); + // ResetContact(); + // } - public void LoadContact(Contact CONTACT) - { - _loadedContact = CONTACT; - _debug.Text = _loadedContact.GetType().ToString(); - } + // public void LoadContact(Contact CONTACT) + // { + // _loadedContact = CONTACT; + // _debug.Text = _loadedContact.GetType().ToString(); + // } public void PassPlayer(Player PLAYER) { @@ -51,7 +49,7 @@ public partial class Phone : Sprite2D for (int i = 0; i < _phoneButtons.Count; i++) { _phoneButtons[i]._phone = this; - _phoneButtons[i]._contact.PassPlayer(PLAYER); + _phoneButtons[i]._contact.PassOwner(PLAYER); _phoneButtons[i]._contact.PassNumber((i+1)%10); } } diff --git a/Gameplay/PhoneButton.cs b/Gameplay/PhoneButton.cs index 2b1667a..3ace364 100644 --- a/Gameplay/PhoneButton.cs +++ b/Gameplay/PhoneButton.cs @@ -4,7 +4,7 @@ using System; public partial class PhoneButton : TextureButton { // [Signal] - // public delegate void HoverEventHandler(Cell THISCELL, bool ISHOVERED); + // public delegate void HoverEventHandler(Shield THISSHIELD, bool ISHOVERED); public bool _isHovered = false; public Phone _phone; public Contact _contact; @@ -18,7 +18,10 @@ public partial class PhoneButton : TextureButton public override void _Pressed() { base._Pressed(); - _phone.LoadContact(_contact); + if (_contact._clickable) + { + _contact.CallAction(); + } } diff --git a/Gameplay/Player.cs b/Gameplay/Player.cs index 5c3e9a1..c72760b 100644 --- a/Gameplay/Player.cs +++ b/Gameplay/Player.cs @@ -82,13 +82,21 @@ public partial class Player : Actor _debug.Text = "YOU WIN!!"; } - // public bool CheckWin(List CELLS) + public void StartBattle() + { + for (int i = 0; i < _phone._phoneButtons.Count; i++) + { + _phone._phoneButtons[i]._contact.Start(); + } + } + + // public bool CheckWin(List SHIELDS) // { // foreach (Goal.GoalName cond in _goal._eligibleGoals) // { // foreach (List condList in _goal._conditions[cond]) // { - // // if (condList.All(a=>CELLS.FirstOrDefault(c=>c._address == a, null)?._owner == this)) + // // if (condList.All(a=>SHIELDS.FirstOrDefault(c=>c._address == a, null)?._owner == this)) // // { // // return true; // // } @@ -96,10 +104,10 @@ public partial class Player : Actor // } // return false; // } - // public void MarkCell(Cell CELL) + // public void MarkShield(Shield SHIELD) // { - // CELL._mark.Texture = _mark.Texture; - // // CELL._owner = this; + // SHIELD._mark.Texture = _mark.Texture; + // // SHIELD._owner = this; // } public override void _Process(double delta) diff --git a/Gameplay/Shield.cs b/Gameplay/Shield.cs new file mode 100644 index 0000000..a630750 --- /dev/null +++ b/Gameplay/Shield.cs @@ -0,0 +1,66 @@ +using Godot; +using System; +using System.Diagnostics; +using System.Runtime.CompilerServices; + +public partial class Shield : TextureButton +{ + public bool _isHovered = false, _isPressed = false, _isDisabled = false, _isFocused = false, _locked = false, _destroyed = false, _broken = false; + public int _address, _durability; + public Enemy _owner, _tenant; + public Actor _marker; + public Sprite2D _regularMark, _brokenMark; + public Board _board; + + public override void _Ready() + { + _regularMark = GetNode("RegularMark"); + _brokenMark = GetNode("BrokenMark"); + _durability = 100; + } + + public override void _Pressed() + { + base._Pressed(); + _owner.ClickShield(this); + } + + public override void _Process(double DELTA) + { + base._Process(DELTA); + } + + public void Break() + { + _broken = true; + TextureNormal = TexturePressed = TextureHover = TextureDisabled = TextureFocused = _brokenMark.Texture; + } + + public void ChangeHealth(int CHANGE_AMOUNT) + { + _durability += CHANGE_AMOUNT; + if (!_broken) + { + if (_durability <= 0) + { + Break(); + } + } + } + + public void Disable(bool DISABLED) + { + SetProcess(!DISABLED); + } + + // public void Mark(Actor MARKER = null) + // { + // _marker = MARKER; + // 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; + // } + +} diff --git a/Gameplay/Cell.cs.uid b/Gameplay/Shield.cs.uid similarity index 100% rename from Gameplay/Cell.cs.uid rename to Gameplay/Shield.cs.uid diff --git a/Gameplay/action.tscn b/Gameplay/action.tscn new file mode 100644 index 0000000..9cfa99c --- /dev/null +++ b/Gameplay/action.tscn @@ -0,0 +1,6 @@ +[gd_scene format=3 uid="uid://fygidhjkgabe"] + +[ext_resource type="Script" uid="uid://cac8dbhhcrjfe" path="res://Gameplay/Action.cs" id="1_lk435"] + +[node name="Action" type="Node" unique_id=110922950] +script = ExtResource("1_lk435") diff --git a/Gameplay/board.tscn b/Gameplay/board.tscn index f599c32..f678cfd 100644 --- a/Gameplay/board.tscn +++ b/Gameplay/board.tscn @@ -1,63 +1,27 @@ -[gd_scene load_steps=4 format=3 uid="uid://jkmo1fb2ohv4"] +[gd_scene format=3 uid="uid://jkmo1fb2ohv4"] [ext_resource type="Texture2D" uid="uid://cbi83mc26qju5" path="res://Art/Tic-tac-toe.png" id="1_iqk8r"] [ext_resource type="Script" uid="uid://decakbqo4jfdi" path="res://Gameplay/Board.cs" id="2_ucn0m"] -[ext_resource type="PackedScene" uid="uid://0vj01cjcpibt" path="res://Gameplay/cell.tscn" id="3_s74v7"] +[ext_resource type="PackedScene" uid="uid://b32djog2mowgw" path="res://Gameplay/shield.tscn" id="3_ucn0m"] -[node name="Board" type="Sprite2D"] +[node name="Board" type="Sprite2D" unique_id=816918439] texture = ExtResource("1_iqk8r") script = ExtResource("2_ucn0m") -[node name="Cell1" parent="." instance=ExtResource("3_s74v7")] -offset_left = -300.0 -offset_top = -301.0 -offset_right = -100.0 -offset_bottom = -101.0 +[node name="Shield0" parent="." unique_id=1408990258 instance=ExtResource("3_ucn0m")] -[node name="Cell2" parent="." instance=ExtResource("3_s74v7")] -offset_left = -100.0 -offset_top = -300.0 -offset_right = 100.0 -offset_bottom = -100.0 +[node name="Shield1" parent="." unique_id=1099937150 instance=ExtResource("3_ucn0m")] -[node name="Cell3" parent="." instance=ExtResource("3_s74v7")] -offset_left = 100.0 -offset_top = -300.0 -offset_right = 300.0 -offset_bottom = -100.0 +[node name="Shield2" parent="." unique_id=555260924 instance=ExtResource("3_ucn0m")] -[node name="Cell4" parent="." instance=ExtResource("3_s74v7")] -offset_left = -300.0 -offset_top = -100.0 -offset_right = -100.0 -offset_bottom = 100.0 +[node name="Shield3" parent="." unique_id=1428089072 instance=ExtResource("3_ucn0m")] -[node name="Cell5" parent="." instance=ExtResource("3_s74v7")] -offset_left = -100.0 -offset_top = -100.0 -offset_right = 100.0 -offset_bottom = 100.0 +[node name="Shield4" parent="." unique_id=1268807490 instance=ExtResource("3_ucn0m")] -[node name="Cell6" parent="." instance=ExtResource("3_s74v7")] -offset_left = 100.0 -offset_top = -100.0 -offset_right = 300.0 -offset_bottom = 100.0 +[node name="Shield5" parent="." unique_id=646412611 instance=ExtResource("3_ucn0m")] -[node name="Cell7" parent="." instance=ExtResource("3_s74v7")] -offset_left = -300.0 -offset_top = 100.0 -offset_right = -100.0 -offset_bottom = 300.0 +[node name="Shield6" parent="." unique_id=1387360377 instance=ExtResource("3_ucn0m")] -[node name="Cell8" parent="." instance=ExtResource("3_s74v7")] -offset_left = -100.0 -offset_top = 100.0 -offset_right = 100.0 -offset_bottom = 300.0 +[node name="Shield7" parent="." unique_id=949001958 instance=ExtResource("3_ucn0m")] -[node name="Cell9" parent="." instance=ExtResource("3_s74v7")] -offset_left = 100.0 -offset_top = 100.0 -offset_right = 300.0 -offset_bottom = 300.0 +[node name="Shield8" parent="." unique_id=1837156402 instance=ExtResource("3_ucn0m")] diff --git a/Gameplay/cell.tscn b/Gameplay/cell.tscn deleted file mode 100644 index d0e0b4d..0000000 --- a/Gameplay/cell.tscn +++ /dev/null @@ -1,19 +0,0 @@ -[gd_scene format=3 uid="uid://0vj01cjcpibt"] - -[ext_resource type="Script" uid="uid://pg7mpir3ewhw" path="res://Gameplay/Cell.cs" id="1_lehgd"] -[ext_resource type="Texture2D" uid="uid://g6ikqlh8yccy" path="res://Art/blanksquare.jpg" id="2_mxyjk"] - -[node name="Cell" type="TextureButton" unique_id=1408990258] -modulate = Color(1, 1, 1, 0.2) -offset_right = 200.0 -offset_bottom = 200.0 -texture_normal = ExtResource("2_mxyjk") -texture_pressed = ExtResource("2_mxyjk") -texture_hover = ExtResource("2_mxyjk") -texture_disabled = ExtResource("2_mxyjk") -texture_focused = ExtResource("2_mxyjk") -script = ExtResource("1_lehgd") - -[node name="DefaultMark" type="Sprite2D" parent="." unique_id=1684344431] -visible = false -texture = ExtResource("2_mxyjk") diff --git a/Gameplay/contact.tscn b/Gameplay/contact.tscn index 1a29102..2da0020 100644 --- a/Gameplay/contact.tscn +++ b/Gameplay/contact.tscn @@ -1,6 +1,16 @@ -[gd_scene load_steps=2 format=3 uid="uid://if21pf73w7by"] +[gd_scene format=3 uid="uid://if21pf73w7by"] [ext_resource type="Script" uid="uid://bgj2cuqdq0b6l" path="res://Gameplay/Contact.cs" id="1_basqx"] +[ext_resource type="PackedScene" uid="uid://fygidhjkgabe" path="res://Gameplay/action.tscn" id="2_dg7ct"] -[node name="Contact" type="Sprite2D"] +[node name="Contact" type="Sprite2D" unique_id=1143036413] script = ExtResource("1_basqx") + +[node name="Timer" type="Timer" parent="." unique_id=879173975] + +[node name="Cooldown" type="Timer" parent="." unique_id=1276257080] + +[node name="Action" parent="." unique_id=110922950 instance=ExtResource("2_dg7ct")] + +[connection signal="timeout" from="Timer" to="." method="OnTimerTimeout"] +[connection signal="timeout" from="Cooldown" to="." method="OnCooldownTimeout"] diff --git a/Gameplay/shield.tscn b/Gameplay/shield.tscn new file mode 100644 index 0000000..cd5c43e --- /dev/null +++ b/Gameplay/shield.tscn @@ -0,0 +1,24 @@ +[gd_scene format=3 uid="uid://b32djog2mowgw"] + +[ext_resource type="Texture2D" uid="uid://3agkku8rqvmj" path="res://Art/reg_shield.png" id="1_j8jvf"] +[ext_resource type="Script" uid="uid://pg7mpir3ewhw" path="res://Gameplay/Shield.cs" id="2_53x4r"] +[ext_resource type="Texture2D" uid="uid://b5oc4f3gxijq5" path="res://Art/broken_shield.png" id="3_tgx6c"] + +[node name="Shield" type="TextureButton" unique_id=1408990258] +modulate = Color(1, 1, 1, 0.2) +offset_right = 200.0 +offset_bottom = 200.0 +texture_normal = ExtResource("1_j8jvf") +texture_pressed = ExtResource("1_j8jvf") +texture_hover = ExtResource("1_j8jvf") +texture_disabled = ExtResource("1_j8jvf") +texture_focused = ExtResource("1_j8jvf") +script = ExtResource("2_53x4r") + +[node name="RegularMark" type="Sprite2D" parent="." unique_id=1684344431] +visible = false +texture = ExtResource("1_j8jvf") + +[node name="BrokenMark" type="Sprite2D" parent="." unique_id=1605725110] +visible = false +texture = ExtResource("3_tgx6c")