Exemple #1
0
 public void Fire()
 {
     if (_canShoot && Globals.Energy - 8 > 0)
     {
         GetNode <AudioStreamPlayer>("AudioStreamPlayer").Play();
         Random      random         = new Random();
         RigidBody2D bulletInstance = random.Next(1, 10) > Globals.CritChance ? (RigidBody2D)Bullet.Instance() : (RigidBody2D)CritBullet.Instance();
         bulletInstance.Position = GetNode <Node2D>("GunPoint").GlobalPosition;
         bulletInstance.Rotation = Rotation;
         bulletInstance.ApplyImpulse(new Vector2(0, 0), new Vector2(BulletSpeed, 0).Rotated(Rotation));
         GetTree().Root.AddChild(bulletInstance);
         ReduceEnergy();
         ShootTimer();
     }
     GetParent().GetNode <TextureProgress>("HUD/VBoxContainer/Energy").Value = Globals.Energy;
 }