mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Generic enemies
This commit is contained in:
parent
762666242e
commit
d99c773641
55 changed files with 968 additions and 204 deletions
14
Scripts/Components/BulletFlags.cs
Normal file
14
Scripts/Components/BulletFlags.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
|
||||
namespace Cirno.Scripts.Components;
|
||||
|
||||
[Flags]
|
||||
public enum BulletFlags
|
||||
{
|
||||
Freezable = 1 << 1,
|
||||
Controllable = 1 << 2,
|
||||
Bouncy = 1 << 3,
|
||||
Piercing = 1 << 4,
|
||||
Grazeable = 1 << 5,
|
||||
Rotateable = 1 << 6,
|
||||
}
|
||||
1
Scripts/Components/BulletFlags.cs.uid
Normal file
1
Scripts/Components/BulletFlags.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d6fmk6vngnxi
|
||||
45
Scripts/Components/BulletInfo.cs
Normal file
45
Scripts/Components/BulletInfo.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
using System.Collections.Generic;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components;
|
||||
|
||||
public class BulletInfo(BulletResource originalBulletResource)
|
||||
{
|
||||
public BulletResource OriginalBulletResource { get; set; } = originalBulletResource;
|
||||
public Vector2 Position { get; set; }
|
||||
public Vector2 Direction { get; set; }
|
||||
public float Speed { get; set; }
|
||||
public float LifeTime { get; set; }
|
||||
public bool DestroyOnCollision { get; set; }
|
||||
public BulletOwner Owner { get; set; }
|
||||
public DamageType DamageType { get; set; }
|
||||
public float Damage { get; set; }
|
||||
public float Knockback { get; set; }
|
||||
public int BulletCount { get; set; }
|
||||
public float RotationSpeed { get; set; }
|
||||
public float RotationOffset { get; set; }
|
||||
//public double Time { get; set; }
|
||||
public float Spread { get; set; }
|
||||
public bool RotateSprite { get; set; } = false;
|
||||
public bool Controllabe { get; set; } = false;
|
||||
public bool Freezable { get; set; } = true;
|
||||
public PackedScene BulletScene { get; set; }
|
||||
public PackedScene DestructionParticlesScene { get; set; }
|
||||
public IBulletModifier Modifier { get; set; }
|
||||
public List<TimeModifier> TimeModifiers { get; set; } = new List<TimeModifier>();
|
||||
|
||||
public bool Grazeable { get; set; }
|
||||
public float GrazeValue { get; set; }
|
||||
|
||||
public BulletFlags Attributes { get; set; }
|
||||
|
||||
#region Laser
|
||||
public bool IsLaser { get; set; }
|
||||
public float SpawnDelay { get; set; } = 0.3f; // Delay before beam appears
|
||||
public float PreFireTime { get; set; } = 0.5f; // Time before laser becomes lethal
|
||||
public float LethalTime { get; set; } = 1.5f; // Time laser remains lethal
|
||||
public Color PreFireColor { get; set; } = new Color(1, 0, 0, 0.5f); // Thin red beam
|
||||
public Color LethalColor { get; set; } = new Color(1, 0, 0, 1.0f); // Thicker beam
|
||||
#endregion
|
||||
}
|
||||
1
Scripts/Components/BulletInfo.cs.uid
Normal file
1
Scripts/Components/BulletInfo.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://r80khe0f3jj8
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Cirno.Scripts.Weapons;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
|
@ -90,42 +88,4 @@ public partial class BulletSpawner : Node2D
|
|||
// Vector2 direction = (target - position).Normalized();
|
||||
// SpawnBullet(position, direction, speed, owner, burstCount, spread: spread, bulletScene: bulletScene, modifier: modifier);
|
||||
// }
|
||||
}
|
||||
|
||||
public class BulletInfo(BulletResource originalBulletResource)
|
||||
{
|
||||
public BulletResource OriginalBulletResource { get; set; } = originalBulletResource;
|
||||
public Vector2 Position { get; set; }
|
||||
public Vector2 Direction { get; set; }
|
||||
public float Speed { get; set; }
|
||||
public float LifeTime { get; set; }
|
||||
public bool DestroyOnCollision { get; set; }
|
||||
public BulletOwner Owner { get; set; }
|
||||
public DamageType DamageType { get; set; }
|
||||
public float Damage { get; set; }
|
||||
public float Knockback { get; set; }
|
||||
public int BulletCount { get; set; }
|
||||
public float RotationSpeed { get; set; }
|
||||
public float RotationOffset { get; set; }
|
||||
//public double Time { get; set; }
|
||||
public float Spread { get; set; }
|
||||
public bool RotateSprite { get; set; } = false;
|
||||
public bool Controllabe { get; set; } = false;
|
||||
public bool Freezable { get; set; } = true;
|
||||
public PackedScene BulletScene { get; set; }
|
||||
public PackedScene DestructionParticlesScene { get; set; }
|
||||
public IBulletModifier Modifier { get; set; }
|
||||
public List<TimeModifier> TimeModifiers { get; set; } = new List<TimeModifier>();
|
||||
|
||||
public bool Grazeable { get; set; }
|
||||
public float GrazeValue { get; set; }
|
||||
|
||||
#region Laser
|
||||
public bool IsLaser { get; set; }
|
||||
public float SpawnDelay { get; set; } = 0.3f; // Delay before beam appears
|
||||
public float PreFireTime { get; set; } = 0.5f; // Time before laser becomes lethal
|
||||
public float LethalTime { get; set; } = 1.5f; // Time laser remains lethal
|
||||
public Color PreFireColor { get; set; } = new Color(1, 0, 0, 0.5f); // Thin red beam
|
||||
public Color LethalColor { get; set; } = new Color(1, 0, 0, 1.0f); // Thicker beam
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -36,6 +36,16 @@ public partial class Shooting : EnemyStateBase
|
|||
|
||||
public float CurrentHealth => DamageReceiver.HealthProvider.CurrentResource;
|
||||
|
||||
public override void Init(IStateMachine<EnemyState, CharacterBody2D> machine)
|
||||
{
|
||||
base.Init(machine);
|
||||
|
||||
if (StorageModule.Root.EnemyResource.BossScript is not null)
|
||||
{
|
||||
this.BossScript = StorageModule.Root.EnemyResource.BossScript;
|
||||
}
|
||||
}
|
||||
|
||||
public override void EnterState()
|
||||
{
|
||||
base.EnterState();
|
||||
|
|
|
|||
16
Scripts/Components/FSM/Enemy/EnemyFSMAnimatedSprite.cs
Normal file
16
Scripts/Components/FSM/Enemy/EnemyFSMAnimatedSprite.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.FSM.Enemy;
|
||||
|
||||
public partial class EnemyFSMAnimatedSprite : AnimatedSprite2D
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
var enemyFsmProxy = this.GetParentOrNull<EnemyFSMProxy>();
|
||||
|
||||
if (enemyFsmProxy?.EnemyResource?.AnimationFrames != null)
|
||||
{
|
||||
this.SpriteFrames = enemyFsmProxy.EnemyResource.AnimationFrames;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://dathhlufbe6gr
|
||||
|
|
@ -27,6 +27,12 @@ public partial class EnemyFSMProxy : CharacterBody2D, IActivable
|
|||
|
||||
[Signal] public delegate void DeathEventHandler(EnemyFSMProxy enemy);
|
||||
|
||||
public void Init(EnemyResource enemyResource)
|
||||
{
|
||||
this.EnemyResource = enemyResource;
|
||||
|
||||
}
|
||||
|
||||
public void TriggerDeath()
|
||||
{
|
||||
EmitSignalDeath(this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue