energy manager noch nicht fertig...
This commit is contained in:
32
src/Gameplay/Nodules/Components/EnergyProducer.cs
Normal file
32
src/Gameplay/Nodules/Components/EnergyProducer.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Godot;
|
||||
using Slimepire.Core;
|
||||
|
||||
namespace Slimepire.Gameplay.Nodules.Components;
|
||||
|
||||
public partial class EnergyProducer : Node
|
||||
{
|
||||
[Export]
|
||||
public float ProductionRate = 1;
|
||||
|
||||
private float _energy;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
EnergyManager.Instance.RegisterEnergyProducer(this);
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
_energy += ProductionRate * (float)delta;
|
||||
if (_energy > 1)
|
||||
{
|
||||
EnergyManager.Instance.TransferEnergy(_energy);
|
||||
_energy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
EnergyManager.Instance.RemoveEnergyProducer(this);
|
||||
}
|
||||
}
|
||||
1
src/Gameplay/Nodules/Components/EnergyProducer.cs.uid
Normal file
1
src/Gameplay/Nodules/Components/EnergyProducer.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bku1vey63ew65
|
||||
6
src/Gameplay/Nodules/Components/EnergyProducer.tscn
Normal file
6
src/Gameplay/Nodules/Components/EnergyProducer.tscn
Normal file
@@ -0,0 +1,6 @@
|
||||
[gd_scene format=3 uid="uid://t0gdf172f65v"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bku1vey63ew65" path="res://src/Gameplay/Nodules/Components/EnergyProducer.cs" id="1_4q7h4"]
|
||||
|
||||
[node name="EnergyProducer" type="Node" unique_id=1184182162]
|
||||
script = ExtResource("1_4q7h4")
|
||||
28
src/Gameplay/Nodules/Components/EnergyStorage.cs
Normal file
28
src/Gameplay/Nodules/Components/EnergyStorage.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Godot;
|
||||
using Slimepire.Core;
|
||||
|
||||
namespace Slimepire.Gameplay.Nodules.Components;
|
||||
|
||||
public partial class EnergyStorage : Node
|
||||
{
|
||||
[Export]
|
||||
public float MaxEnergy = 100;
|
||||
|
||||
public float Energy { get; private set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
EnergyManager.Instance.RegisterEnergyStorage(this);
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
EnergyManager.Instance.RemoveEnergyStorage(this);
|
||||
}
|
||||
|
||||
public float AcceptEnergy(float energy)
|
||||
{
|
||||
Energy += energy;
|
||||
return Energy;
|
||||
}
|
||||
}
|
||||
1
src/Gameplay/Nodules/Components/EnergyStorage.cs.uid
Normal file
1
src/Gameplay/Nodules/Components/EnergyStorage.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dgkeo1wsicv13
|
||||
6
src/Gameplay/Nodules/Components/EnergyStorage.tscn
Normal file
6
src/Gameplay/Nodules/Components/EnergyStorage.tscn
Normal file
@@ -0,0 +1,6 @@
|
||||
[gd_scene format=3 uid="uid://by6iw05ovnhq8"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dgkeo1wsicv13" path="res://src/Gameplay/Nodules/Components/EnergyStorage.cs" id="1_vetx7"]
|
||||
|
||||
[node name="EnergyStorage" type="Node" unique_id=1765924301]
|
||||
script = ExtResource("1_vetx7")
|
||||
@@ -1,20 +0,0 @@
|
||||
using Godot;
|
||||
|
||||
namespace Slimepire.Gameplay.Nodules;
|
||||
|
||||
[SceneTree]
|
||||
public partial class Mitochondria : Node2D
|
||||
{
|
||||
public float Energy { get; set; } = 0;
|
||||
public float MaxEnergy { get; set; } = 100;
|
||||
public float EnergyRegenRate { get; set; } = 1;
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (Energy < MaxEnergy)
|
||||
{
|
||||
Energy += EnergyRegenRate * (float)delta;
|
||||
}
|
||||
GPUParticles2D.Amount = (int)Energy;
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://h50qndjmmq4d
|
||||
File diff suppressed because one or more lines are too long
@@ -25,6 +25,7 @@ public partial class Nodule : Node2D
|
||||
{
|
||||
Gfx.SpriteFrames = NoduleResource.SpriteFrames;
|
||||
Gfx.SelfModulate = NoduleResource.Color;
|
||||
Gfx.Play();
|
||||
|
||||
ClickArea.MouseEntered += ClickAreaOnMouseEntered;
|
||||
ClickArea.MouseExited += ClickAreaOnMouseExited;
|
||||
@@ -37,11 +38,6 @@ public partial class Nodule : Node2D
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (energy < NoduleResource.MaxEnergy)
|
||||
{
|
||||
energy += NoduleResource.EnergyRegenRate * (float)delta;
|
||||
}
|
||||
|
||||
EnergyLabel.Text = energy.ToString("F2");
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
[ext_resource type="Script" uid="uid://cmpl0if164dba" path="res://src/Gameplay/Nodules/Nodule.cs" id="1_yembh"]
|
||||
[ext_resource type="Texture2D" uid="uid://cecg47efx7gw8" path="res://assets/simple_nodule.png" id="2_7qt20"]
|
||||
[ext_resource type="PackedScene" uid="uid://c11xdoiv2ch3w" path="res://src/Gameplay/Nodules/Mitochondria.tscn" id="3_x44k2"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_7qt20"]
|
||||
radius = 15.0
|
||||
@@ -61,8 +60,7 @@ unique_name_in_owner = true
|
||||
texture_filter = 1
|
||||
sprite_frames = SubResource("SpriteFrames_xyjsl")
|
||||
autoplay = "default"
|
||||
frame = 1
|
||||
frame_progress = 0.9100785
|
||||
frame_progress = 0.120879106
|
||||
|
||||
[node name="TubeConnectionArea" type="Area2D" parent="." unique_id=339547035]
|
||||
unique_name_in_owner = true
|
||||
@@ -73,10 +71,6 @@ collision_mask = 2
|
||||
shape = SubResource("CircleShape2D_x44k2")
|
||||
debug_color = Color(0.38922516, 0.6054754, 0.25354394, 0.41960785)
|
||||
|
||||
[node name="Mitochondria" parent="." unique_id=954228490 instance=ExtResource("3_x44k2")]
|
||||
process_mode = 4
|
||||
visible = false
|
||||
|
||||
[node name="EnergyLabel" type="Label" parent="." unique_id=466024399]
|
||||
unique_name_in_owner = true
|
||||
anchors_preset = 5
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
extends Node2D
|
||||
|
||||
var clicked_inside := false
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_LEFT and event.pressed == true:
|
||||
clicked_inside = true
|
||||
get_viewport().set_input_as_handled()
|
||||
@@ -1 +0,0 @@
|
||||
uid://bvl0487nflq0q
|
||||
Reference in New Issue
Block a user