Ejemplo n.º 1
0
    override public eSkillTargetHit OnHit()
    {
        HitInfo hit_info = HitValues.Dequeue();

        SkillInfo.Action main_action = Skill.Info.Actions[0];
        if (BattleBase.Instance.IsBattleEnd == true)
        {
            return(eSkillTargetHit.Miss);
        }

        if (m_Creature.IsDead == true || main_action.check_distance == true && Character.MoveDistance > BattleConfig.Instance.HitDistance)
        {
            bool next = false;
            if (Skill.Info.TargetType == eTargetType.position_next)
            {
                int target_index = target_container.target_creatures.FindIndex(c => c == m_Creature);
                if (target_index != -1)
                {
                    for (int i = target_index + 1; i < target_container.target_creatures.Count + target_index; ++i)
                    {
                        ICreature target_creature = target_container.target_creatures[i % target_container.target_creatures.Count];
                        if (target_creature != null && target_creature.IsDead == false && (main_action.check_distance == false || target_creature.Character.MoveDistance < BattleConfig.Instance.HitDistance))
                        {
                            // 당첨
                            m_Creature = target_creature as BattleCreature;
                            next       = true;
                            break;
                        }
                    }
                }
            }
            if (next == false)
            {
                if (m_Creature.IsDead == false)
                {
                    if (target_container.main_target != null)
                    {
                        Battle.Instance.PlayParticle(target_container.main_target, Battle.Instance.m_Miss);
                        TextManager.Instance.PushMessagePosition(target_container.main_target, Skill.Creature, Localization.Get("AttackFail"), eBuffColorType.Immune, eTextPushType.Normal, -4f);
                    }
                    return(eSkillTargetHit.MissPosition);
                }
                return(eSkillTargetHit.Miss);
            }
        }

        if (m_Creature.IsTeam != Skill.Creature.IsTeam)
        {
            int hit_rate   = Skill.Creature.GetValue(eStatType.HitRate);
            int evade_rate = m_Creature.GetValue(eStatType.EvadeRate);
            if (MNS.Random.Instance.NextRange(1, 10000) > (hit_rate - evade_rate))
            {
                TextManager.Instance.PushMessage(m_Creature, Localization.Get("Evade"), eBuffColorType.Immune, eTextPushType.Normal);
                return(eSkillTargetHit.Evade);
            }
        }

        int  critical_power = Skill.Creature.GetValue(eStatType.CriticalPower);
        bool is_critical    = false;

        if (BattleConfig.Instance.UseCritical && Skill.IsLeaderActive == false)
        {
            is_critical = MNS.Random.Instance.NextRange(1, 10000) <= Skill.Creature.GetValue(eStatType.CriticalChance);
            if (is_critical == false)
            {
                is_critical = ((m_Creature.IsTeam != Skill.Creature.IsTeam && (m_Creature.CanAction(Skill) == false || m_Creature.IsPlayingAction) || m_Creature.IsTeam == Skill.Creature.IsTeam && !(m_Creature.CanAction() == false || m_Creature.IsPlayingAction)));
            }
        }

        var  direct_actions = Skill.Info.Actions.Where(a => a.IsDirect);
        bool is_damage_mana = direct_actions.Any(a => a.actionType == eActionType.damage_mana);

        foreach (SkillInfo.Action action in direct_actions)
        {
            int hit_value = Mathf.RoundToInt(CalculateHitValue(action) * hit_info.percent);

            eTextPushType push_type = is_critical ? eTextPushType.Critical : eTextPushType.Normal;
            if (is_critical)
            {
                hit_value = hit_value * critical_power / 10000;
            }

            switch (action.actionType)
            {
            case eActionType.damage:
            {
                if (m_Creature.InvokeImmune(eImmuneType.damage, Skill.Creature.Info.AttackType, Skill.Level) == true)
                {
                    return(eSkillTargetHit.Immune);
                }

                if (Skill.Creature != null)
                {
                    Skill.Creature.AddDeal(-hit_value);
                }

                hit_value = m_Creature.ApplyShield(Skill.Creature.Info.AttackType, hit_value);

                if (hit_value < 0)
                {
                    TextManager.Instance.PushDamage(Skill.Creature.Info.AttackType == SharedData.eAttackType.physic, m_Creature, hit_value, push_type);
                    m_Creature.SetDamage(hit_value, false);

                    m_Creature.SetWait();

                    float damage_percent = -hit_value / (float)m_Creature.Stat.MaxHP;

                    if (is_damage_mana == false)
                    {
                        m_Creature.AddMP(eMPFillType.Damage, damage_percent);
                    }

                    if (Skill.IsDefault == true)
                    {
                        Skill.Creature.AddMP(eMPFillType.Deal, damage_percent);
                    }

                    action.Fire(Skill, eActionType.damage, hit_value);
                }
                else
                {
                    return(eSkillTargetHit.Shield);
                }
            }
            break;

            case eActionType.heal:
            {
                TextManager.Instance.PushHeal(m_Creature, hit_value, push_type);
                m_Creature.SetHeal(hit_value, false);
                m_Creature.SetWait();

                if (Skill.IsDefault == true)
                {
                    float heal_percent = hit_value / (float)m_Creature.Stat.MaxHP;
                    Skill.Creature.AddMP(eMPFillType.Heal, heal_percent);
                }
            }
            break;

            case eActionType.damage_mana:
            {
                if (m_Creature.InvokeImmune(eImmuneType.damage, Skill.Creature.Info.AttackType, Skill.Level) == true)
                {
                    return(eSkillTargetHit.Immune);
                }

                TextManager.Instance.PushMana(m_Creature, hit_value, push_type);
                m_Creature.SetDamageMana(hit_value, false);
                m_Creature.SetWait();
            }
            break;

            case eActionType.heal_mana:
            {
                TextManager.Instance.PushMana(m_Creature, hit_value, push_type);
                m_Creature.SetHealMana(hit_value, false);
                m_Creature.SetWait();

                float heal_percent = hit_value / (float)m_Creature.Stat.MaxMP;
                if (Skill.IsDefault == true)
                {
                    Skill.Creature.AddMP(eMPFillType.HealMana, heal_percent);
                }
            }
            break;
            }
        }

        //Debug.LogFormat("{0} -> {1} : {2}", self.Character.name, target.Character.name, skill.Info.Name);
        return(eSkillTargetHit.Hit);
    }
