mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Shooting
This commit is contained in:
parent
1229613def
commit
341f76d885
17 changed files with 156 additions and 55 deletions
|
|
@ -36,17 +36,17 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
[Signal]
|
||||
public delegate void OnDestroyEventHandler();
|
||||
|
||||
private AudioStreamPlayer2D _grazeSound;
|
||||
private GpuParticles2D _grazeParticles;
|
||||
private AudioStreamPlayer3D _grazeSound;
|
||||
private GpuParticles3D _grazeParticles;
|
||||
|
||||
private CollisionShape2D _collisionShape2D;
|
||||
private CollisionShape3D _collisionShape;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_grazeSound = GetNodeOrNull<AudioStreamPlayer2D>("AudioStreamPlayer2D");
|
||||
_grazeParticles = GetNodeOrNull<GpuParticles2D>("GrazeParticles");
|
||||
_grazeSound = GetNodeOrNull<AudioStreamPlayer3D>("AudioStreamPlayer");
|
||||
_grazeParticles = GetNodeOrNull<GpuParticles3D>("GrazeParticles");
|
||||
|
||||
_collisionShape2D = GetNode<CollisionShape2D>("CollisionShape2D");
|
||||
_collisionShape = GetNode<CollisionShape3D>("CollisionShape");
|
||||
}
|
||||
|
||||
public void Initialize(BulletInfo bulletInfo, GameManager gameManager)
|
||||
|
|
@ -77,12 +77,12 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
{
|
||||
Enabled = true;
|
||||
Show();
|
||||
if (this._collisionShape2D is null)
|
||||
if (this._collisionShape is null)
|
||||
{
|
||||
_collisionShape2D = GetNode<CollisionShape2D>("CollisionShape2D");
|
||||
_collisionShape = GetNode<CollisionShape3D>("CollisionShape");
|
||||
}
|
||||
|
||||
_collisionShape2D.SetDeferred(CollisionShape2D.PropertyName.Disabled, false);
|
||||
_collisionShape.SetDeferred(CollisionShape3D.PropertyName.Disabled, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -96,12 +96,12 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
Hide();
|
||||
}
|
||||
|
||||
if (this._collisionShape2D is null)
|
||||
if (this._collisionShape is null)
|
||||
{
|
||||
_collisionShape2D = GetNode<CollisionShape2D>("CollisionShape2D");
|
||||
_collisionShape = GetNode<CollisionShape3D>("CollisionShape2D");
|
||||
}
|
||||
|
||||
_collisionShape2D.SetDeferred(CollisionShape2D.PropertyName.Disabled, true);
|
||||
_collisionShape.SetDeferred(CollisionShape2D.PropertyName.Disabled, true);
|
||||
}
|
||||
|
||||
public void Graze()
|
||||
|
|
@ -209,7 +209,9 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
ControlBullet(delta);
|
||||
}
|
||||
|
||||
//this.Position += ((float)(Speed * delta) * _direction);
|
||||
var newPos2D = ((float)(Speed * delta) * _direction);
|
||||
|
||||
this.Position += new Vector3(newPos2D.X, 0, newPos2D.Y);
|
||||
}
|
||||
|
||||
private void ControlBullet(double delta)
|
||||
|
|
@ -232,7 +234,7 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
Destroy();
|
||||
}
|
||||
|
||||
private void _on_body_entered(Node2D body)
|
||||
private void _on_body_entered(Node3D body)
|
||||
{
|
||||
if (body.IsInGroup("Solid"))
|
||||
{
|
||||
|
|
@ -247,7 +249,7 @@ public partial class Bullet3D : Area3D, IBullet
|
|||
// }
|
||||
}
|
||||
|
||||
private void _on_area_entered(Area2D area)
|
||||
private void _on_area_entered(Area3D area)
|
||||
{
|
||||
if (area.IsInGroup("Solid"))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using Godot;
|
|||
|
||||
namespace Cirno.Scripts.Weapons;
|
||||
|
||||
public partial class Weapon3D : Node
|
||||
public partial class Weapon3D : Node3D
|
||||
{
|
||||
[Export]
|
||||
public WeaponResource WeaponData { get; set; }
|
||||
|
|
@ -103,18 +103,18 @@ public partial class Weapon3D : Node
|
|||
}
|
||||
|
||||
// Check for battery if it's used
|
||||
if (UsesBattery)
|
||||
{
|
||||
if (GameManager.Instance.Player.Shield.CurrentResource >= WeaponData.AmmoPerShot)
|
||||
{
|
||||
GameManager.Instance.Player.Shield.CurrentResource -= WeaponData.AmmoPerShot;
|
||||
}
|
||||
else
|
||||
{
|
||||
EmitSignalEmpty();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if (UsesBattery)
|
||||
// {
|
||||
// if (GameManager.Instance.Player.Shield.CurrentResource >= WeaponData.AmmoPerShot)
|
||||
// {
|
||||
// GameManager.Instance.Player.Shield.CurrentResource -= WeaponData.AmmoPerShot;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// EmitSignalEmpty();
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Out of ammo?
|
||||
if (LoadedAmmo < WeaponData.AmmoPerShot)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue