Ejemplo n.º 1
0
    public void UseSkill(PawnInstance _target)
    {
        GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().LockCharactersPanelButtons();
        ConsumeCost();
        if (SkillName.Contains("Rapid") || SkillName.Contains("Rapide"))
        {
            skillUser.HasPlayedARapidSkill = true;
        }

        GameObject skillNameUI = GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().SkillName;

        if (Translater.CurrentLanguage != LanguageEnum.EN)
        {
            if (skillUser.GetComponent <LuckBased>() != null)
            {
                skillNameUI.transform.GetComponentInChildren <Text>().text = Translater.LuckBasedSkillName(skillUser.GetComponent <PawnInstance>().Data.PawnId, characterSkillIndex);
            }
            else
            {
                skillNameUI.transform.GetComponentInChildren <Text>().text = SkillName;
            }
        }
        else
        {
            skillNameUI.transform.GetComponentInChildren <Text>().text = skillName;
        }

        if (skillUser.GetComponent <LuckBased>() != null && skillUser.GetComponent <LuckBased>().isSkillFeedbackPending)
        {
            skillUser.GetComponent <LuckBased>().FeedbackLuckForSkillBattle();
        }
        skillNameUI.SetActive(true);

        int effectiveDamage = Damage;

        if (!isMeantToHeal && !isMeantToBuff)
        {
            foreach (BattleBoeuf boeuf in skillUser.EffectiveBoeufs)
            {
                if (boeuf.BoeufType == BoeufType.Damage)
                {
                    effectiveDamage += boeuf.EffectValue;
                }
            }
            effectiveDamage = Mathf.Max(0, effectiveDamage);
        }
        if (battleAnimation != null)
        {
            PawnInstance[] tab = new PawnInstance[1];
            tab[0] = _target.GetComponent <PawnInstance>();
            BattleHandler.CurrentSkillAnimDuration = battleAnimation.GetComponent <IBattleAnimation>().GetAnimationTime();
            battleAnimation.GetComponent <IBattleAnimation>().SetTargets(tab);
            battleAnimation.GetComponent <IBattleAnimation>().Play();
        }
        else
        {
            BattleHandler.CurrentSkillAnimDuration = 0.5f;
        }
        ApplySkillEffectOnTarget(_target, effectiveDamage);
        BattleHandler.ExpectedAnswers = 1;
        skillUser.GetComponent <AnimatedPawn>().Anim.SetTrigger("doClassicAtk");
        BattleHandler.IsWaitingForSkillEnd = true;
    }
Ejemplo n.º 2
0
    public void UseSkill()
    {
        GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().LockCharactersPanelButtons();
        ConsumeCost();
        if (SkillName.Contains("Rapid") || SkillName.Contains("Rapide"))
        {
            skillUser.HasPlayedARapidSkill = true;
        }

        GameObject skillNameUI = GameManager.Instance.GetBattleUI.GetComponent <UIBattleHandler>().SkillName;

        Debug.Log(characterSkillIndex);

        if (Translater.CurrentLanguage != LanguageEnum.EN)
        {
            if (skillUser.GetComponent <LuckBased>() != null)
            {
                skillNameUI.transform.GetComponentInChildren <Text>().text = Translater.LuckBasedSkillName(skillUser.GetComponent <PawnInstance>().Data.PawnId, characterSkillIndex);
            }
            else
            {
                skillNameUI.transform.GetComponentInChildren <Text>().text = SkillName;
            }
        }
        else
        {
            skillNameUI.transform.GetComponentInChildren <Text>().text = skillName;
        }

        if (skillUser.GetComponent <LuckBased>() != null && skillUser.GetComponent <LuckBased>().isSkillFeedbackPending)
        {
            skillUser.GetComponent <LuckBased>().FeedbackLuckForSkillBattle();
        }
        skillNameUI.SetActive(true);

        int effectiveDamage = Damage;

        if (!isMeantToHeal && !isMeantToBuff)
        {
            foreach (BattleBoeuf boeuf in skillUser.EffectiveBoeufs)
            {
                if (boeuf.BoeufType == BoeufType.Damage)
                {
                    effectiveDamage += boeuf.EffectValue;
                }
            }
            effectiveDamage = Mathf.Max(0, effectiveDamage);
        }

        if (targetType == TargetType.FoeAll)
        {
            UseSkillOnAllFoes(effectiveDamage);
            if (SkillName.Contains("Rainbow Beam") || SkillName.Contains("Rayon Arc-en-Ciel"))
            {
                int tmpTargets = BattleHandler.ExpectedAnswers;
                UseSkillOnAllAllies(effectiveDamage);
                BattleHandler.ExpectedAnswers += tmpTargets;
            }
        }
        else if (targetType == TargetType.FriendAll)
        {
            UseSkillOnAllAllies(effectiveDamage);
        }
        else if (targetType == TargetType.Self)
        {
            if (battleAnimation != null)
            {
                PawnInstance[] tab = new PawnInstance[1];
                BattleHandler.CurrentSkillAnimDuration = battleAnimation.GetComponent <IBattleAnimation>().GetAnimationTime();
                tab[0] = skillUser.GetComponent <PawnInstance>();
                battleAnimation.GetComponent <IBattleAnimation>().SetTargets(tab);
                battleAnimation.GetComponent <IBattleAnimation>().Play();
            }
            else
            {
                BattleHandler.CurrentSkillAnimDuration = 0.5f;
            }
            ApplySkillEffectOnTarget(skillUser.GetComponent <PawnInstance>(), effectiveDamage);
            BattleHandler.ExpectedAnswers = 1;
            if (SkillName == "Splash" || SkillName == "Trempette")
            {
                skillUser.GetComponent <AnimatedPawn>().Anim.SetTrigger("dance");
                BattleHandler.CurrentSkillAnimDuration = 1.2f;
            }
            else if (SkillName == "Unicorn Pride" || SkillName == "Fierté de Licorne")
            {
                skillUser.GetComponent <AnimatedPawn>().Anim.SetTrigger("dance");
                BattleHandler.CurrentSkillAnimDuration = 1.2f;
            }
        }
        else
        {
            Debug.LogError("UseSkill without parameters should not be called for single target skills other than Self.");
        }

        BattleHandler.IsWaitingForSkillEnd = true;
    }