Ejemplo n.º 2
0
    public bool Update()
    {
        float playback_time = m_Creature.Character.PlaybackTime;
        float past_time     = playback_time - StartTime;

        float percent = past_time / Duration;

        if (BuffContainer.Asset != null)
        {
            BuffContainer.Asset.OnUpdate(percent, AffectValuePercent);
        }

        bool is_finish = false;

        if (Action != null && Action.Update(playback_time) == false || Parent != null && Parent.IsFinish == true)
        {
            is_finish = true;
        }
        if (Action == null && Parent == null && past_time >= Duration && Duration != -1f)
        {
            is_finish = true;
        }

        if (IsFinish == true)
        {
            if (Action == null || is_finish == true)
            {
                return(false);
            }
            return(true);
        }

        if (BattleBase.Instance.IsBattleEnd == true)
        {
            return(true);
        }

        switch (ActionInfo.actionType)
        {
        case eActionType.dot_damage:
        case eActionType.dot_heal:
            if ((past_time - m_DotTime >= m_DotTick || is_finish == true))
            {
                m_DotValue = Value * (past_time - m_LastUpdateTime);
                int hit_value = (int)m_DotValue;
                m_DotValue      -= hit_value;
                m_LastUpdateTime = past_time;

                bool is_critical = false;
                if (BattleConfig.Instance.UseCritical && Skill.IsLeaderActive == false)
                {
                    is_critical = MNS.Random.Instance.NextRange(1, 10000) <= Skill.Creature.GetValue(eStatType.CriticalChance);
                    if (is_critical == false)
                    {
                        is_critical = ((m_Creature.IsTeam != Skill.Creature.IsTeam && (m_Creature.CanAction(Skill) == false || m_Creature.IsPlayingAction) || m_Creature.IsTeam == Skill.Creature.IsTeam && !(m_Creature.CanAction() == false || m_Creature.IsPlayingAction)));
                    }
                }

                int critical_power = Skill.Creature.GetValue(eStatType.CriticalPower);

                eTextPushType push_type = is_critical ? eTextPushType.CriticalDot : eTextPushType.Dot;
                if (is_critical)
                {
                    hit_value = hit_value * critical_power / 10000;
                }

                if (ActionInfo.actionType == eActionType.dot_damage)
                {
                    if (m_Creature.InvokeImmune(eImmuneType.dot, Skill.Creature.Info.AttackType, Skill.Level) == false)
                    {
                        if (Skill.Creature != null)
                        {
                            Skill.Creature.AddDeal(-hit_value);
                        }

                        m_Creature.SetDamage(hit_value, true);
                        TextManager.Instance.PushDamage(Skill.Creature.Info.AttackType == SharedData.eAttackType.physic, m_Creature, hit_value, push_type);

                        float damage_percent = -hit_value / (float)m_Creature.Stat.MaxHP;
                        m_Creature.AddMP(eMPFillType.Damage, damage_percent);

                        if (Skill.IsDefault == true)
                        {
                            Skill.Creature.AddMP(eMPFillType.Deal, damage_percent);
                        }

                        ActionInfo.Fire(Skill, eActionType.dot_damage, hit_value);
                    }
                }
                else
                {
                    m_Creature.SetHeal(hit_value, true);
                    TextManager.Instance.PushHeal(m_Creature, hit_value, push_type);

                    if (Skill.IsDefault == true)
                    {
                        float heal_percent = hit_value / (float)m_Creature.Stat.MaxHP;
                        Skill.Creature.AddMP(eMPFillType.Heal, heal_percent);
                    }
                }
                m_DotTime += m_DotTick;
            }

            break;

        case eActionType.dot_damage_mana:
        case eActionType.dot_heal_mana:
            if ((past_time - m_DotTime >= m_DotTick || is_finish == true))
            {
                m_DotValue = Value * (past_time - m_LastUpdateTime);
                int hit_value = (int)m_DotValue;
                m_DotValue      -= hit_value;
                m_LastUpdateTime = past_time;

                bool is_critical = false;
                if (BattleConfig.Instance.UseCritical && Skill.IsLeaderActive == false)
                {
                    is_critical = MNS.Random.Instance.NextRange(1, 10000) <= Skill.Creature.GetValue(eStatType.CriticalChance);
                    if (is_critical == false)
                    {
                        is_critical = ((m_Creature.IsTeam != Skill.Creature.IsTeam && (m_Creature.CanAction(Skill) == false || m_Creature.IsPlayingAction) || m_Creature.IsTeam == Skill.Creature.IsTeam && !(m_Creature.CanAction() == false || m_Creature.IsPlayingAction)));
                    }
                }

                int critical_power = Skill.Creature.GetValue(eStatType.CriticalPower);

                eTextPushType push_type = is_critical ? eTextPushType.CriticalDot : eTextPushType.Dot;
                if (is_critical)
                {
                    hit_value = hit_value * critical_power / 10000;
                }

                if (ActionInfo.actionType == eActionType.dot_damage_mana)
                {
                    if (m_Creature.InvokeImmune(eImmuneType.dot, Skill.Creature.Info.AttackType, Skill.Level) == false)
                    {
                        m_Creature.SetDamageMana(hit_value, true);
                        TextManager.Instance.PushMana(m_Creature, hit_value, push_type);
                    }
                }
                else
                {
                    m_Creature.SetHealMana(hit_value, true);
                    TextManager.Instance.PushMana(m_Creature, hit_value, push_type);
                }
                m_DotTime += m_DotTick;
            }

            break;
        }

        if (is_finish)
        {
            IsFinish = true;
            return(false);
        }
        return(true);
    }
