mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-12 04:25:55 +00:00
Movement for nodes patterns
This commit is contained in:
parent
36df2274c0
commit
e4d7a9159f
6 changed files with 172 additions and 96 deletions
File diff suppressed because one or more lines are too long
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=166 format=4 uid="uid://bv451a8wgty4u"]
|
||||
[gd_scene load_steps=167 format=4 uid="uid://bv451a8wgty4u"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://doxmbokehw8ci" path="res://Scripts/GameManager.cs" id="1_8tmoj"]
|
||||
[ext_resource type="PackedScene" uid="uid://c4pr2707hbeph" path="res://Scenes/Actors/fsm_player.tscn" id="2_ksslq"]
|
||||
|
|
@ -54,6 +54,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://dsbk2l40er2da" path="res://Scenes/Props/Box_Blue.tscn" id="37_gtga7"]
|
||||
[ext_resource type="PackedScene" uid="uid://c8lgk4wnyi1e6" path="res://Scenes/Actors/HealthStation.tscn" id="38_kuhg5"]
|
||||
[ext_resource type="PackedScene" uid="uid://cl4r3t4c1klv7" path="res://Scenes/Interactable/Switch_Box.tscn" id="38_qnbhd"]
|
||||
[ext_resource type="Script" uid="uid://b5s5mjuk1rng5" path="res://Scripts/Resources/TimeModifier.cs" id="42_uh0gg"]
|
||||
[ext_resource type="Script" uid="uid://d0a0o50j82eo6" path="res://Scripts/Activables/ScriptableBase.cs" id="42_wigyb"]
|
||||
[ext_resource type="PackedScene" uid="uid://fxvlaidieiv7" path="res://Scenes/Interactable/ScriptableAreaTrigger.tscn" id="43_kf3qc"]
|
||||
[ext_resource type="Script" uid="uid://dkihoo85jfec5" path="res://Scripts/Resources/Events/MovePlayerEvent.cs" id="44_klwgh"]
|
||||
|
|
@ -168,7 +169,7 @@ DamageType = 0
|
|||
OverrideControllable = false
|
||||
Controllable = false
|
||||
OverrideCreationModifier = false
|
||||
TimeModifiers = []
|
||||
TimeModifiers = Array[ExtResource("42_uh0gg")]([])
|
||||
WaitForCompletion = true
|
||||
metadata/_custom_type_script = "uid://c0ndqalsc4jve"
|
||||
|
||||
|
|
@ -332,7 +333,7 @@ DamageType = 0
|
|||
OverrideControllable = false
|
||||
Controllable = false
|
||||
OverrideCreationModifier = false
|
||||
TimeModifiers = []
|
||||
TimeModifiers = Array[ExtResource("42_uh0gg")]([])
|
||||
WaitForCompletion = true
|
||||
metadata/_custom_type_script = "uid://c0ndqalsc4jve"
|
||||
|
||||
|
|
|
|||
|
|
@ -29,23 +29,26 @@ public partial class CreateEmitterPattern : AttackPattern
|
|||
public void Start()
|
||||
{
|
||||
Emitter = pattern.CreateAsChild
|
||||
? parent.CreateChild<AutonomousBulletEmitter>(pattern.Prefab, parent.GlobalPosition + pattern.SpawnOffset)
|
||||
: parent.CreateSibling<AutonomousBulletEmitter>(pattern.Prefab, parent.GlobalPosition + pattern.SpawnOffset);
|
||||
? parent.CreateChild<AutonomousBulletEmitter>(pattern.Prefab,
|
||||
parent.GlobalPosition + pattern.SpawnOffset)
|
||||
: parent.CreateSibling<AutonomousBulletEmitter>(pattern.Prefab,
|
||||
parent.GlobalPosition + pattern.SpawnOffset);
|
||||
Emitter.Script = pattern.Script;
|
||||
Emitter.EmitOnStart = true;
|
||||
Emitter.LifeTime = pattern.LifeTime;
|
||||
|
||||
|
||||
_active = true;
|
||||
Emitter.Autonomous = !pattern.WaitForCompletion;
|
||||
|
||||
|
||||
Emitter.Death += EmitterOnDeath;
|
||||
|
||||
|
||||
Emitter.Start();
|
||||
}
|
||||
|
||||
private void EmitterOnDeath()
|
||||
{
|
||||
_active = false;
|
||||
Emitter.Death -= EmitterOnDeath;
|
||||
}
|
||||
|
||||
public void UpdatePattern(double delta)
|
||||
|
|
@ -57,12 +60,11 @@ public partial class CreateEmitterPattern : AttackPattern
|
|||
Emitter.Update(delta);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool IsComplete()
|
||||
{
|
||||
if (pattern.WaitForCompletion)
|
||||
if (pattern.WaitForCompletion)
|
||||
return !_active;
|
||||
return _active;
|
||||
}
|
||||
|
|
|
|||
56
Scripts/AttackPatterns/NodeMovementPattern.cs
Normal file
56
Scripts/AttackPatterns/NodeMovementPattern.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.AttackPatterns;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class NodeMovementPattern : AttackPattern
|
||||
{
|
||||
[Export] private Vector2 relativeTargetPosition;
|
||||
[Export] private float moveDuration = 2f;
|
||||
[Export] private Tween.TransitionType transitionType = Tween.TransitionType.Linear;
|
||||
[Export] private Tween.EaseType easeType = Tween.EaseType.InOut;
|
||||
|
||||
public override IPatternMachine MakeMachine(Node2D parent)
|
||||
{
|
||||
return new NodeMovementPatternMachine(this, parent);
|
||||
}
|
||||
|
||||
public class NodeMovementPatternMachine(NodeMovementPattern pattern, Node2D parent) : IPatternMachine
|
||||
{
|
||||
public Node2D Parent => parent;
|
||||
|
||||
private Tween tween;
|
||||
private bool isComplete = false;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (Parent is not IScriptHost scriptHost)
|
||||
{
|
||||
GD.PrintErr("Parent was not a script host");
|
||||
isComplete = true;
|
||||
return;
|
||||
}
|
||||
|
||||
tween = Parent.CreateTween();
|
||||
isComplete = false;
|
||||
|
||||
Vector2 targetPosition = (scriptHost?.HomePosition ?? Parent.GlobalPosition) + pattern.relativeTargetPosition;
|
||||
|
||||
tween.TweenProperty(Parent, "global_position", targetPosition, pattern.moveDuration)
|
||||
.SetTrans(pattern.transitionType)
|
||||
.SetEase(pattern.easeType)
|
||||
.Finished += () =>
|
||||
{
|
||||
isComplete = true;
|
||||
};
|
||||
}
|
||||
|
||||
public void UpdatePattern(double delta) { }
|
||||
|
||||
public bool IsComplete()
|
||||
{
|
||||
return isComplete;
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Scripts/AttackPatterns/NodeMovementPattern.cs.uid
Normal file
1
Scripts/AttackPatterns/NodeMovementPattern.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bgwt0pml2omnf
|
||||
|
|
@ -41,7 +41,7 @@ public partial class ParallelPatternGroup : AttackPattern
|
|||
foreach (var patternMachine in _patternMachines)
|
||||
{
|
||||
//if (!CurrentPattern.WaitForCompletion || _patternMachine.IsComplete())
|
||||
if ( patternMachine.IsComplete()) continue;
|
||||
if (patternMachine.IsComplete()) continue;
|
||||
patternMachine.UpdatePattern(delta);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue