Пример #1
0
 public void Fire(bool pressed)
 {
     if (ammo_ != null)
     {
         ammo_.Fire(1f, GlobalPosition, GlobalRotation, Vector2.Up.Rotated(GlobalRotation));
         if (!ammo_.IsLaser())
         {
             GetNode("/root").GetChild(0).AddChild(ammo_ as Node2D);
             ammo_ = (IFireable)ammoScene_.Instance();
         }
     }
 }
Пример #2
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        poly_ = GetNode <Polygon2D>("Shape");
        ammo_ = (IFireable)ammoScene_.Instance();
        var rigid = (ammo_ as RigidBody2D);

        if (rigid != null)
        {
            rigid.Sleeping = true;
        }
        if (ammo_.IsLaser())
        {
            (ammo_ as RayCast2D).Enabled = true;
            // TODO: this throws error currently
            AddChild(ammo_ as Node2D);
        }
    }