mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-13 00:45:54 +00:00
Remade spawn coordinates system
This commit is contained in:
parent
3681614196
commit
d633618633
5 changed files with 85 additions and 12 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Cirno.Scripts;
|
||||
|
||||
public partial class Weapon : Node2D
|
||||
|
|
@ -31,12 +32,18 @@ public partial class Weapon : Node2D
|
|||
private Timer _cooldownTimer;
|
||||
|
||||
private Marker2D _muzzle;
|
||||
|
||||
private Node2D _bulletsContainer;
|
||||
|
||||
private GameManager _gameManager;
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
_muzzle = GetNode<Marker2D>("./Muzzle");
|
||||
_cooldownTimer = GetNode<Timer>("./ShootTimer");
|
||||
|
||||
_gameManager = GetNode<GameManager>("/root/GameScene");
|
||||
}
|
||||
|
||||
public void Reload()
|
||||
|
|
@ -74,7 +81,20 @@ public partial class Weapon : Node2D
|
|||
|
||||
// TODO: Shoot at muzzle position, need to provide a way to turn it, on a radius?
|
||||
// TODO: Create not as child but as standalone
|
||||
var bullet = this.CreateChild<Bullet>(BulletScene);
|
||||
|
||||
// if (BulletScene == null) return;
|
||||
//
|
||||
// var newInstance = BulletScene.Instantiate<Bullet>();
|
||||
// _gameManager.BulletsContainer.CallDeferred("add_child", newInstance);
|
||||
|
||||
var bullet = this.CreateChildOf<Bullet>(_gameManager.BulletsContainer, BulletScene, _muzzle.GlobalPosition);
|
||||
|
||||
if (bullet == null)
|
||||
{
|
||||
GD.PrintErr("Bullet is null, not shooting");
|
||||
return;
|
||||
};
|
||||
|
||||
bullet.SetDirection(ShootDirection);
|
||||
bullet.Speed = BulletSpeed;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue