コード例 #1
0
ファイル: EventManager.cs プロジェクト: roadf5/HSMod
    public SpellPreCastEvent OnSpellPreCast(Player player, SpellCard spell, Character target)
    {
        SpellPreCastEvent spellPreCastEvent = new SpellPreCastEvent()
        {
            Player = player,
            Spell  = spell,
            Target = target
        };

        SpellPreCastHandler.OnNext(spellPreCastEvent);

        foreach (Minion battlefieldMinion in GameManager.Instance.GetAllMinions())
        {
            battlefieldMinion.Buffs.OnSpellPreCast.OnNext(spell);
        }

        return(spellPreCastEvent);
    }
コード例 #2
0
ファイル: Player.cs プロジェクト: roadf5/HSMod
    public void PlaySpell(SpellCard spellCard, Character target)
    {
        Debugger.LogPlayer(this, "starting to cast spell " + spellCard.Name + " to " + target);

        // Firing OnSpellPreCast events
        SpellPreCastEvent spellPreCastEvent = EventManager.Instance.OnSpellPreCast(this, spellCard, target);

        if (target != spellPreCastEvent.Target)
        {
            Debugger.LogPlayer(this, " switching spell " + spellCard.Name + " target to " + target);

            // Re-setting the target because it has changed on the PreCast events
            target = spellPreCastEvent.Target;
        }

        // Checking if the Spell has not been cancelled
        if (spellPreCastEvent.Status != PreStatus.Cancelled)
        {
            Debugger.LogPlayer(this, "casting spell " + spellCard.Name + " to " + target);

            // Casting the Spell to the target
            spellCard.Cast(target);
        }
        else
        {
            Debugger.LogPlayer(this, "cancelled casting spell " + spellCard.Name);
        }

        // Firing OnSpellCasted events
        EventManager.Instance.OnSpellCasted(this, spellCard);

        // Adding the Spell to the Played Spells list
        UsedSpells.Add(spellCard);

        // Updating the Player glows
        UpdateSprites();
    }