mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
Mapping
This commit is contained in:
parent
ba2f6a97fc
commit
efd6283487
15 changed files with 177 additions and 35 deletions
|
|
@ -5,7 +5,7 @@ using Godot.Collections;
|
|||
|
||||
namespace Cirno.Scripts.Activables;
|
||||
|
||||
public partial class ScriptableBase : Node2D
|
||||
public partial class ScriptableBase : Node2D, IActivable
|
||||
{
|
||||
[Export] public Array<EventResource> Events;
|
||||
|
||||
|
|
@ -59,4 +59,9 @@ public partial class ScriptableBase : Node2D
|
|||
// StartPhase(CurrentPhase);
|
||||
// }
|
||||
}
|
||||
|
||||
public void Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
Start();
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,8 @@ public partial class Boss : Enemy, IActivable
|
|||
[Export] public string BossName { get; private set; }
|
||||
[Export] private Array<BossPhase> Phases;
|
||||
[Export] private PackedScene BossHudPrefab;
|
||||
[Export] public Vector2 BossPhaseAnimationStartingPosition = new Vector2(180, 10);
|
||||
|
||||
private int currentPhaseIndex = 0;
|
||||
|
||||
private bool _started = false;
|
||||
|
|
@ -27,9 +29,6 @@ public partial class Boss : Enemy, IActivable
|
|||
[Export]
|
||||
public Vector2 CameraOffset = Vector2.Zero;
|
||||
|
||||
// [Export]
|
||||
// private PackedScene _bossPhaseAnimationPrefab;
|
||||
|
||||
private TextureRect _animationTextureRect;
|
||||
|
||||
[Export]
|
||||
|
|
@ -74,20 +73,12 @@ public partial class Boss : Enemy, IActivable
|
|||
|
||||
_bossHud.CallDeferred("add_child", _animationTextureRect);
|
||||
|
||||
//canvas.AddChild(animationTextureRect);
|
||||
|
||||
_animationTextureRect.Position = new Vector2(180, 10);
|
||||
_animationTextureRect.Position = BossPhaseAnimationStartingPosition;
|
||||
|
||||
_animationTextureRect.Visible = false;
|
||||
|
||||
//var animation = _bossPhaseAnimationPrefab.Instantiate<BossPhaseAnimation>();
|
||||
|
||||
// _gameManager.AddChild(animation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
|
|
@ -105,6 +96,18 @@ public partial class Boss : Enemy, IActivable
|
|||
StartPhase(CurrentPhase);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Explode()
|
||||
{
|
||||
if (_bossHud is not null)
|
||||
{
|
||||
_bossHud.QueueFree();
|
||||
}
|
||||
|
||||
_gameManager.CameraTargetPlayer();
|
||||
|
||||
base.Explode();
|
||||
}
|
||||
|
||||
private void StartPhase(BossPhase phase)
|
||||
{
|
||||
|
|
@ -150,6 +153,7 @@ public partial class Boss : Enemy, IActivable
|
|||
private async Task PlayAnimation()
|
||||
{
|
||||
_animationTextureRect.Modulate = new Color(_animationTextureRect.Modulate.R, _animationTextureRect.Modulate.G, _animationTextureRect.Modulate.B, 0f);
|
||||
_animationTextureRect.Position = BossPhaseAnimationStartingPosition;
|
||||
_animationTextureRect.Visible = true;
|
||||
|
||||
var tween = GetTree().CreateTween();
|
||||
|
|
|
|||
|
|
@ -99,11 +99,7 @@ public partial class SpiralPattern : AttackPattern
|
|||
RotationOffset = angleOffset,
|
||||
Modifier = _modifier,
|
||||
TimeModifiers = ((_timeModifiers?.Where(mod => mod != null)) ?? Array.Empty<TimeModifier>()).Select(m =>
|
||||
new ModifierWrapper()
|
||||
{
|
||||
TimeModifier = m,
|
||||
Applied = false
|
||||
}).ToList()
|
||||
m.Wrap()).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,10 @@ public partial class Bullet : Area2D
|
|||
break;
|
||||
}
|
||||
|
||||
modifier.Applied = true;
|
||||
if (!modifier.TimeModifier.Continuous)
|
||||
{
|
||||
modifier.Applied = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ public partial class Enemy : CharacterBody2D
|
|||
[Export] public float AlarmReactRange = 200f;
|
||||
|
||||
[Export] public Weapon EquippedWeapon;
|
||||
[Export] public Node2D DefeatScript;
|
||||
|
||||
protected float _currentHealth = 0f;
|
||||
|
||||
|
|
@ -218,13 +219,30 @@ public partial class Enemy : CharacterBody2D
|
|||
|
||||
}
|
||||
|
||||
private void Explode()
|
||||
protected virtual void Explode()
|
||||
{
|
||||
Debug.WriteLine("Ded");
|
||||
if (DefeatScript is not null)
|
||||
{
|
||||
ActivateDefeatScript();
|
||||
}
|
||||
//CreateParticles();
|
||||
//CreateDebris();
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
public void Hit(float damage)
|
||||
{
|
||||
|
|
|
|||
9
Scripts/Resources/Modifiers/DelayedSpeedModifier.cs
Normal file
9
Scripts/Resources/Modifiers/DelayedSpeedModifier.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Resources.Modifiers;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class DelayedSpeedModifier : TimeModifier
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -8,17 +8,38 @@ public partial class TimeModifier : Resource
|
|||
[Export] public float TimeInSeconds = 1f;
|
||||
[Export] public TimeModifierType ModifierType;
|
||||
[Export] public float Value;
|
||||
[Export] public bool Continuous = false;
|
||||
|
||||
public ModifierWrapper Wrap()
|
||||
{
|
||||
return new ModifierWrapper()
|
||||
{
|
||||
TimeModifier = this,
|
||||
Applied = false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class ModifierWrapper
|
||||
{
|
||||
public TimeModifier TimeModifier { get; set; }
|
||||
public bool Applied { get; set; } = false;
|
||||
|
||||
public virtual void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void Process(double deltaTime)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public enum TimeModifierType
|
||||
{
|
||||
SpeedChange,
|
||||
RotationChange,
|
||||
FacePlayer
|
||||
FacePlayer,
|
||||
Dynamic
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue