예제 #1
0
 protected override void InitSkill()
 {
     base.InitSkill();
     //连续技第二个
     if (originSkill != null && comboSkill == null)
     {
         int i = 0;
         foreach (var o in other)
         {
             if (o != null)
             {
                 var buff = o.GetComponent <CharacterStatus>().Buffs.Find(b => b.GetType() == typeof(DodgeBuff));
                 if (buff != null)
                 {
                     var b = (DodgeBuff)buff;
                     if (!b.done)
                     {
                         i++;
                     }
                 }
                 else
                 {
                     i++;
                 }
             }
         }
         if (i > 0)
         {
             animator.SetInteger("Skill", animID);
         }
         else
         {
             character.GetComponent <CharacterAction>().SetSkill("ChooseDirection");
             animator.applyRootMotion = false;
             skillState = SkillState.reset;
             return;
         }
     }
     foreach (var o in other)
     {
         if (comboSkill == null)
         {
             var comboUnits = DamageSystem.ComboDetect(character, o);
             if (comboUnits.Count > 0)
             {
                 foreach (var u in comboUnits)
                 {
                     var ninjaCombo = new NinjaCombo();
                     ninjaCombo.SetLevel(u.GetComponent <CharacterStatus>().skills["NinjaCombo"]);
                     comboUnitsOriginDirection.Add(u, u.forward);
                     u.forward = o.position - u.position;
                     u.GetComponent <Animator>().SetInteger("Skill", 1);
                 }
             }
         }
     }
 }
예제 #2
0
    protected virtual void ShowUI()
    {
        if (other.Count <= 1)
        {
            expectationUI.transform.Find("Left").gameObject.SetActive(false);
            expectationUI.transform.Find("Right").gameObject.SetActive(false);
        }
        foreach (var o in other)
        {
            var             a                 = o.GetComponent <CharacterStatus>().attributes;
            var             atk               = a.Find(d => d.eName == "atk").value.ToString();
            var             def               = a.Find(d => d.eName == "def").value.ToString();
            var             dex               = a.Find(d => d.eName == "dex").value.ToString();
            var             currentHp         = a.Find(d => d.eName == "hp").value.ToString();
            var             currentMp         = a.Find(d => d.eName == "mp").value.ToString();
            FinalDamageBuff finalDamageBuff   = (FinalDamageBuff)character.GetComponent <Unit>().Buffs.Find(b => b.GetType() == typeof(FinalDamageBuff));
            var             damageExpectation = DamageSystem.ExpectDamage(character, o, damageFactor, hit, hoverRange == 0, finalDamageBuff == null ? 0 : finalDamageBuff.Factor);
            var             finalRate         = DamageSystem.HitRateSystem(character, o, skillRate).ToString();

            if (originSkill != null && originSkill is AttackSkill)
            {
                var originAttackSkill = (AttackSkill)originSkill;
                damageExpectation += DamageSystem.ExpectDamage(character, o, originAttackSkill.damageFactor, originAttackSkill.hit, hoverRange == 0, finalDamageBuff == null ? 0 : finalDamageBuff.Factor);
                finalRate          = DamageSystem.HitRateSystem(character, o, (skillRate * hit + originAttackSkill.skillRate * originAttackSkill.hit) / (hit + originAttackSkill.hit)).ToString();
            }

            string roleName     = o.GetComponent <CharacterStatus>().roleCName.Replace(" ", "");
            string roleIdentity = o.GetComponent <CharacterStatus>().IsEnemy(character.GetComponent <CharacterStatus>()) ? "" : o.GetComponent <CharacterStatus>().identity;
            string roleState    = o.GetComponent <Unit>().UnitEnd ? "结束" : "待机";
            string hp           = currentHp;
            string mp           = currentMp;
            string hpMax        = a.Find(d => d.eName == "hp").valueMax.ToString();
            string mpMax        = a.Find(d => d.eName == "mp").valueMax.ToString();
            string effectInfo   = damageExpectation.ToString();
            string rateInfo     = finalRate + "%";
            string atkInfo      = atk;
            string defInfo      = def;
            string dexInfo      = dex;

            expectationList.Add(new KeyValuePair <CharacterStatus, string[]>(o.GetComponent <CharacterStatus>(),
                                                                             new string[12] {
                roleName,
                roleIdentity,
                roleState,
                hp,
                mp,
                hpMax,
                mpMax,
                effectInfo,
                rateInfo,
                atkInfo,
                defInfo,
                dexInfo
            }));

            //相同外观角色的合击逻辑。伤害期望部分的加成在Damage System中已经完成。
            var comboUnits = DamageSystem.ComboDetect(character, o);
            if (comboUnits.Count > 0)
            {
                foreach (var u in comboUnits)
                {
                    var go    = (GameObject)Resources.Load("Prefabs/UI/Arrows");
                    var arrow = GameObject.Instantiate(go);

                    arrow.transform.position = u.GetComponent <CharacterStatus>().arrowPosition + u.position;
                    var arrows = arrow.GetComponentsInChildren <Transform>();
                    foreach (var d in arrows)
                    {
                        if (d != arrow.transform)
                        {
                            d.gameObject.SetActive(false);

                            if (d.localPosition.normalized == (o.position - u.position).normalized)
                            {
                                d.gameObject.SetActive(true);
                                d.GetComponent <Renderer>().material.color = Color.red;
                            }
                        }
                    }
                    arrowList.Add(arrow);
                }
                comboUnitsList.Add(comboUnits);
            }
        }

        RefreshExpectionData(0);
        pointer.transform.SetParent(expectationList[pointerIterator].Key.transform);
        pointer.transform.localPosition = expectationList[pointerIterator].Key.arrowPosition;
        pointer.SetActive(true);
        expectationUI.SetActive(true);
    }
예제 #3
0
    public override void Effect()
    {
        if (effectState == EffectState.origin)
        {
            originSkill.Effect();
        }
        else
        {
            //结算消耗以及动作归位。
            base.Effect();

            if (calculateDamage)
            {
                //寻找是否有最终伤害buff
                FinalDamageBuff finalDamageBuff = (FinalDamageBuff)character.GetComponent <Unit>().Buffs.Find(b => b.GetType() == typeof(FinalDamageBuff));

                foreach (var o in other)
                {
                    //<伤害序列,伤害结果>
                    Dictionary <int, int> damageDic = new Dictionary <int, int>();

                    //每Hit
                    for (int i = 0; i < hit; i++)
                    {
                        int d;
                        var doNextHit = DamageSystem.ApplyDamage(character, o, skipDodge, damageFactor, skillRate, extraCrit, extraPounce, comboSkill == null && hoverRange == 0 || comboSkill != null && comboSkill.hoverRange == 0, finalDamageBuff == null ? 0 : finalDamageBuff.Factor, out d);
                        damageDic.Add(i, d);
                        if (!doNextHit)
                        {
                            break;
                        }
                    }

                    //如果有最终伤害Buff,且Duration小于0,手动撤销影响。(此处应为倍化术)
                    if (finalDamageBuff != null && finalDamageBuff.Duration < 0)
                    {
                        finalDamageBuff.Undo(character);
                    }
                    //comboSkill是指组合技的第二个技能。这里说明是第一个技能,结合前面的条件,则这里是无连续技的技能逻辑。
                    if (comboSkill == null)
                    {
                        //寻求合击的逻辑
                        var comboUnits = DamageSystem.ComboDetect(character, o);
                        if (comboUnits.Count > 0)
                        {
                            for (int i = 0; i < comboUnits.Count; i++)
                            {
                                int             d;
                                FinalDamageBuff u_finalDamageBuff = (FinalDamageBuff)comboUnits[i].GetComponent <Unit>().Buffs.Find(b => b.GetType() == typeof(FinalDamageBuff));
                                var             ninjaCombo        = new NinjaCombo();
                                ninjaCombo.SetLevel(comboUnits[i].GetComponent <CharacterStatus>().skills["NinjaCombo"]);
                                DamageSystem.ApplyDamage(comboUnits[i], o, false, ninjaCombo.damageFactor, ninjaCombo.skillRate, ninjaCombo.extraCrit, ninjaCombo.extraPounce, ninjaCombo.hoverRange == 0, u_finalDamageBuff == null ? 0 : u_finalDamageBuff.Factor, out d);
                                damageDic.Add(damageDic.Count + i, d);
                                comboUnits[i].GetComponent <Animator>().SetInteger("Skill", 0);
                            }
                        }
                    }

                    FlyNum(damageDic, o);
                }
            }
        }
    }
예제 #4
0
    public override void Effect()
    {
        if (effectState == EffectState.origin)
        {
            originSkill.Effect();
        }
        else
        {
            base.Effect();

            FinalDamageBuff finalDamageBuff = (FinalDamageBuff)character.GetComponent <Unit>().Buffs.Find(b => b.GetType() == typeof(FinalDamageBuff));

            foreach (var o in other)
            {
                //<伤害序列,伤害结果>
                Dictionary <int, int> damageDic = new Dictionary <int, int>();

                //每Hit
                for (int i = 0; i < hit; i++)
                {
                    int d;
                    var doNextHit = DamageSystem.ApplyDamage(character, o, damageFactor, skillRate, extraCrit, extraPounce, comboSkill == null && hoverRange == 0 || comboSkill != null && comboSkill.hoverRange == 0, finalDamageBuff == null ? 0 : finalDamageBuff.Factor, out d);
                    damageDic.Add(i, d);
                    if (!doNextHit)
                    {
                        break;
                    }
                }
                foreach (var data in damageDic)
                {
                    RoundManager.GetInstance().Invoke(i => {
                        if (o)
                        {
                            if (data.Value >= 0)
                            {
                                UIManager.GetInstance().FlyNum(o.GetComponent <CharacterStatus>().arrowPosition / 2 + o.position + Vector3.down * 0.2f * i + Vector3.left * 0.2f * (Mathf.Pow(-1, i) > 0 ? 0 : 1), damageDic[i].ToString());
                            }
                        }
                    }, 0.2f * data.Key, data.Key);
                }
                if (finalDamageBuff != null && finalDamageBuff.Duration < 0)
                {
                    finalDamageBuff.Undo(character);
                }
                //comboSkill是指组合技的第二个技能。
                if (comboSkill == null)
                {
                    var comboUnits = DamageSystem.ComboDetect(character, o);
                    if (comboUnits.Count > 0)
                    {
                        foreach (var u in comboUnits)
                        {
                            int             d;
                            FinalDamageBuff u_finalDamageBuff = (FinalDamageBuff)u.GetComponent <Unit>().Buffs.Find(b => b.GetType() == typeof(FinalDamageBuff));
                            var             ninjaCombo        = new NinjaCombo();
                            ninjaCombo.SetLevel(u.GetComponent <CharacterStatus>().skills["NinjaCombo"]);
                            DamageSystem.ApplyDamage(u, o, ninjaCombo.damageFactor, ninjaCombo.skillRate, ninjaCombo.extraCrit, ninjaCombo.extraPounce, ninjaCombo.hoverRange == 0, u_finalDamageBuff == null ? 0 : u_finalDamageBuff.Factor, out d);
                            UIManager.GetInstance().FlyNum(o.GetComponent <CharacterStatus>().arrowPosition / 2 + o.position, d.ToString());
                            u.GetComponent <Animator>().SetInteger("Skill", 0);
                        }
                    }
                }
            }
        }
    }