Fixed critical oversight in timer management and implimented global timer system
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public partial class IQBasedEnemy : RigidBody2D
|
public partial class IQEnemy : RigidBody2D
|
||||||
{
|
{
|
||||||
// Misc
|
// Misc
|
||||||
float GlobalTimer;
|
float GlobalTimer;
|
||||||
@@ -45,7 +45,6 @@ public partial class IQBasedEnemy : RigidBody2D
|
|||||||
// Read and set stats
|
// Read and set stats
|
||||||
if (HasMeta("MaxHP")) MaxHP = (float)GetMeta("MaxHP");
|
if (HasMeta("MaxHP")) MaxHP = (float)GetMeta("MaxHP");
|
||||||
|
|
||||||
|
|
||||||
// Set up ground detection
|
// Set up ground detection
|
||||||
GetNode<Area2D>("GroundDetector").AreaEntered += OnGroundEntered;
|
GetNode<Area2D>("GroundDetector").AreaEntered += OnGroundEntered;
|
||||||
GetNode<Area2D>("GroundDetector").AreaExited += OnGroundExited;
|
GetNode<Area2D>("GroundDetector").AreaExited += OnGroundExited;
|
||||||
@@ -57,17 +56,21 @@ public partial class IQBasedEnemy : RigidBody2D
|
|||||||
|
|
||||||
if (IQ >= 100) MaxHP += 20;
|
if (IQ >= 100) MaxHP += 20;
|
||||||
HP = MaxHP;
|
HP = MaxHP;
|
||||||
|
if (IQ >= 100 && HasMeta("RegenerationInterval")) RegenerationInterval *= 0.9f;
|
||||||
|
if (IQ >= 100 && HasMeta("RegenerationAmmount")) RegenerationAmmount *= 1.05f; // 5% increase
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
// Incriment Global Timer
|
// Update Timer
|
||||||
GlobalTimer += (float)delta;
|
GlobalTimer = GetTree().Root.GetNode<CommonData>("CommonData").GlobalTimer;
|
||||||
|
|
||||||
|
// Show current hp for testing purposes
|
||||||
|
if (HasMeta("CurrentHP")) SetMeta("CurrentHP", HP);
|
||||||
|
|
||||||
// Regenerate Health
|
// Regenerate Health
|
||||||
if (AbilityRegenerate){
|
if (AbilityRegenerate){
|
||||||
if (GlobalTimer % RegenerationInterval == 0) Regenerate(RegenerationAmmount);
|
if (GlobalTimer % RegenerationInterval == 0){Regenerate(RegenerationAmmount);}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,72 +1,72 @@
|
|||||||
[gd_scene load_steps=22 format=3 uid="uid://eknn66u8gt26"]
|
[gd_scene load_steps=22 format=3 uid="uid://eknn66u8gt26"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cy22d14qd0f48" path="res://Assets/Scenes/DEVSCENES/IQBasedEnemy.cs" id="1_a638n"]
|
[ext_resource type="Script" uid="uid://cy22d14qd0f48" path="res://Assets/Scenes/DEVSCENES/IQEnemy.cs" id="1_p53ib"]
|
||||||
[ext_resource type="Texture2D" uid="uid://c0pno0ac25r7i" path="res://Assets/Sprites/knight.png" id="2_xbll0"]
|
[ext_resource type="Texture2D" uid="uid://c0pno0ac25r7i" path="res://Assets/Sprites/knight.png" id="2_o0b1e"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bc7hl"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bc7hl"]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_a1e3t"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_a1e3t"]
|
||||||
atlas = ExtResource("2_xbll0")
|
atlas = ExtResource("2_o0b1e")
|
||||||
region = Rect2(0, 64, 32, 32)
|
region = Rect2(0, 64, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ef81u"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_ef81u"]
|
||||||
atlas = ExtResource("2_xbll0")
|
atlas = ExtResource("2_o0b1e")
|
||||||
region = Rect2(32, 64, 32, 32)
|
region = Rect2(32, 64, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4c3ag"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_4c3ag"]
|
||||||
atlas = ExtResource("2_xbll0")
|
atlas = ExtResource("2_o0b1e")
|
||||||
region = Rect2(64, 64, 32, 32)
|
region = Rect2(64, 64, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_1uahc"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_1uahc"]
|
||||||
atlas = ExtResource("2_xbll0")
|
atlas = ExtResource("2_o0b1e")
|
||||||
region = Rect2(96, 64, 32, 32)
|
region = Rect2(96, 64, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_e5qiv"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_e5qiv"]
|
||||||
atlas = ExtResource("2_xbll0")
|
atlas = ExtResource("2_o0b1e")
|
||||||
region = Rect2(128, 64, 32, 32)
|
region = Rect2(128, 64, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3xcl8"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_3xcl8"]
|
||||||
atlas = ExtResource("2_xbll0")
|
atlas = ExtResource("2_o0b1e")
|
||||||
region = Rect2(160, 64, 32, 32)
|
region = Rect2(160, 64, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_55x3b"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_55x3b"]
|
||||||
atlas = ExtResource("2_xbll0")
|
atlas = ExtResource("2_o0b1e")
|
||||||
region = Rect2(192, 64, 32, 32)
|
region = Rect2(192, 64, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_f81eh"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_f81eh"]
|
||||||
atlas = ExtResource("2_xbll0")
|
atlas = ExtResource("2_o0b1e")
|
||||||
region = Rect2(224, 64, 32, 32)
|
region = Rect2(224, 64, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_2ehdo"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_2ehdo"]
|
||||||
atlas = ExtResource("2_xbll0")
|
atlas = ExtResource("2_o0b1e")
|
||||||
region = Rect2(0, 96, 32, 32)
|
region = Rect2(0, 96, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4wgw3"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_4wgw3"]
|
||||||
atlas = ExtResource("2_xbll0")
|
atlas = ExtResource("2_o0b1e")
|
||||||
region = Rect2(32, 96, 32, 32)
|
region = Rect2(32, 96, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7bxlo"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_7bxlo"]
|
||||||
atlas = ExtResource("2_xbll0")
|
atlas = ExtResource("2_o0b1e")
|
||||||
region = Rect2(64, 96, 32, 32)
|
region = Rect2(64, 96, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kwup2"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_kwup2"]
|
||||||
atlas = ExtResource("2_xbll0")
|
atlas = ExtResource("2_o0b1e")
|
||||||
region = Rect2(96, 96, 32, 32)
|
region = Rect2(96, 96, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_p5lub"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_p5lub"]
|
||||||
atlas = ExtResource("2_xbll0")
|
atlas = ExtResource("2_o0b1e")
|
||||||
region = Rect2(128, 96, 32, 32)
|
region = Rect2(128, 96, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_v4h3h"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_v4h3h"]
|
||||||
atlas = ExtResource("2_xbll0")
|
atlas = ExtResource("2_o0b1e")
|
||||||
region = Rect2(160, 96, 32, 32)
|
region = Rect2(160, 96, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fpk85"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_fpk85"]
|
||||||
atlas = ExtResource("2_xbll0")
|
atlas = ExtResource("2_o0b1e")
|
||||||
region = Rect2(192, 96, 32, 32)
|
region = Rect2(192, 96, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_hylxp"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_hylxp"]
|
||||||
atlas = ExtResource("2_xbll0")
|
atlas = ExtResource("2_o0b1e")
|
||||||
region = Rect2(224, 96, 32, 32)
|
region = Rect2(224, 96, 32, 32)
|
||||||
|
|
||||||
[sub_resource type="SpriteFrames" id="SpriteFrames_rqn21"]
|
[sub_resource type="SpriteFrames" id="SpriteFrames_rqn21"]
|
||||||
@@ -130,9 +130,11 @@ animations = [{
|
|||||||
[node name="IQEnemy" type="RigidBody2D"]
|
[node name="IQEnemy" type="RigidBody2D"]
|
||||||
collision_layer = 8
|
collision_layer = 8
|
||||||
collision_mask = 3
|
collision_mask = 3
|
||||||
script = ExtResource("1_a638n")
|
script = ExtResource("1_p53ib")
|
||||||
metadata/IQ = 20
|
metadata/IQ = 20
|
||||||
metadata/MaxHP = 100.0
|
metadata/MaxHP = 100.0
|
||||||
|
metadata/CurrentHP = 0.0
|
||||||
|
metadata/AbilityRegenerate = true
|
||||||
|
|
||||||
[node name="GroundDetector" type="Area2D" parent="."]
|
[node name="GroundDetector" type="Area2D" parent="."]
|
||||||
position = Vector2(1.1368684e-13, 10.999999)
|
position = Vector2(1.1368684e-13, 10.999999)
|
||||||
File diff suppressed because one or more lines are too long
@@ -6,6 +6,11 @@ public partial class CommonData : Node
|
|||||||
{
|
{
|
||||||
public bool Muted = true;
|
public bool Muted = true;
|
||||||
|
|
||||||
|
// Game Information
|
||||||
|
public const float FPS = 90.0f; // Max game fps
|
||||||
|
public float GlobalTimer = 0.0f; // Seconds elapsed since game start
|
||||||
|
int NumFramesElapsed = 0;
|
||||||
|
|
||||||
// Level information
|
// Level information
|
||||||
public string CurrentLevel;
|
public string CurrentLevel;
|
||||||
|
|
||||||
@@ -38,6 +43,11 @@ public partial class CommonData : Node
|
|||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
|
// Frame Counter
|
||||||
|
NumFramesElapsed += 1;
|
||||||
|
GlobalTimer = NumFramesElapsed / FPS;
|
||||||
|
GlobalTimer = (float)Convert.ToDouble(GlobalTimer.ToString("0.##")); // Truncates seconds elapsed to hundreds place (0.00)
|
||||||
|
|
||||||
if (Input.IsActionJustPressed("quit_game"))
|
if (Input.IsActionJustPressed("quit_game"))
|
||||||
{
|
{
|
||||||
GetTree().Quit();
|
GetTree().Quit();
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ config_version=5
|
|||||||
config/name="fracturepoint"
|
config/name="fracturepoint"
|
||||||
run/main_scene="uid://bn5opy6atakg"
|
run/main_scene="uid://bn5opy6atakg"
|
||||||
config/features=PackedStringArray("4.5", "C#", "GL Compatibility")
|
config/features=PackedStringArray("4.5", "C#", "GL Compatibility")
|
||||||
|
run/max_fps=90
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|||||||
Reference in New Issue
Block a user