Ejemplo n.º 3
0
    void UpdateMP()
    {
        bool is_dead      = m_Creature.IsDead;
        bool bFeverEffect = m_Creature.IsMPFull == true && m_Creature.CanAction();

        if (is_dead)
        {
            m_Skill1Full.gameObject.SetActive(false);
            m_Skill2Full.gameObject.SetActive(false);
            m_Auto1.gameObject.SetActive(false);
            m_Auto2.gameObject.SetActive(false);
        }
        else
        {
            if (BattleBase.Instance.IsAuto == false)
            {
                m_Auto1.gameObject.SetActive(false);
                m_Auto2.gameObject.SetActive(false);

                if (bFeverEffect)
                {
                    if (m_Creature.Skills.Count > 1 && m_Skill1Full.gameObject.activeInHierarchy == false)
                    {
                        m_SkillFever1.Play();
                    }
                    if (m_Creature.Skills.Count > 2 && m_Skill2Full.gameObject.activeInHierarchy == false)
                    {
                        m_SkillFever2.Play();
                    }
                }
                m_Skill1Full.gameObject.SetActive(bFeverEffect && m_Creature.Skills.Count > 1);
                m_Skill2Full.gameObject.SetActive(bFeverEffect && m_Creature.Skills.Count > 2);
            }
            else
            {
                short auto_index = m_Creature.AutoSkillIndex;
                switch (auto_index)
                {
                case 0:
                    if (bFeverEffect)
                    {
                        if (m_Skill1Full.gameObject.activeInHierarchy == false)
                        {
                            m_SkillFever1.Play();
                        }
                        if (m_Skill2Full.gameObject.activeInHierarchy == false)
                        {
                            m_SkillFever2.Play();
                        }
                    }
                    m_Skill1Full.gameObject.SetActive(bFeverEffect);
                    m_Skill2Full.gameObject.SetActive(bFeverEffect);
                    m_Auto1.gameObject.SetActive(true);
                    m_Auto2.gameObject.SetActive(true);
                    break;

                case 1:
                    if (m_Creature.Skills.Count < 2)
                    {
                        break;
                    }
                    if (bFeverEffect && m_Skill1Full.gameObject.activeInHierarchy == false)
                    {
                        m_SkillFever1.Play();
                    }

                    m_Skill1Full.gameObject.SetActive(bFeverEffect);
                    m_Auto1.gameObject.SetActive(true);

                    m_Skill2Full.gameObject.SetActive(false);
                    m_Auto2.gameObject.SetActive(false);
                    break;

                case 2:
                    if (m_Creature.Skills.Count < 3)
                    {
                        break;
                    }
                    if (bFeverEffect && m_Skill2Full.gameObject.activeInHierarchy == false)
                    {
                        m_SkillFever2.Play();
                    }

                    m_Auto1.gameObject.SetActive(false);
                    m_Skill1Full.gameObject.SetActive(false);

                    m_Auto2.gameObject.SetActive(true);
                    m_Skill2Full.gameObject.SetActive(false);
                    break;
                }
            }
        }
    }