mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-07-06 08:31:16 +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
|
DestroyOnCollision = true
|
||||||
Owner = 1
|
Owner = 1
|
||||||
DamageType = 0
|
DamageType = 0
|
||||||
|
Controllable = true
|
||||||
TimeModifiers = null
|
TimeModifiers = null
|
||||||
|
|
|
||||||
|
|
@ -461,6 +461,7 @@ LifeTime = 20.0
|
||||||
DestroyOnCollision = true
|
DestroyOnCollision = true
|
||||||
Owner = 2
|
Owner = 2
|
||||||
DamageType = 0
|
DamageType = 0
|
||||||
|
Controllable = false
|
||||||
Modifier = SubResource("Resource_ksslq")
|
Modifier = SubResource("Resource_ksslq")
|
||||||
TimeModifiers = Array[Object]([])
|
TimeModifiers = Array[Object]([])
|
||||||
metadata/_custom_type_script = "uid://dslyrfcej3g2n"
|
metadata/_custom_type_script = "uid://dslyrfcej3g2n"
|
||||||
|
|
|
||||||
|
|
@ -151,9 +151,26 @@ public partial class Bullet : Area2D
|
||||||
ApplyTimeModifiers(delta);
|
ApplyTimeModifiers(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (BulletInfo.Controllabe)
|
||||||
|
{
|
||||||
|
ControlBullet(delta);
|
||||||
|
}
|
||||||
|
|
||||||
this.Position += ((float)(Speed * delta) * _direction);
|
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()
|
private void _on_visible_on_screen_notifier_2d_screen_exited()
|
||||||
{
|
{
|
||||||
//Debug.WriteLine("Destroy bullet out of screen");
|
//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 baseAngle = Mathf.Atan2(baseDirection.Y, baseDirection.X);
|
||||||
|
|
||||||
float offsetRadians = Mathf.DegToRad(bulletInfo.RotationOffset);
|
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 + offsetRadians + (spreadStep * i);
|
||||||
// float angle = baseAngle + Mathf.DegToRad(bulletInfo.RotationOffset + (bulletInfo.Spread / bulletInfo.BulletCount) * 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 float RotationOffset { get; set; }
|
||||||
//public double Time { get; set; }
|
//public double Time { get; set; }
|
||||||
public float Spread { get; set; }
|
public float Spread { get; set; }
|
||||||
|
public bool Controllabe { get; set; } = false;
|
||||||
public PackedScene BulletScene { get; set; }
|
public PackedScene BulletScene { get; set; }
|
||||||
public PackedScene DestructionParticlesScene { get; set; }
|
public PackedScene DestructionParticlesScene { get; set; }
|
||||||
public IBulletModifier Modifier { get; set; }
|
public IBulletModifier Modifier { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ public partial class BulletResource : Resource
|
||||||
[Export] public bool DestroyOnCollision = true;
|
[Export] public bool DestroyOnCollision = true;
|
||||||
[Export] public BulletOwner Owner = BulletOwner.None;
|
[Export] public BulletOwner Owner = BulletOwner.None;
|
||||||
[Export] public DamageType DamageType = DamageType.Neutral;
|
[Export] public DamageType DamageType = DamageType.Neutral;
|
||||||
|
[Export] public bool Controllable = false;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public BulletCreationModifier Modifier;
|
public BulletCreationModifier Modifier;
|
||||||
|
|
@ -42,6 +43,7 @@ public partial class BulletResource : Resource
|
||||||
LifeTime = LifeTime,
|
LifeTime = LifeTime,
|
||||||
DestroyOnCollision = DestroyOnCollision,
|
DestroyOnCollision = DestroyOnCollision,
|
||||||
DestructionParticlesScene = DestructionParticlesScene,
|
DestructionParticlesScene = DestructionParticlesScene,
|
||||||
|
Controllabe = Controllable,
|
||||||
TimeModifiers = TimeModifiers.Select(x => x).ToList()
|
TimeModifiers = TimeModifiers.Select(x => x).ToList()
|
||||||
// TimeModifiers = TimeModifiers?.Where(mod => mod is TimeModifier).Cast<TimeModifier>().Select(m => new ModifierWrapper()
|
// TimeModifiers = TimeModifiers?.Where(mod => mod is TimeModifier).Cast<TimeModifier>().Select(m => new ModifierWrapper()
|
||||||
// {
|
// {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue