reworking effects, turning them into their own scene for replicability
This commit is contained in:
61
Gameplay/Effects/ClickEffect.cs
Normal file
61
Gameplay/Effects/ClickEffect.cs
Normal file
@@ -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>("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;
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Gameplay/Effects/ClickEffect.cs.uid
Normal file
1
Gameplay/Effects/ClickEffect.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b2h6prsg8m1y7
|
||||
20
Gameplay/Effects/ClickEffects/ClickEffect1.cs
Normal file
20
Gameplay/Effects/ClickEffects/ClickEffect1.cs
Normal file
@@ -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<Shield> 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!";
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Gameplay/Effects/ClickEffects/ClickEffect1.cs.uid
Normal file
1
Gameplay/Effects/ClickEffects/ClickEffect1.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://qmmft72g5uj6
|
||||
9
Gameplay/Effects/ClickEffects/click_effect1.tscn
Normal file
9
Gameplay/Effects/ClickEffects/click_effect1.tscn
Normal file
@@ -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]
|
||||
7
Gameplay/Effects/PassiveEffect.cs
Normal file
7
Gameplay/Effects/PassiveEffect.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class PassiveEffect : Effect
|
||||
{
|
||||
|
||||
}
|
||||
1
Gameplay/Effects/PassiveEffect.cs.uid
Normal file
1
Gameplay/Effects/PassiveEffect.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://by1gyhcy001o0
|
||||
7
Gameplay/Effects/PassiveEffects/PassiveEffect1.cs
Normal file
7
Gameplay/Effects/PassiveEffects/PassiveEffect1.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class PassiveEffect1 : PassiveEffect
|
||||
{
|
||||
|
||||
}
|
||||
1
Gameplay/Effects/PassiveEffects/PassiveEffect1.cs.uid
Normal file
1
Gameplay/Effects/PassiveEffects/PassiveEffect1.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ctrfj2ixcrwa1
|
||||
58
Gameplay/Effects/TimeEffect.cs
Normal file
58
Gameplay/Effects/TimeEffect.cs
Normal file
@@ -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>("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();
|
||||
}
|
||||
|
||||
}
|
||||
1
Gameplay/Effects/TimeEffect.cs.uid
Normal file
1
Gameplay/Effects/TimeEffect.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://jvk7ejpb7xnc
|
||||
21
Gameplay/Effects/TimeEffects/TimeEffect1.cs
Normal file
21
Gameplay/Effects/TimeEffects/TimeEffect1.cs
Normal file
@@ -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<Shield> 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!";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
1
Gameplay/Effects/TimeEffects/TimeEffect1.cs.uid
Normal file
1
Gameplay/Effects/TimeEffects/TimeEffect1.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b3ql333letuv
|
||||
10
Gameplay/Effects/TimeEffects/time_effect_1.tscn
Normal file
10
Gameplay/Effects/TimeEffects/time_effect_1.tscn
Normal file
@@ -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"]
|
||||
9
Gameplay/Effects/click_effect.tscn
Normal file
9
Gameplay/Effects/click_effect.tscn
Normal file
@@ -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]
|
||||
7
Gameplay/Effects/passive_effect.tscn
Normal file
7
Gameplay/Effects/passive_effect.tscn
Normal file
@@ -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")
|
||||
11
Gameplay/Effects/time_effect.tscn
Normal file
11
Gameplay/Effects/time_effect.tscn
Normal file
@@ -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"]
|
||||
Reference in New Issue
Block a user