Пример #1
0
        private void SpawnBullet()
        {
            var bullet = (EnemyBullet2)_bulletScene.Instance();

            bullet.Speed          = 100;
            bullet.Rotation       = _host.GetNode <Node2D>("BulletSpawn").Rotation;
            bullet.GlobalPosition = _host.Position;
            bullet.Direction      = Vector2.Right.Rotated(_host.GetNode <Position2D>("BulletSpawn/Position2D").RotationDegrees);
            _host.GetParent().AddChild(bullet);
            _host.GetNode <Node2D>("BulletSpawn").Rotate(_shots < 6 ? .5f : -.5f);
        }
Пример #2
0
 private void _OnAreaBodyEntered(KinematicBody2D body)
 {
     // if the node touching the coin area name is Player--
     // add score once, then delete the Area2D Collision2D-
     // then call checkDie() every frame from -------------
     // _PhysicsProcess(). --------------------------------
     if (body.GetParent().Name == "Player")
     {
         Main.score++;
         GetNode(GetPath() + "/area").QueueFree();
         isDying = true;
     }
 }
Пример #3
0
    public void CastSpell(KinematicBody2D player)
    {
        if (CanSpellCast())
        {
            Caster caster = new Caster(player);

            // Add the caster to the scene first.
            caster.GlobalPosition = player.GlobalPosition;
            player.GetParent().AddChild(caster);

            // Process the physicists
            foreach (Physicist physicist in physicists)
            {
                if (physicist.ShouldCreatePhysics())
                {
                    SpellPhysics physics = physicist.CreatePhysics(caster);
                    caster.AddSpellPhysics(physics);
                }
            }
            lastCaster = caster;
            GD.Print($"Generating caster with {caster.GetChildCount()} physics");
        }
    }