Ejemplo n.º 1
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");
        }
    }
Ejemplo n.º 2
0
 public void AddSpellPhysics(SpellPhysics spellPhysics)
 {
     AddChild(spellPhysics);
     spellPhysics.Connect("tree_exited", this, nameof(OnSpellPhysicsExit));
 }