Exemple #1
0
    // Called before start
    // Set references
    private new void Awake()
    {
        // Call the base's version
        base.Awake();

        // These references are attached to foreign objects and will need to be set multiple times [allies only]
        SetReferences();
        // These references are attached to this game object, so they will only need to be set once
        _grimRef = this.GetComponent <AllyGrimoire>();
        if (_grimRef == null)
        {
            if (this.name != "DeadAllyStats")
            {
                Debug.Log("Could not find Grimoire attached to " + this.name);
            }
        }
        try
        {
            _basicAttackRef = this.GetComponent <BasicAttack>();
        }
        catch
        {
            Debug.LogError("No Basic attack attached to " + this.name);
        }
    }
Exemple #2
0
    /// <summary>
    /// Gives a plus 1 to magic temporarily
    /// </summary>
    public void IncrementMagic()
    {
        // For quick reference
        AllyStats allyStats = _alliesStats[_currentAllyIndex];

        // Increase the stat
        IncrementStat(ref _magicAmountIncr, ref _magicNums, allyStats.GetMagic(), allyStats.MagicBubblesFilled, _magicBubbles);

        // Refelect temp magic changes in preview text
        if ((_magicAmountIncr + allyStats.MagicBubblesFilled) % (_magicBubbles.Count + 1) == 0)
        {
            // Get the grimoire of the current ally
            AllyGrimoire allyGrim = allyStats.GetComponent <AllyGrimoire>();
            // Preview the skill increase
            _skillPrevContRef.PreviewSkillUpgrade(allyGrim, Mathf.FloorToInt((_magicAmountIncr + allyStats.MagicBubblesFilled) / (_magicBubbles.Count + 1)));
        }
    }
Exemple #3
0
    // Called before the first frame
    // Initialize some variables
    private void Start()
    {
        // Basic attack should already be on every ally, so add that skill as the first one
        _availableSkills.Add(this.GetComponent <BasicAttack>());
        // Set the default first skill to basic attack
        SetSkill(_availableSkills[0]);
        _availableSkills[0].EquipSkill();
        _specialActive = false;

        // Check if this character should start out with any skills by calling Grimoire's Magic increase
        AllyGrimoire myGrim = this.GetComponent <AllyGrimoire>();

        if (myGrim != null)
        {
            myGrim.MagicIncrease();
        }
        else
        {
            Debug.Log("There is no Grimoire attached to " + this.name);
        }
    }
    /// <summary>
    /// Waits on calling the OnCharacterFinishedAction until there are no ongoing things
    /// </summary>
    /// <returns>IEnumerator</returns>
    private IEnumerator WaitFinishAction()
    {
        int infiniteAvoid = 1000;
        int counter       = 0;

        // Check if there are any ongoing actions stopping us from finishing this enemy's turn
        while (_ongoingActions.Count != 0)
        {
            if (infiniteAvoid < ++counter)
            {
                GameObject   nullObj    = null;
                AllyGrimoire errorCause = nullObj.GetComponent <AllyGrimoire>();
            }
            yield return(null);
        }

        // Call the event for finishing the action
        if (OnCharacterFinishedAction != null)
        {
            OnCharacterFinishedAction();
        }

        yield return(null);
    }
Exemple #5
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;
            }
        }
    }