mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-15 04:23:47 +00:00
Actor defeat script
This commit is contained in:
parent
16b7d936c9
commit
d49f5e2a45
4 changed files with 63 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=18 format=3 uid="uid://bc054js8ep2b"]
|
[gd_scene load_steps=19 format=3 uid="uid://bc054js8ep2b"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Scripts/Components/Actors/Actor.cs" id="1_ugrra"]
|
[ext_resource type="Script" path="res://Scripts/Components/Actors/Actor.cs" id="1_ugrra"]
|
||||||
[ext_resource type="SpriteFrames" uid="uid://ch2ll1on8im2p" path="res://Resources/Sprites/FairyGuard.tres" id="2_i2plx"]
|
[ext_resource type="SpriteFrames" uid="uid://ch2ll1on8im2p" path="res://Resources/Sprites/FairyGuard.tres" id="2_i2plx"]
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
[ext_resource type="Script" path="res://Scripts/Components/Actors/DamageReceiverActorModule.cs" id="12_fu5g7"]
|
[ext_resource type="Script" path="res://Scripts/Components/Actors/DamageReceiverActorModule.cs" id="12_fu5g7"]
|
||||||
[ext_resource type="Script" path="res://Scripts/Components/Actors/DeathAnimationHandler.cs" id="13_e2vvk"]
|
[ext_resource type="Script" path="res://Scripts/Components/Actors/DeathAnimationHandler.cs" id="13_e2vvk"]
|
||||||
[ext_resource type="Resource" uid="uid://dk2rbf88a5irh" path="res://Resources/Bullets/Explosion_Harmless.tres" id="14_881we"]
|
[ext_resource type="Resource" uid="uid://dk2rbf88a5irh" path="res://Resources/Bullets/Explosion_Harmless.tres" id="14_881we"]
|
||||||
|
[ext_resource type="Script" path="res://Scripts/Components/Actors/ActorDefeatScriptHandler.cs" id="15_17yce"]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_2b36v"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_2b36v"]
|
||||||
radius = 5.0
|
radius = 5.0
|
||||||
|
|
@ -98,6 +99,9 @@ shape = SubResource("CircleShape2D_0tkae")
|
||||||
script = ExtResource("13_e2vvk")
|
script = ExtResource("13_e2vvk")
|
||||||
ExplosionData = ExtResource("14_881we")
|
ExplosionData = ExtResource("14_881we")
|
||||||
|
|
||||||
|
[node name="DefeatScriptHandler" type="Node2D" parent="."]
|
||||||
|
script = ExtResource("15_17yce")
|
||||||
|
|
||||||
[connection signal="area_entered" from="PlayerDetection" to="PlayerDetection" method="_on_area_entered"]
|
[connection signal="area_entered" from="PlayerDetection" to="PlayerDetection" method="_on_area_entered"]
|
||||||
[connection signal="area_exited" from="PlayerDetection" to="PlayerDetection" method="_on_area_exited"]
|
[connection signal="area_exited" from="PlayerDetection" to="PlayerDetection" method="_on_area_exited"]
|
||||||
[connection signal="velocity_computed" from="NavigationAgent2D" to="NavigationMovementProvider" method="_on_navigation_agent_2d_velocity_computed"]
|
[connection signal="velocity_computed" from="NavigationAgent2D" to="NavigationMovementProvider" method="_on_navigation_agent_2d_velocity_computed"]
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=24 format=4 uid="uid://5klhna6pdpss"]
|
[gd_scene load_steps=25 format=4 uid="uid://5klhna6pdpss"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Scripts/GameManager.cs" id="1_uhxhn"]
|
[ext_resource type="Script" path="res://Scripts/GameManager.cs" id="1_uhxhn"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bghghp5ep4w2j" path="res://Scenes/player.tscn" id="2_afebu"]
|
[ext_resource type="PackedScene" uid="uid://bghghp5ep4w2j" path="res://Scenes/player.tscn" id="2_afebu"]
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
[ext_resource type="TileSet" uid="uid://6k28roiljylj" path="res://Tilesets/factory_tileset.tres" id="5_bsah1"]
|
[ext_resource type="TileSet" uid="uid://6k28roiljylj" path="res://Tilesets/factory_tileset.tres" id="5_bsah1"]
|
||||||
[ext_resource type="Script" path="res://Scripts/TilemapAvoidance.cs" id="6_f3h3l"]
|
[ext_resource type="Script" path="res://Scripts/TilemapAvoidance.cs" id="6_f3h3l"]
|
||||||
[ext_resource type="Script" path="res://Scenes/CameraController.gd" id="7_4a7df"]
|
[ext_resource type="Script" path="res://Scenes/CameraController.gd" id="7_4a7df"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://b0gpbkxdfbnjh" path="res://Scenes/Actors/ForceField_Horizontal.tscn" id="8_5cbgu"]
|
||||||
[ext_resource type="Script" path="res://Scripts/InventoryManager.cs" id="8_scbgd"]
|
[ext_resource type="Script" path="res://Scripts/InventoryManager.cs" id="8_scbgd"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bc054js8ep2b" path="res://Scenes/Actors/4WayActorEnemyTest.tscn" id="8_vi7eu"]
|
[ext_resource type="PackedScene" uid="uid://bc054js8ep2b" path="res://Scenes/Actors/4WayActorEnemyTest.tscn" id="8_vi7eu"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dkwi1hu1bixoe" path="res://Scenes/HUD/HUD.tscn" id="9_xs7rn"]
|
[ext_resource type="PackedScene" uid="uid://dkwi1hu1bixoe" path="res://Scenes/HUD/HUD.tscn" id="9_xs7rn"]
|
||||||
|
|
@ -64,8 +65,12 @@ metadata/_edit_lock_ = true
|
||||||
[node name="ActorEnemyTest" parent="Tilemaps/Actors" instance=ExtResource("12_8mkvw")]
|
[node name="ActorEnemyTest" parent="Tilemaps/Actors" instance=ExtResource("12_8mkvw")]
|
||||||
position = Vector2(258, 364)
|
position = Vector2(258, 364)
|
||||||
|
|
||||||
[node name="ActorEnemyTest" parent="Tilemaps" instance=ExtResource("8_vi7eu")]
|
[node name="HorizontalForceField" parent="Tilemaps/Actors" instance=ExtResource("8_5cbgu")]
|
||||||
|
position = Vector2(15, 304)
|
||||||
|
|
||||||
|
[node name="ActorEnemyTest" parent="Tilemaps" node_paths=PackedStringArray("DefeatScript") instance=ExtResource("8_vi7eu")]
|
||||||
position = Vector2(8, 410)
|
position = Vector2(8, 410)
|
||||||
|
DefeatScript = NodePath("../Actors/HorizontalForceField")
|
||||||
|
|
||||||
[node name="CameraController" type="Camera2D" parent="."]
|
[node name="CameraController" type="Camera2D" parent="."]
|
||||||
script = ExtResource("7_4a7df")
|
script = ExtResource("7_4a7df")
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,11 @@ public partial class Actor : CharacterBody2D
|
||||||
[Export]
|
[Export]
|
||||||
public float MovementSpeed { get; private set; }
|
public float MovementSpeed { get; private set; }
|
||||||
|
|
||||||
|
[ExportCategory("Defeat Script")]
|
||||||
|
[Export] public Node2D DefeatScript { get; set; }
|
||||||
|
|
||||||
|
[Export] public ActivationType ActivationType { get; private set; } = ActivationType.Toggle;
|
||||||
|
|
||||||
public Vector2 MovementDirection { get; set; }
|
public Vector2 MovementDirection { get; set; }
|
||||||
public Vector2 FacingDirection { get; set; }
|
public Vector2 FacingDirection { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
46
Scripts/Components/Actors/ActorDefeatScriptHandler.cs
Normal file
46
Scripts/Components/Actors/ActorDefeatScriptHandler.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Cirno.Scripts.Components.Actors;
|
||||||
|
|
||||||
|
public partial class ActorDefeatScriptHandler : ActorModule
|
||||||
|
{
|
||||||
|
[Export] public Node2D DefeatScript { get; private set; }
|
||||||
|
[Export] public ActivationType ActivationType { get; private set; }
|
||||||
|
protected Actor _actor;
|
||||||
|
|
||||||
|
public override void Init(Actor actor)
|
||||||
|
{
|
||||||
|
_actor = actor;
|
||||||
|
DefeatScript = actor.DefeatScript;
|
||||||
|
ActivationType = actor.ActivationType;
|
||||||
|
_actor.OnDeath += ActorOnOnDeath;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ActorOnOnDeath()
|
||||||
|
{
|
||||||
|
ActivateDefeatScript();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(double delta)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void PhysicsUpdate(double delta)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void ActivateDefeatScript()
|
||||||
|
{
|
||||||
|
if (DefeatScript is not IActivable target)
|
||||||
|
{
|
||||||
|
GD.PrintErr($"Target {DefeatScript.Name} is not activable");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
target?.Activate();
|
||||||
|
|
||||||
|
GD.Print($"{DefeatScript.Name} activated");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue