mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-07-09 02:21:15 +00:00
steering bullets
This commit is contained in:
parent
766b04b2ff
commit
6125565d8c
6 changed files with 89 additions and 67 deletions
|
|
@ -13,4 +13,5 @@ LifeTime = 10.0
|
|||
DestroyOnCollision = true
|
||||
Owner = 1
|
||||
DamageType = 0
|
||||
Controllable = true
|
||||
TimeModifiers = null
|
||||
|
|
|
|||
|
|
@ -461,6 +461,7 @@ LifeTime = 20.0
|
|||
DestroyOnCollision = true
|
||||
Owner = 2
|
||||
DamageType = 0
|
||||
Controllable = false
|
||||
Modifier = SubResource("Resource_ksslq")
|
||||
TimeModifiers = Array[Object]([])
|
||||
metadata/_custom_type_script = "uid://dslyrfcej3g2n"
|
||||
|
|
|
|||
|
|
@ -151,9 +151,26 @@ public partial class Bullet : Area2D
|
|||
ApplyTimeModifiers(delta);
|
||||
}
|
||||
|
||||
|
||||
if (BulletInfo.Controllabe)
|
||||
{
|
||||
ControlBullet(delta);
|
||||
}
|
||||
|
||||
this.Position += ((float)(Speed * delta) * _direction);
|
||||
}
|
||||
|
||||
private void ControlBullet(double delta)
|
||||
{
|
||||
var axis = Input.GetAxis("left", "right");
|
||||
|
||||
if (axis != 0)
|
||||
{
|
||||
float rotationSpeed = 180f; // Degrees per second
|
||||
RotateBullet(axis * rotationSpeed * (float)delta);
|
||||
}
|
||||
}
|
||||
|
||||
private void _on_visible_on_screen_notifier_2d_screen_exited()
|
||||
{
|
||||
//Debug.WriteLine("Destroy bullet out of screen");
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public partial class BulletSpawner : Node2D
|
|||
float baseAngle = Mathf.Atan2(baseDirection.Y, baseDirection.X);
|
||||
|
||||
float offsetRadians = Mathf.DegToRad(bulletInfo.RotationOffset);
|
||||
float spreadStep = Mathf.DegToRad(bulletInfo.Spread) / Mathf.Max(1,bulletInfo.BulletCount - 1); // Ensure proper spread spacing, also add 1 if 0
|
||||
float spreadStep = Mathf.DegToRad(bulletInfo.Spread) / Mathf.Max(1, bulletInfo.BulletCount - 1); // Ensure proper spread spacing, also add 1 if 0
|
||||
float angle = baseAngle + offsetRadians + (spreadStep * i);
|
||||
// float angle = baseAngle + Mathf.DegToRad(bulletInfo.RotationOffset + (bulletInfo.Spread / bulletInfo.BulletCount) * i);
|
||||
|
||||
|
|
@ -97,6 +97,7 @@ public class BulletInfo
|
|||
public float RotationOffset { get; set; }
|
||||
//public double Time { get; set; }
|
||||
public float Spread { get; set; }
|
||||
public bool Controllabe { get; set; } = false;
|
||||
public PackedScene BulletScene { get; set; }
|
||||
public PackedScene DestructionParticlesScene { get; set; }
|
||||
public IBulletModifier Modifier { get; set; }
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ public partial class BulletResource : Resource
|
|||
[Export] public bool DestroyOnCollision = true;
|
||||
[Export] public BulletOwner Owner = BulletOwner.None;
|
||||
[Export] public DamageType DamageType = DamageType.Neutral;
|
||||
[Export] public bool Controllable = false;
|
||||
|
||||
[Export]
|
||||
public BulletCreationModifier Modifier;
|
||||
|
|
@ -42,6 +43,7 @@ public partial class BulletResource : Resource
|
|||
LifeTime = LifeTime,
|
||||
DestroyOnCollision = DestroyOnCollision,
|
||||
DestructionParticlesScene = DestructionParticlesScene,
|
||||
Controllabe = Controllable,
|
||||
TimeModifiers = TimeModifiers.Select(x => x).ToList()
|
||||
// TimeModifiers = TimeModifiers?.Where(mod => mod is TimeModifier).Cast<TimeModifier>().Select(m => new ModifierWrapper()
|
||||
// {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue