コード例 #1
0
    /// <summary>
    /// Makes the skill go on cooldown.
    /// </summary>
    protected void GoOnCooldown()
    {
        if (_cooldown != 0)
        {
            // Sets cooldown timer to cooldown. When cooldown timer reaches 0, we can use the skill again
            _cooldownTimer = _cooldown;

            // If the current character is an ally, we also want them to reset their skill to basic attack
            if (_maRef.WhatAmI == CharacterType.Ally)
            {
                // Get the ally skill controller
                AllySkillController allyskillContRef = _maRef.GetComponent <AllySkillController>();
                if (allyskillContRef == null)
                {
                    Debug.Log("No AllySkillController was attached to " + _maRef.name);
                    return;
                }

                // De activate the special skill (if it was one)
                allyskillContRef.DeactivateSkill();
            }

            OnCooldownStart?.Invoke();
        }
    }
コード例 #2
0
    // Called before Start
    // Set references
    private new void Awake()
    {
        // Call the base's version
        base.Awake();

        // Get the ally's stats
        _allySkillCont = this.GetComponent <AllySkillController>();
    }
コード例 #3
0
    // Called before start
    // Set references to itself
    protected override void Awake()
    {
        base.Awake();

        _allySkillContRef = this.GetComponent <AllySkillController>();
        if (_allySkillContRef == null)
        {
            Debug.Log("There was no AllySkillController attached to " + this.name);
        }
    }
コード例 #4
0
    /// <summary>
    /// Swaps the skill of the current selected player
    /// Called by the skill swap button.
    /// </summary>
    public void SwapSelectedPlayerSkill()
    {
        // Get the current selected allies skill controller
        MoveAttack charMA = _mAGUIRef.RecentCharSelectedMA;

        if (charMA != null)
        {
            // Get a refrence to the currently selected ally's skill controller
            AllySkillController curAllySkillCont = charMA.GetComponent <AllySkillController>();
            // Swap the equipped skill
            curAllySkillCont.SwapSkill();
        }
    }
コード例 #5
0
    /// <summary>
    /// Display the preview menu with the ally's special skill
    /// </summary>
    /// <param name="allyStats">Reference to the ally who is parent of the skill</param>
    public void DisplayUpdatePreviewMenu(AllyStats allyStats)
    {
        // Update the skill preview
        string skillName        = " None";
        string skillDescription = "Upgrade magic to gain a skill";
        string skillDmg         = "0";
        string skillRange       = "0";
        string skillCooldown    = "0";
        Sprite skillIcon        = null;

        // Get the reference to the skill
        if (allyStats != null)
        {
            AllySkillController skillContRef = allyStats.GetComponent <AllySkillController>();
            if (skillContRef != null)
            {
                Skill activeSkill = skillContRef.SpecialSkill;
                if (activeSkill != null)
                {
                    skillName        = " " + SkillHolder.GetSkillName(activeSkill.GetSkillNum());
                    skillDescription = SkillHolder.GetSkillDescription(activeSkill.GetSkillNum());
                    skillDmg         = activeSkill.GetDamage().ToString();
                    skillRange       = activeSkill.GetRange().ToString();
                    skillCooldown    = activeSkill.GetCoolDown().ToString();
                    skillIcon        = SkillHolder.GetSkillImage(activeSkill.GetSkillNum());
                }
            }
        }
        // Set the values
        _skillNameText.text        = skillName;
        _skillDescriptionText.text = skillDescription;
        _skillDmgText.text         = skillDmg;
        _skillRangeText.text       = skillRange;
        _skillCooldownText.text    = skillCooldown;
        _skillIconImage.sprite     = skillIcon;
        if (skillIcon == null)
        {
            _skillIconImage.color = new Color(0, 0, 0, 0);
        }
        else
        {
            _skillIconImage.color = new Color(1, 1, 1, 1);
        }
        // Set their colors to default
        _skillNameText.color        = _defSkillTextCol;
        _skillDescriptionText.color = _defSkillTextCol;
        _skillDmgText.color         = _defSkillTextCol;
        _skillRangeText.color       = _defSkillTextCol;
        _skillCooldownText.color    = _defSkillTextCol;
    }
コード例 #6
0
    /// <summary>
    /// Bestoys a skill upon an ally
    /// </summary>
    /// <param name="chosenChara">The ally chosen to get the skill</param>
    /// <param name="skillIndex">The index of the skill</param>
    public Skill GiveSkill(AllySkillController chosenChara, byte skillIndex)
    {
        if (skillIndex >= _skillNames.Length)
        {
            Debug.Log("There is no skill at that index");
            return(null);
        }

        // Attaches the desired skill if the ally does not already have it
        switch (_skillNames[skillIndex])
        {
        case ("BasicAttack"):
            if (!HasSkill <BasicAttack>(chosenChara))
            {
                return(chosenChara.gameObject.AddComponent <BasicAttack>());
            }
            break;

        case ("Heal"):
            if (!HasSkill <Heal>(chosenChara))
            {
                return(chosenChara.gameObject.AddComponent <Heal>());
            }
            break;

        case ("Smite"):
            if (!HasSkill <Smite>(chosenChara))
            {
                return(chosenChara.gameObject.AddComponent <Smite>());
            }
            break;

        case ("ThreeSixtySwing"):
            if (!HasSkill <ThreeSixtySwing>(chosenChara))
            {
                return(chosenChara.gameObject.AddComponent <ThreeSixtySwing>());
            }
            break;

        default:
            Debug.Log("WARNING - BUG DETECTED - Unrecognized Skill to acquire");
            return(null);
        }
        Debug.Log(chosenChara.name + " already has " + _skillNames[skillIndex] + " attached");
        return(null);
    }
コード例 #7
0
    /// <summary>
    /// Ends the skills animaton and does damage to the 1 enemy that was hit
    /// </summary>
    override public void EndSkill()
    {
        // Validate that we have an enemy to attack
        if (_enemiesHP != null && _enemiesHP.Count > 0 && _enemiesHP[0] != null)
        {
            //Debug.Log("Ending attack on " + enemiesHP[0].name);
            // End the skills animation

            EndSkillAnimation();
            // Deal the damage and get rid of our reference to the enemyHP
            _enemiesHP[0].TakeDamage(_damage, this.GetComponent <Stats>());


            // Reduce the special skill's cooldown by 1
            // If this is an ally
            if (_maRef.WhatAmI == CharacterType.Ally)
            {
                // Get the AllySkillController
                AllySkillController allySkillContRef = _maRef.GetComponent <AllySkillController>();
                if (allySkillContRef == null)
                {
                    Debug.Log("There is no AllySkillController attached to " + this.name);
                }
                // Increment the cooldown of special skill
                if (allySkillContRef.SpecialSkill != null)
                {
                    allySkillContRef.SpecialSkill.IncrementCooldownTimer();
                }
            }
        }
        // If we have no enemy to attack, give back control to the proper authority
        else
        {
            // We should not attack anything, so set attack animation to 0
            _anime.SetInteger("AttackDirection", 0);
        }

        // Get rid of the references of the enemies to hit, so that we do not hit them again on accident
        // after the next time this enemy moves
        _enemiesHP = new List <Health>();
    }
コード例 #8
0
    /// <summary>
    /// Swaps the skill of the current selected player
    /// Called by pressing a side skill button
    /// </summary>
    public void SwapCharacterSkill(int index)
    {
        // Get the current selected allies skill controller
        MoveAttack charMA = _mAGUIContRef.RecentCharSelectedMA;
        // Get the current character's available skills
        List <Skill> availSkills = charMA.GetComponent <CharacterSkills>().GetAvailableSkills();

        // If the skill is on cooldown, don't swap to it
        if (availSkills[index].GetCooldownTimer() > 0)
        {
        }
        // If the character does not already have that skill active, swap their skills
        else if (charMA.SkillRef != availSkills[index])
        {
            // Get a refrence to the currently selected ally's skill controller
            AllySkillController curAllySkillCont = charMA.GetComponent <AllySkillController>();
            // Swap the equipped skill
            curAllySkillCont.SwapSkill();
            // Reselect the character
            _mAGUIContRef.RefreshSelectedVisualTiles();
        }
    }
コード例 #9
0
    /// <summary>
    /// Checks if the character already has the specified skill
    /// </summary>
    /// <typeparam name="T">Skill to check if the character has</typeparam>
    /// <param name="chosenChara">Character to check if they have the skill</param>
    /// <returns>True if has skill. False if thye do not.</returns>
    private bool HasSkill <T>(AllySkillController chosenChara)
    {
        Skill hasSkill = chosenChara.gameObject.GetComponent <T>() as Skill;

        return(hasSkill != null);
    }
コード例 #10
0
    /// <summary>
    /// Ends the skills animaton and pushes the enemy one space back.
    /// If the enemy being pushed cannot move that one space back, they will take damage instead.
    /// </summary>
    override public void EndSkill()
    {
        // Validate that we have an enemy to attack
        if (_enemiesHP != null && _enemiesHP.Count > 0 && _enemiesHP[0] != null && _attackNode != null)
        {
            //Debug.Log("Ending attack on " + enemiesHP[0].name);
            //sound effect
            _audManRef.PlaySound("Bump");

            // End the skills animation
            EndSkillAnimation();

            // Peak at the done "behind" the character to attack. If it is open, push the enemy
            // If it is not open, deal some damage
            Node       standingNode = _mAContRef.GetNodeByWorldPosition(this.transform.position);
            Vector2Int direction    = _attackNode.Position - standingNode.Position;
            Node       pushToNode   = _mAContRef.GetNodeAtPosition(_attackNode.Position + direction);
            if (pushToNode != null)
            {
                // If the node is empty, we push the character there
                if (pushToNode.Occupying == CharacterType.None)
                {
                    StartCoroutine(PushCharacter(_enemiesHP[0].transform, pushToNode));
                }
                // If they can't be pushed, deal damage
                else
                {
                    _enemiesHP[0].TakeDamage(_damage, this.GetComponent <Stats>());
                }
            }
            // If they cannot be pushed there, deal damage
            else
            {
                _enemiesHP[0].TakeDamage(_damage, this.GetComponent <Stats>());
            }


            // Reduce the special skill's cooldown by 1
            // If this is an ally
            if (_maRef.WhatAmI == CharacterType.Ally)
            {
                // Get the AllySkillController
                AllySkillController allySkillContRef = _maRef.GetComponent <AllySkillController>();
                if (allySkillContRef == null)
                {
                    Debug.Log("There is no AllySkillController attached to " + this.name);
                }
                // Increment the cooldown of special skill
                if (allySkillContRef.SpecialSkill != null)
                {
                    allySkillContRef.SpecialSkill.IncrementCooldownTimer();
                }
            }
        }
        // If we have no enemy to attack, give back control to the proper authority
        else
        {
            // We should not attack anything, so set attack animation to 0
            _anime.SetInteger("AttackDirection", 0);
        }

        // Get rid of the references of the enemies to hit, so that we do not hit them again on accident
        // after the next time this enemy moves
        _enemiesHP = new List <Health>();

        if (_maRef.WhatAmI == CharacterType.Ally)
        {
            GoOnCooldown();
        }
    }
コード例 #11
0
    /// <summary>
    /// Replaces text and such with what would happen if the skill was upgraded
    /// </summary>
    /// <param name="allyGrim">Grimoire of the selected</param>
    /// <param name="previewMagicStat">The amount the magic will potentially increase</param>
    public void PreviewSkillUpgrade(AllyGrimoire allyGrim, int amountIncrease)
    {
        // Default values
        string skillName        = " None";
        string skillDescription = "Upgrade magic to gain a skill";
        int    skillDmg         = 0;
        int    skillRange       = 0;
        int    skillCooldown    = 0;
        Sprite skillIcon        = null;

        // For if the values were changed at all
        bool isSkillNameBuff     = false;
        bool isSkillDmgBuff      = false;
        bool isSkillRangeBuff    = false;
        bool isSkillCooldownBuff = false;

        // Get the starting values for the skill
        AllySkillController skillContRef = allyGrim.GetComponent <AllySkillController>();

        if (skillContRef != null)
        {
            Skill activeSkill = skillContRef.SpecialSkill;
            if (activeSkill != null)
            {
                skillName        = " " + SkillHolder.GetSkillName(activeSkill.GetSkillNum());
                skillDescription = SkillHolder.GetSkillDescription(activeSkill.GetSkillNum());
                skillIcon        = SkillHolder.GetSkillImage(activeSkill.GetSkillNum());
                skillDmg         = activeSkill.GetDamage();
                skillRange       = activeSkill.GetRange();
                skillCooldown    = activeSkill.GetCoolDown();
            }


            // Iterate over the buffs
            for (int i = 1; i <= amountIncrease; ++i)
            {
                // Get the next buff
                MagicBuff nextBuff = allyGrim.PeekForward(i);

                switch (nextBuff)
                {
                // If the next buff is to acquire a skill, get that skill and set the defaults
                case (MagicBuff.SKILLACQ):
                    // We are going to temporarily give this character the skill in question to get the starting values
                    Skill gainSkill = _skillHolderRef.GiveSkill(skillContRef, allyGrim.SkillToGain);

                    skillName        = " " + SkillHolder.GetSkillName(allyGrim.SkillToGain);
                    skillDescription = SkillHolder.GetSkillDescription(allyGrim.SkillToGain);
                    skillIcon        = SkillHolder.GetSkillImage(allyGrim.SkillToGain);
                    skillDmg         = gainSkill.GetDamage();
                    skillRange       = gainSkill.GetRange();
                    skillCooldown    = gainSkill.GetCoolDown();

                    isSkillNameBuff     = true;
                    isSkillDmgBuff      = true;
                    isSkillRangeBuff    = true;
                    isSkillCooldownBuff = true;

                    // Get rid of the temporary skill
                    Destroy(gainSkill);
                    break;

                // If the next buff is just an increment, increment them
                case (MagicBuff.DMGINC):
                    ++skillDmg;
                    isSkillDmgBuff = true;
                    break;

                case (MagicBuff.RANGEINC):
                    isSkillRangeBuff = true;
                    ++skillRange;
                    break;

                case (MagicBuff.COOLLWR):
                    isSkillCooldownBuff = true;
                    --skillCooldown;
                    break;

                default:
                    Debug.Log("Unhandled MagicBuff in SkillPreviewController");
                    break;
                }
            }
            // Set the values
            _skillNameText.text        = skillName;
            _skillDescriptionText.text = skillDescription;
            _skillIconImage.sprite     = skillIcon;
            if (skillIcon == null)
            {
                _skillIconImage.color = new Color(0, 0, 0, 0);
            }
            else
            {
                _skillIconImage.color = new Color(1, 1, 1, 1);
            }
            _skillDmgText.text      = skillDmg.ToString();
            _skillRangeText.text    = skillRange.ToString();
            _skillCooldownText.text = skillCooldown.ToString();
            // Set the ones that were buffed to green
            if (isSkillNameBuff)
            {
                _skillNameText.color = CharDetailedMenuController.UpgradeTextCol;
            }
            if (isSkillDmgBuff)
            {
                _skillDmgText.color = CharDetailedMenuController.UpgradeTextCol;
            }
            if (isSkillRangeBuff)
            {
                _skillRangeText.color = CharDetailedMenuController.UpgradeTextCol;
            }
            if (isSkillCooldownBuff)
            {
                _skillCooldownText.color = CharDetailedMenuController.UpgradeTextCol;
            }
        }
    }