Exemple #1
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);
    }