コード例 #1
0
    void CastSpell(SpellCastCall e)
    {
        if (selectedSpell == null || !selectedSpell.Charged || !staminaController.EnoughStamina())
        {
            return;
        }
        bool resourcesSpent = false;

        switch (selectedSpell.spell.spellParams.element)
        {
        case Element.NATURE:
            CrawlController.instance.ConsumeCrawl(CastingUIController.positionToCast, selectedSpell.spell.spellParams.elementCost * 10, selectedSpell.spell.spellParams.elementCost);
            resourcesSpent = true;
            break;

        case Element.WATER:
            resourcesSpent = true;
            WaterControllerScript.instance.ConsumeWater(CastingUIController.positionToCast, selectedSpell.spell.spellParams.elementCost * 10, selectedSpell.spell.spellParams.elementCost);
            break;

        //TODO: make one for each element
        default:
            return;
        }

        if (resourcesSpent)
        {
            selectedSpell.spell.spellParams.positionToCast = CastingUIController.positionToCast;
            selectedSpell.spell.Cast();
        }

        StopCastingCall ev = new StopCastingCall();

        ev.FireEvent();
    }
コード例 #2
0
 void drainStamina(float amount)
 {
     if (stamina > 0)
     {
         stamina = Mathf.Clamp(stamina - amount, 0, maxStamina);
         updateStaminaBar();
         changed = false;
     }
     else if (isCasting)
     {
         //Twe dont have any stamina, so we cant cadt anymore, so tell everyone shows over
         isCasting = false;
         StopCastingCall e = new StopCastingCall();
         e.FireEvent();
     }
 }