Exemplo n.º 1
0
 public void GetSpell(SpellTitles title, PlayerSpell spell, SpellSelector spellSelector)
 {
     this.spellSelector = spellSelector;
     this.title         = title;
     this.spell         = spell;
     icon.sprite        = spell.icon;
 }
Exemplo n.º 2
0
 public void ChangeSpell(SpellTitles title, PlayerSpell spell)
 {
     this.title = title;
     this.spell = spell;
     SetParameters();
     //Create window with spell list
 }
Exemplo n.º 3
0
 void SpellCastCanceled(SpellTitles spellTitle)
 {
     spellState.Remove(spellTitle);
     attackNumber.Remove(spellTitle);
     spellBar.spellUI[cellIndex].ChangeState(SpellState.None);
     chargingBar.gameObject.SetActive(false);
 }
Exemplo n.º 4
0
    IEnumerator TimeToNextUseSpell(SpellTitles spellTitle, float time)
    {
        yield return(new WaitForSeconds(time));

        if (spellState.ContainsKey(spellTitle))
        {
            while (spellState.ContainsKey(spellTitle) && spellState[spellTitle] == SpellState.Active)
            {
                yield return(new WaitForEndOfFrame());
            }

            SpellEnd(spellTitle);
        }
    }
Exemplo n.º 5
0
    void SpellEnd(SpellTitles spellTitle)
    {
        curSpell.SpellEnd();

        startMovePosition.Remove(spellTitle);
        movePosition = default;
        attackNumber.Remove(spellTitle);
        attributes.isInvulnerable = false;
        movement.SpellCastEnd();
        spellBar.spellUI[cellIndex].SetCooldown(spellTitle);
        spellState.Remove(spellTitle);
        spellBar.spellUI[cellIndex].ChangeState(SpellState.None);
        chargingDamageMultiplier = 0f;
    }
Exemplo n.º 6
0
 public void SetParameters(PlayerSpell spell, SpellTitles title, int attackNumber)
 {
     this.spell        = spell;
     this.title        = title;
     this.attackNumber = attackNumber;
 }
Exemplo n.º 7
0
 void SetCastTime(SpellTitles title)
 {
     castTime[title] = spell.castTime + Time.time;
 }
Exemplo n.º 8
0
 public void SetCooldown(SpellTitles title)
 {
     curCooldown[title]      = spell.cooldown + Time.time;
     cooldownIcon.fillAmount = 1f;
 }
Exemplo n.º 9
0
 public void SetSpellToSpellUI(SpellTitles title, PlayerSpell spell)
 {
     editableSpell.ChangeSpell(title, spell);
     GameManager.UIOverlapsMouse = false;
     gameObject.SetActive(false);
 }
Exemplo n.º 10
0
    void Update()
    {
        if (!movement.isCast && spellState.ContainsKey(curSpellTitle) && spellState[curSpellTitle] == SpellState.Cast)
        {
            if (movement.isHurt)
            {
                SpellCastCanceled(curSpellTitle);
            }

            return;
        }

        if (curSpell != null && curSpell.spell.useType == SpellUseTypes.Charging && input.spellKeyUp[cellIndex] && spellState.ContainsKey(curSpellTitle) && spellState[curSpellTitle] == SpellState.Cast)
        {
            CancelInvoke("NextAnimation");
            NextAnimation();
            chargingDamageMultiplier = (Time.time - startCastTime) / curSpell.spell.castTime;
            chargingBar.gameObject.SetActive(false);
        }

        if (!movement.isEvading && !movement.isClimbing && !movement.isHanging &&
            input.lastInputs.Count > 0 && (input.lastInputs[0] == InputsEnum.FirstSpell || input.lastInputs[0] == InputsEnum.SecondSpell || input.lastInputs[0] == InputsEnum.ThirdSpell) &&
            attack.attackState != AttackState.Damage)
        {
            float _curCooldown = 0f;
            int   _cellIndex   = 0;

            switch (input.lastInputs[0])
            {
            case InputsEnum.FirstSpell:
                _cellIndex = 0;
                break;

            case InputsEnum.SecondSpell:
                _cellIndex = 1;
                break;

            case InputsEnum.ThirdSpell:
                _cellIndex = 2;
                break;
            }

            SpellTitles _spellTitle = spellBar.spellUI[_cellIndex].title;

            if ((spellState.ContainsKey(_spellTitle) && spellState[_spellTitle] != SpellState.Waiting && movement.isCast) ||
                (!spellState.ContainsKey(_spellTitle) && movement.isCast) ||
                (spellState.ContainsKey(_spellTitle) && movement.isCast && _cellIndex != cellIndex))
            {
                return;
            }

            curSpellTitle = _spellTitle;
            cellIndex     = _cellIndex;

            if (spellState.ContainsKey(curSpellTitle) && spellState[curSpellTitle] == SpellState.Waiting)
            {
                curSpell    = spellList.spells[curSpellTitle].GetComponent <Spell>();
                attackCount = curSpell.spell.attackCount;
                movement.CastSpell(curSpell.spell.attackAnimations[attackNumber[curSpellTitle]]);
                input.lastInputs.RemoveAt(0);
                NextAnimation();
            }
            else
            {
                //// Check to enough energy to use spell
                //if (attributes.EnergyPoints < cellIndex + 1)
                //{
                //    input.lastInputs.RemoveAt(0);
                //    Debug.Log("Not enough energy to use spell!");
                //    return;
                //}

                _curCooldown = spellBar.spellUI[cellIndex].curCooldown.ContainsKey(curSpellTitle) ? spellBar.spellUI[cellIndex].curCooldown[curSpellTitle] : 0f;
                input.lastInputs.RemoveAt(0);

                if (_curCooldown <= Time.time && curSpellTitle != SpellTitles.FreeSlot)
                {
                    spellState.Add(spellBar.spellUI[cellIndex].title, SpellState.Cast);
                    spellBar.spellUI[cellIndex].ChangeState(SpellState.Cast);
                    curSpell    = spellList.spells[curSpellTitle].GetComponent <Spell>();
                    attackCount = curSpell.spell.attackCount;
                    movement.CastSpell(curSpell.spell.castAnimation);
                    Invoke("NextAnimation", curSpell.spell.castTime);
                    AudioManager.PlayCastSpellAudio(curSpell.spell.audioCast);
                    attackNumber.Add(curSpellTitle, 0);
                    startCastTime = Time.time;

                    if (curSpell.spell.useType == SpellUseTypes.Charging)
                    {
                        chargingBar.SetChargingTime(curSpell.spell.castTime);
                    }
                }
                else
                {
                    Debug.Log("SPELL ON CD"); // Play CD sound
                }
            }
        }
    }