From 435fbc7ba26b04312e558a3b752d106a9c7a275f Mon Sep 17 00:00:00 2001 From: cojoedmo Date: Tue, 3 Feb 2026 03:37:58 -0500 Subject: [PATCH] reworking effects, turning them into their own scene for replicability --- Gameplay/Action.cs | 12 --- Gameplay/Actions/Example1.cs | 25 ------ Gameplay/Actions/Example1.cs.uid | 1 - Gameplay/Actions/Example2.cs | 22 ----- Gameplay/Actions/Example2.cs.uid | 1 - Gameplay/Contact.cs | 87 +++++++------------ Gameplay/Effect.cs | 27 ++++++ Gameplay/{Action.cs.uid => Effect.cs.uid} | 0 Gameplay/Effects/ClickEffect.cs | 61 +++++++++++++ Gameplay/Effects/ClickEffect.cs.uid | 1 + Gameplay/Effects/ClickEffects/ClickEffect1.cs | 20 +++++ .../Effects/ClickEffects/ClickEffect1.cs.uid | 1 + .../Effects/ClickEffects/click_effect1.tscn | 9 ++ Gameplay/Effects/PassiveEffect.cs | 7 ++ Gameplay/Effects/PassiveEffect.cs.uid | 1 + .../Effects/PassiveEffects/PassiveEffect1.cs | 7 ++ .../PassiveEffects/PassiveEffect1.cs.uid | 1 + Gameplay/Effects/TimeEffect.cs | 58 +++++++++++++ Gameplay/Effects/TimeEffect.cs.uid | 1 + Gameplay/Effects/TimeEffects/TimeEffect1.cs | 21 +++++ .../Effects/TimeEffects/TimeEffect1.cs.uid | 1 + .../Effects/TimeEffects/time_effect_1.tscn | 10 +++ Gameplay/Effects/click_effect.tscn | 9 ++ Gameplay/Effects/passive_effect.tscn | 7 ++ Gameplay/Effects/time_effect.tscn | 11 +++ Gameplay/Globals.cs | 27 +----- Gameplay/Phone.cs | 23 +++-- Gameplay/PhoneButton.cs | 9 +- Gameplay/Player.cs | 2 +- Gameplay/contact.tscn | 10 --- Gameplay/{action.tscn => effect.tscn} | 4 +- Gameplay/phone_button.tscn | 17 +++- 32 files changed, 321 insertions(+), 172 deletions(-) delete mode 100644 Gameplay/Action.cs delete mode 100644 Gameplay/Actions/Example1.cs delete mode 100644 Gameplay/Actions/Example1.cs.uid delete mode 100644 Gameplay/Actions/Example2.cs delete mode 100644 Gameplay/Actions/Example2.cs.uid create mode 100644 Gameplay/Effect.cs rename Gameplay/{Action.cs.uid => Effect.cs.uid} (100%) create mode 100644 Gameplay/Effects/ClickEffect.cs create mode 100644 Gameplay/Effects/ClickEffect.cs.uid create mode 100644 Gameplay/Effects/ClickEffects/ClickEffect1.cs create mode 100644 Gameplay/Effects/ClickEffects/ClickEffect1.cs.uid create mode 100644 Gameplay/Effects/ClickEffects/click_effect1.tscn create mode 100644 Gameplay/Effects/PassiveEffect.cs create mode 100644 Gameplay/Effects/PassiveEffect.cs.uid create mode 100644 Gameplay/Effects/PassiveEffects/PassiveEffect1.cs create mode 100644 Gameplay/Effects/PassiveEffects/PassiveEffect1.cs.uid create mode 100644 Gameplay/Effects/TimeEffect.cs create mode 100644 Gameplay/Effects/TimeEffect.cs.uid create mode 100644 Gameplay/Effects/TimeEffects/TimeEffect1.cs create mode 100644 Gameplay/Effects/TimeEffects/TimeEffect1.cs.uid create mode 100644 Gameplay/Effects/TimeEffects/time_effect_1.tscn create mode 100644 Gameplay/Effects/click_effect.tscn create mode 100644 Gameplay/Effects/passive_effect.tscn create mode 100644 Gameplay/Effects/time_effect.tscn rename Gameplay/{action.tscn => effect.tscn} (61%) diff --git a/Gameplay/Action.cs b/Gameplay/Action.cs deleted file mode 100644 index b07f1eb..0000000 --- a/Gameplay/Action.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Godot; -using System; - -public partial class Action : Node -{ - public float _timerSeconds, _cooldownSeconds; - public Contact _contact; - public virtual void Fire() - { - - } -} diff --git a/Gameplay/Actions/Example1.cs b/Gameplay/Actions/Example1.cs deleted file mode 100644 index 0b90f10..0000000 --- a/Gameplay/Actions/Example1.cs +++ /dev/null @@ -1,25 +0,0 @@ -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 = [.. _contact._owner._board._shields.Where(s=>!s._broken)]; - int shieldNumber = Globals._rng.Next(0, unbrokenShields.Count); - int damageAmount = Globals._rng.Next(-12,-8); - _contact._owner._board._shields[shieldNumber].ChangeHealth(damageAmount); - ((Player)_contact._owner)._phone._debug.Text = "Shield " + shieldNumber + " damaged " + damageAmount + "hp"; - } -} diff --git a/Gameplay/Actions/Example1.cs.uid b/Gameplay/Actions/Example1.cs.uid deleted file mode 100644 index 897d0b9..0000000 --- a/Gameplay/Actions/Example1.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bgl77ljlxm6xf diff --git a/Gameplay/Actions/Example2.cs b/Gameplay/Actions/Example2.cs deleted file mode 100644 index 85b26f8..0000000 --- a/Gameplay/Actions/Example2.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Godot; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.CompilerServices; - -public partial class Example2 : Action -{ - public override void _Ready() - { - base._Ready(); - } - - public override void Fire() - { - base.Fire(); - int shieldNumber = 2; - int damageAmount = Globals._rng.Next(-50,-30); - _contact._owner._board._shields[shieldNumber].ChangeHealth(damageAmount); - ((Player)_contact._owner)._phone._debug.Text = "Shield " + shieldNumber + " damaged " + damageAmount + "hp"; - } -} diff --git a/Gameplay/Actions/Example2.cs.uid b/Gameplay/Actions/Example2.cs.uid deleted file mode 100644 index 7d47d16..0000000 --- a/Gameplay/Actions/Example2.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bsmvcs8l2p211 diff --git a/Gameplay/Contact.cs b/Gameplay/Contact.cs index 1e517aa..711f28a 100644 --- a/Gameplay/Contact.cs +++ b/Gameplay/Contact.cs @@ -1,77 +1,54 @@ using Godot; using System; +using System.Collections.Generic; +using System.Linq; using System.Runtime.CompilerServices; public partial class Contact : Sprite2D { - public bool _clickable = false, _interval = false; - public int _number, _calls = 0, _maxCalls = 0; - public Timer _timer, _cooldown; - public Action _action; - public Actor _owner; + public int _number; + public List _effects; + public PhoneButton _button; + // public public override void _Ready() { - _timer = GetNode("Timer"); - _cooldown = GetNode("Cooldown"); - _action = GetNode("Action"); - _action._contact = this; + } - public virtual void CallAction() + public virtual void FireEffect() { - if (_cooldown.TimeLeft == 0 || _action._cooldownSeconds == 0) - { - GD.Print("Action fired!!"); - _action.Fire(); - } + + } + + public virtual void End() + { + _effects.ForEach(e=>e.End()); + } + + public void LoadEffect(string EFFECT_NAME, string EFFECT_TYPE) + { + PackedScene scene = ResourceLoader.Load("res://Gameplay/Effects/"+EFFECT_TYPE+"/"+EFFECT_NAME+".tscn"); + Effect instance = scene.Instantiate(); + + AddChild(instance); + Effect newEffect = (Effect)GetChildren().Single(c=>c==instance); + + newEffect.SetContact(this); + // TimeEffect1 newEffect = scene.Instantiate(); + // AddChild(newEffect); + // GD.Print(newEffect); + // newEffect._contact = this; + // _effects.Add(newEffect); } public void PassNumber(int NUMBER) { _number = NUMBER; } - public void PassOwner(Actor OWNER) - { - _owner = OWNER; - } - public void SetTimer(float SECONDS) + public virtual void Start() { - _action._timerSeconds = SECONDS; - _interval = true; - _clickable = false; - } - - public void SetCooldown(float SECONDS) - { - _action._cooldownSeconds = SECONDS; - _interval = false; - _clickable = true; - } - - 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() - { - + _effects.ForEach(e=>e.Start()); } } diff --git a/Gameplay/Effect.cs b/Gameplay/Effect.cs new file mode 100644 index 0000000..d31eb5c --- /dev/null +++ b/Gameplay/Effect.cs @@ -0,0 +1,27 @@ +using Godot; +using System; + +public partial class Effect : Node +{ + public Contact _contact; + public virtual void Fire() + { + + } + + public virtual void End() + { + + } + + public virtual void SetContact(Contact CONTACT) + { + _contact = CONTACT; + GD.Print(_contact); + } + + public virtual void Start() + { + + } +} diff --git a/Gameplay/Action.cs.uid b/Gameplay/Effect.cs.uid similarity index 100% rename from Gameplay/Action.cs.uid rename to Gameplay/Effect.cs.uid diff --git a/Gameplay/Effects/ClickEffect.cs b/Gameplay/Effects/ClickEffect.cs new file mode 100644 index 0000000..afc425f --- /dev/null +++ b/Gameplay/Effects/ClickEffect.cs @@ -0,0 +1,61 @@ +using Godot; +using System; + +public partial class ClickEffect : Effect +{ + public bool _available; + public int _calls = 0, _maxCalls = 0; + public float _timerSeconds; + public Timer _timer; + + public override void _Ready() + { + base._Ready(); + _timer = GetNode("Timer"); + } + + public override void _Process(double delta) + { + base._Process(delta); + if (_contact._button._phone._running) + { + _contact._button._progressBar.Value = Math.Round(_timer.TimeLeft / _timerSeconds * 100, 0); + } + } + + public override void Fire() + { + base.Fire(); + if (_available && (_calls <= _maxCalls || _maxCalls == 0)) + { + _calls++; + _timer.Start(_timerSeconds); + } + } + + public override void End() + { + _contact._button._progressBar.Value = 0; + } + + public virtual void SetTimer(int SECONDS) + { + _timerSeconds = SECONDS; + } + + public override void Start() + { + base.Start(); + _available = false; + _calls = 0; + _timer.Start(_timerSeconds); + } + + private void OnTimerTimeout() + { + if (_calls <= _maxCalls || _maxCalls == 0) + { + _available = true; + } + } +} diff --git a/Gameplay/Effects/ClickEffect.cs.uid b/Gameplay/Effects/ClickEffect.cs.uid new file mode 100644 index 0000000..cc1765f --- /dev/null +++ b/Gameplay/Effects/ClickEffect.cs.uid @@ -0,0 +1 @@ +uid://b2h6prsg8m1y7 diff --git a/Gameplay/Effects/ClickEffects/ClickEffect1.cs b/Gameplay/Effects/ClickEffects/ClickEffect1.cs new file mode 100644 index 0000000..e3268a8 --- /dev/null +++ b/Gameplay/Effects/ClickEffects/ClickEffect1.cs @@ -0,0 +1,20 @@ +using Godot; +using System; +using System.Collections.Generic; +using System.Linq; + +public partial class ClickEffect1 : ClickEffect +{ + public override void Fire() + { + base.Fire(); + if (_available && (_calls <= _maxCalls || _maxCalls == 0)) + { + List shields = _contact._button._phone._player._board._shields.Where(s=>!s._broken).ToList(); + int shieldNumber = Globals._rng.Next(0, shields.Count); + int damage = Globals._rng.Next(-50,-30); + shields[shieldNumber].ChangeHealth(damage); + _contact._button._phone._player._debug.Text = "Shield "+shieldNumber+" damaged for "+damage+" Damage!"; + } + } +} diff --git a/Gameplay/Effects/ClickEffects/ClickEffect1.cs.uid b/Gameplay/Effects/ClickEffects/ClickEffect1.cs.uid new file mode 100644 index 0000000..14042bc --- /dev/null +++ b/Gameplay/Effects/ClickEffects/ClickEffect1.cs.uid @@ -0,0 +1 @@ +uid://qmmft72g5uj6 diff --git a/Gameplay/Effects/ClickEffects/click_effect1.tscn b/Gameplay/Effects/ClickEffects/click_effect1.tscn new file mode 100644 index 0000000..91c7741 --- /dev/null +++ b/Gameplay/Effects/ClickEffects/click_effect1.tscn @@ -0,0 +1,9 @@ +[gd_scene format=3 uid="uid://dkio7bpdjyh6q"] + +[ext_resource type="PackedScene" uid="uid://fygidhjkgabe" path="res://Gameplay/effect.tscn" id="1_dgxlt"] +[ext_resource type="Script" uid="uid://qmmft72g5uj6" path="res://Gameplay/Effects/ClickEffects/ClickEffect1.cs" id="2_wfqii"] + +[node name="ClickEffect1" unique_id=110922950 instance=ExtResource("1_dgxlt")] +script = ExtResource("2_wfqii") + +[node name="Timer" type="Timer" parent="." index="0" unique_id=801745901] diff --git a/Gameplay/Effects/PassiveEffect.cs b/Gameplay/Effects/PassiveEffect.cs new file mode 100644 index 0000000..40ab6e6 --- /dev/null +++ b/Gameplay/Effects/PassiveEffect.cs @@ -0,0 +1,7 @@ +using Godot; +using System; + +public partial class PassiveEffect : Effect +{ + +} diff --git a/Gameplay/Effects/PassiveEffect.cs.uid b/Gameplay/Effects/PassiveEffect.cs.uid new file mode 100644 index 0000000..6ac7187 --- /dev/null +++ b/Gameplay/Effects/PassiveEffect.cs.uid @@ -0,0 +1 @@ +uid://by1gyhcy001o0 diff --git a/Gameplay/Effects/PassiveEffects/PassiveEffect1.cs b/Gameplay/Effects/PassiveEffects/PassiveEffect1.cs new file mode 100644 index 0000000..110beca --- /dev/null +++ b/Gameplay/Effects/PassiveEffects/PassiveEffect1.cs @@ -0,0 +1,7 @@ +using Godot; +using System; + +public partial class PassiveEffect1 : PassiveEffect +{ + +} diff --git a/Gameplay/Effects/PassiveEffects/PassiveEffect1.cs.uid b/Gameplay/Effects/PassiveEffects/PassiveEffect1.cs.uid new file mode 100644 index 0000000..7dd13f5 --- /dev/null +++ b/Gameplay/Effects/PassiveEffects/PassiveEffect1.cs.uid @@ -0,0 +1 @@ +uid://ctrfj2ixcrwa1 diff --git a/Gameplay/Effects/TimeEffect.cs b/Gameplay/Effects/TimeEffect.cs new file mode 100644 index 0000000..3ef44c2 --- /dev/null +++ b/Gameplay/Effects/TimeEffect.cs @@ -0,0 +1,58 @@ +using Godot; +using System; +using System.Runtime.InteropServices.Marshalling; + +public partial class TimeEffect : Effect +{ + public int _calls = 0, _maxCalls = 0; + public float _timerSeconds; + public Timer _timer; + + public override void _Ready() + { + base._Ready(); + _timer = GetNode("Timer"); + } + + public override void _Process(double delta) + { + base._Process(delta); + if (_contact._button._phone._running) + { + _contact._button._progressBar.Value = Math.Round(_timer.TimeLeft / _timerSeconds * 100, 0); + } + } + + public override void Fire() + { + base.Fire(); + if (_calls <= _maxCalls || _maxCalls == 0) + { + _calls++; + _timer.Start(_timerSeconds); + } + } + + public override void End() + { + _contact._button._progressBar.Value = 0; + } + + public virtual void SetTimer(float SECONDS) + { + _timerSeconds = SECONDS; + } + + public override void Start() + { + base.Start(); + _calls = 0; + _timer.Start(_timerSeconds); + } + + private void OnTimerTimeout() + { + Fire(); + } + +} diff --git a/Gameplay/Effects/TimeEffect.cs.uid b/Gameplay/Effects/TimeEffect.cs.uid new file mode 100644 index 0000000..a292988 --- /dev/null +++ b/Gameplay/Effects/TimeEffect.cs.uid @@ -0,0 +1 @@ +uid://jvk7ejpb7xnc diff --git a/Gameplay/Effects/TimeEffects/TimeEffect1.cs b/Gameplay/Effects/TimeEffects/TimeEffect1.cs new file mode 100644 index 0000000..a3f05da --- /dev/null +++ b/Gameplay/Effects/TimeEffects/TimeEffect1.cs @@ -0,0 +1,21 @@ +using Godot; +using System; +using System.Collections.Generic; +using System.Linq; + +public partial class TimeEffect1 : TimeEffect +{ + public override void Fire() + { + base.Fire(); + if (_calls <= _maxCalls || _maxCalls == 0) + { + List shields = _contact._button._phone._player._board._shields.Where(s=>!s._broken).ToList(); + int shieldNumber = Globals._rng.Next(0, shields.Count); + int damage = Globals._rng.Next(-12,-8); + shields[shieldNumber].ChangeHealth(damage); + _contact._button._phone._player._debug.Text = "Shield "+shieldNumber+" damaged for "+damage+" Damage!"; + } + + } +} diff --git a/Gameplay/Effects/TimeEffects/TimeEffect1.cs.uid b/Gameplay/Effects/TimeEffects/TimeEffect1.cs.uid new file mode 100644 index 0000000..d9772b1 --- /dev/null +++ b/Gameplay/Effects/TimeEffects/TimeEffect1.cs.uid @@ -0,0 +1 @@ +uid://b3ql333letuv diff --git a/Gameplay/Effects/TimeEffects/time_effect_1.tscn b/Gameplay/Effects/TimeEffects/time_effect_1.tscn new file mode 100644 index 0000000..bbdf827 --- /dev/null +++ b/Gameplay/Effects/TimeEffects/time_effect_1.tscn @@ -0,0 +1,10 @@ +[gd_scene format=3 uid="uid://dxr716rnqu2e"] + +[ext_resource type="Script" uid="uid://b3ql333letuv" path="res://Gameplay/Effects/TimeEffects/TimeEffect1.cs" id="1_l6ud1"] + +[node name="TimeEffect1" type="Node" unique_id=980963154] +script = ExtResource("1_l6ud1") + +[node name="Timer" type="Timer" parent="." unique_id=1364707554] + +[connection signal="timeout" from="Timer" to="." method="OnTimerTimeout"] diff --git a/Gameplay/Effects/click_effect.tscn b/Gameplay/Effects/click_effect.tscn new file mode 100644 index 0000000..99a1c2b --- /dev/null +++ b/Gameplay/Effects/click_effect.tscn @@ -0,0 +1,9 @@ +[gd_scene format=3 uid="uid://dg1haube60fgt"] + +[ext_resource type="PackedScene" uid="uid://fygidhjkgabe" path="res://Gameplay/effect.tscn" id="1_udl8u"] +[ext_resource type="Script" uid="uid://jvk7ejpb7xnc" path="res://Gameplay/Effects/TimeEffect.cs" id="2_uob21"] + +[node name="ClickEffect" unique_id=110922950 instance=ExtResource("1_udl8u")] +script = ExtResource("2_uob21") + +[node name="Timer" type="Timer" parent="." index="0" unique_id=801745901] diff --git a/Gameplay/Effects/passive_effect.tscn b/Gameplay/Effects/passive_effect.tscn new file mode 100644 index 0000000..13e5a77 --- /dev/null +++ b/Gameplay/Effects/passive_effect.tscn @@ -0,0 +1,7 @@ +[gd_scene format=3 uid="uid://cudff465hbjhq"] + +[ext_resource type="PackedScene" uid="uid://fygidhjkgabe" path="res://Gameplay/effect.tscn" id="1_yrp4s"] +[ext_resource type="Script" uid="uid://jvk7ejpb7xnc" path="res://Gameplay/Effects/TimeEffect.cs" id="2_87klk"] + +[node name="PassiveEffect" unique_id=110922950 instance=ExtResource("1_yrp4s")] +script = ExtResource("2_87klk") diff --git a/Gameplay/Effects/time_effect.tscn b/Gameplay/Effects/time_effect.tscn new file mode 100644 index 0000000..ac9a409 --- /dev/null +++ b/Gameplay/Effects/time_effect.tscn @@ -0,0 +1,11 @@ +[gd_scene format=3 uid="uid://bi16tiewckt3c"] + +[ext_resource type="PackedScene" uid="uid://fygidhjkgabe" path="res://Gameplay/effect.tscn" id="1_dhrm1"] +[ext_resource type="Script" uid="uid://jvk7ejpb7xnc" path="res://Gameplay/Effects/TimeEffect.cs" id="2_v3kdq"] + +[node name="TimeEffect" unique_id=110922950 instance=ExtResource("1_dhrm1")] +script = ExtResource("2_v3kdq") + +[node name="Timer" type="Timer" parent="." index="0" unique_id=801745901] + +[connection signal="timeout" from="Timer" to="." method="OnTimerTimeout"] diff --git a/Gameplay/Globals.cs b/Gameplay/Globals.cs index 6c028ab..b4c1871 100644 --- a/Gameplay/Globals.cs +++ b/Gameplay/Globals.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using Godot; public static partial class Globals @@ -8,32 +9,6 @@ public static partial class Globals public static Random _rng = new(); public static List _addressTranslation = new(){"NW","N","NE","W","C","E","SW","S","SE"}; - public static List ShiftList(List LIST, int SHIFT_BY) - { - if (LIST.Count <= SHIFT_BY || LIST.Count == 0 || SHIFT_BY ==0) - { - return LIST; - } - int getRangeStart = SHIFT_BY < 0 ? -SHIFT_BY : LIST.Count - SHIFT_BY; - int getRangeEnd = SHIFT_BY < 0 ? LIST.Count + SHIFT_BY : SHIFT_BY; - int addRangeEnd = SHIFT_BY < 0 ? -SHIFT_BY : LIST.Count - SHIFT_BY; - var result = LIST.GetRange(getRangeStart, getRangeEnd); - result.AddRange(LIST.GetRange(0, addRangeEnd)); - return result; - } - - public static void Shuffle(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); diff --git a/Gameplay/Phone.cs b/Gameplay/Phone.cs index 2a8ee69..3d0635e 100644 --- a/Gameplay/Phone.cs +++ b/Gameplay/Phone.cs @@ -1,10 +1,12 @@ using Godot; +using Godot.NativeInterop; using System; using System.Collections.Generic; using System.Linq; public partial class Phone : Sprite2D { + public bool _running = false; public PhoneButton _hoveredButton; public List _phoneButtons = new(); public Player _player; @@ -21,12 +23,7 @@ public partial class Phone : Sprite2D { _phoneButtons[i]._phone = this; } - _phoneButtons[0]._contact._action = new Example1(); - _phoneButtons[0]._contact.PassOwner(_player); - _phoneButtons[0]._contact.SetTimer(1.5f); - _phoneButtons[1]._contact._action = new Example2(); - _phoneButtons[1]._contact.PassOwner(_player); - _phoneButtons[1]._contact.SetCooldown(15f); + _phoneButtons[0]._contact.LoadEffect("time_effect_1", "TimeEffects"); } public override void _Process(double DELTA_) @@ -46,13 +43,19 @@ public partial class Phone : Sprite2D // _debug.Text = _loadedContact.GetType().ToString(); // } + public virtual void HangUp() + { + _running = false; + _phoneButtons.ForEach(b=>b._contact.End()); + + } + public void PassPlayer(Player PLAYER) { _player = PLAYER; for (int i = 0; i < _phoneButtons.Count; i++) { _phoneButtons[i]._phone = this; - _phoneButtons[i]._contact.PassOwner(PLAYER); _phoneButtons[i]._contact.PassNumber((i+1)%10); } } @@ -62,4 +65,10 @@ public partial class Phone : Sprite2D // _loadedContact = null; // _debug.Text = ""; } + + public virtual void Start() + { + _running = true; + _phoneButtons.ForEach(b=>b._contact.Start()); + } } diff --git a/Gameplay/PhoneButton.cs b/Gameplay/PhoneButton.cs index 3ace364..f5a4d6d 100644 --- a/Gameplay/PhoneButton.cs +++ b/Gameplay/PhoneButton.cs @@ -8,24 +8,21 @@ public partial class PhoneButton : TextureButton public bool _isHovered = false; public Phone _phone; public Contact _contact; + public ProgressBar _progressBar; public override void _Ready() { base._Ready(); _contact = GetNode("Contact"); + _contact._button = this; + _progressBar = GetNode("ProgressBar"); } public override void _Pressed() { base._Pressed(); - if (_contact._clickable) - { - _contact.CallAction(); - } } - - // private void OnMouseEntered() // { // _isHovered = true; diff --git a/Gameplay/Player.cs b/Gameplay/Player.cs index c72760b..7c29a8f 100644 --- a/Gameplay/Player.cs +++ b/Gameplay/Player.cs @@ -86,7 +86,7 @@ public partial class Player : Actor { for (int i = 0; i < _phone._phoneButtons.Count; i++) { - _phone._phoneButtons[i]._contact.Start(); + _phone.Start(); } } diff --git a/Gameplay/contact.tscn b/Gameplay/contact.tscn index 2da0020..6a962e7 100644 --- a/Gameplay/contact.tscn +++ b/Gameplay/contact.tscn @@ -1,16 +1,6 @@ [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" 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/action.tscn b/Gameplay/effect.tscn similarity index 61% rename from Gameplay/action.tscn rename to Gameplay/effect.tscn index 9cfa99c..4b94427 100644 --- a/Gameplay/action.tscn +++ b/Gameplay/effect.tscn @@ -1,6 +1,6 @@ [gd_scene format=3 uid="uid://fygidhjkgabe"] -[ext_resource type="Script" uid="uid://cac8dbhhcrjfe" path="res://Gameplay/Action.cs" id="1_lk435"] +[ext_resource type="Script" uid="uid://cac8dbhhcrjfe" path="res://Gameplay/Effect.cs" id="1_lk435"] -[node name="Action" type="Node" unique_id=110922950] +[node name="Effect" type="Node" unique_id=110922950] script = ExtResource("1_lk435") diff --git a/Gameplay/phone_button.tscn b/Gameplay/phone_button.tscn index 3afe9ee..fe4f5bd 100644 --- a/Gameplay/phone_button.tscn +++ b/Gameplay/phone_button.tscn @@ -1,11 +1,11 @@ -[gd_scene load_steps=4 format=3 uid="uid://dj6cr426bn30b"] +[gd_scene format=3 uid="uid://dj6cr426bn30b"] [ext_resource type="Texture2D" uid="uid://4hculjnuw6ha" path="res://Art/capsule-fill.svg" id="1_6ytam"] [ext_resource type="Script" uid="uid://cd1nniv27ef2f" path="res://Gameplay/PhoneButton.cs" id="1_d1byk"] [ext_resource type="PackedScene" uid="uid://if21pf73w7by" path="res://Gameplay/contact.tscn" id="3_3os1s"] -[node name="PhoneButton" type="TextureButton"] -modulate = Color(1, 1, 1, 0.2) +[node name="PhoneButton" type="TextureButton" unique_id=1734514874] +clip_children = 2 offset_right = 800.0 offset_bottom = 800.0 texture_normal = ExtResource("1_6ytam") @@ -15,6 +15,15 @@ texture_disabled = ExtResource("1_6ytam") texture_focused = ExtResource("1_6ytam") script = ExtResource("1_d1byk") -[node name="Contact" parent="." instance=ExtResource("3_3os1s")] +[node name="Contact" parent="." unique_id=1509012205 instance=ExtResource("3_3os1s")] position = Vector2(-228, 230) scale = Vector2(0.13, 0.13) + +[node name="ProgressBar" type="ProgressBar" parent="." unique_id=2023053611] +layout_mode = 0 +offset_top = 117.0 +offset_right = 803.0 +offset_bottom = 712.0 +step = 1.0 +fill_mode = 3 +show_percentage = false