Example #1
0
        /** 接收士兵伤害 */
        public void DamageBehit(DamageVO damageVO)
        {
            if (unitData.invincible && damageVO.damageType != DamageType.HEAL)
            {
                return;
            }


            if (BeforeDamage != null)
            {
                BeforeDamage(damageVO);
            }


            if (damageVO.damageType == DamageType.HEAL)
            {
                hp += damageVO.value;
                War.textEffect.PlayHP(damageVO.value, this);
            }
            else
            {
                hp -= damageVO.value;
                unitData.beattack = true;

//				Debug.Log(string.Format("hpbug UnitCtl.DamageBehit atk={0}, def={1},  hp={2}, damageVO.value={3}", atk, def,  hp, damageVO.value));

                float consHp = damageVO.value;
                if (hp < 0)
                {
                    consHp = damageVO.value + hp;
                }

                float def2AtkHP = WarFormula.WD_RelativelyHP_Def2Atk(unitData.def, damageVO.caster.unitData.atk, consHp);

                War.textEffect.PlayHP(-consHp, this);

                War.signal.HPConst(unitData.legionId, damageVO.caster.unitData.legionId, consHp);
                War.signal.HPConst(damageVO.caster.unitData.legionId, unitData.legionId, def2AtkHP);


                War.hunManager.Play(damageVO.caster);

                if (consHp != 0)
                {
                    War.hunManager.Play(unitData.colorId, transform.position + new Vector3(Random.Range(-2, 2), 0f, Random.Range(-2, 2)));
                }

                // 添加经验--进攻
                damageVO.caster.legionData.levelData.AddExp_SoliderAtk(consHp, damageVO.caster);
                // 添加经验--防守
                damageVO.target.legionData.levelData.AddExp_SoliderDef(def2AtkHP, damageVO.caster);
            }



            if (OnDamage != null)
            {
                OnDamage(damageVO);
            }
        }
Example #2
0
        /** 被士兵攻打 */
        public void BehitForUnit(UnitData enemy)
        {
            if (!War.isGameing)
            {
                return;
            }
            if (invincible)
            {
                return;
            }

//			Debug.Log(string.Format("hpbug BehitForUnit atk={0}, def={1},  hp={2}, enemy.atk={3}, enemy.hp={3}", atk, def,  hp, enemy.atk, enemy.hp));

//			Debug.Log(string.Format("<color=lightblue>BehitForUnit enemy={0}  enemy.props={1}</color>", enemy, enemy.props.ToStrProp()));
            DamageVO damageVO = new DamageVO();

            damageVO.caster     = enemy.unit;
            damageVO.target     = this.unit;
            damageVO.value      = WarFormula.WD_Solider2Casern_Damage(def, enemy.atk, enemy.hp);
            damageVO.fromType   = DamageFromType.Solider;
            damageVO.damageType = DamageType.ATTACK;

            try
            {
                damageVO.target.DamageBehit(damageVO);
            }
            catch (Exception e)
            {
                if (Application.isEditor)
                {
                    Debug.LogError(e);
                }
                else
                {
                    Debug.LogFormat("<color=red>" + e + "</color>");
                }
            }

//			Debug.Log(string.Format("hpbug BehitForUnit atk={0}, def={1}, hitVO.damageVO.value={2}, hp={3}", atk, def, damageVO.value, hp));
            if (hp >= 0)
            {
                behit = true;
                War.signal.OnBehit(uid, enemy.legionId);
            }
            else
            {
                hp    = WarFormula.WD_RelativelyHP_Def2Atk(def, enemy.atk, -hp);
                behit = false;
                ChangeLegion(enemy.legionId);
            }
        }
Example #3
0
        /** 生成数据--士兵 */
        public void GenerationSoliders()
        {
            // 创建士兵UnitData
            foreach (KeyValuePair <int, StageLegionConfig> kvp in stageConfig.legionDict)
            {
                StageLegionConfig legionConfig = kvp.Value;
                UnitData          unitData     = new UnitData();
                unitData.unitType = UnitType.Solider;
                unitData.legionId = legionConfig.legionId;
                unitData.avatarId = 30101;

                LegionData legionData = legionDict[legionConfig.legionId];



                // 电脑士兵属性
                if (!HasEnterLegionData(unitData.legionId))
                {
                    Prop[] soliderModuleProps = WarTestData.GetSoliderProps();

                    float[] props = soliderModuleProps.PropsToInit_Float();
                    props[PropId.HpAdd]        = props[PropId.InitHp] = props[PropId.InitMaxHp];
                    legionData.soliderInitProp = props;

//					Debug.Log("Comupter soldierMonsterId= " + legionConfig.soldierMonsterId + " " +   props.ToStrProp());
                }
                // 玩家士兵属性
                else
                {
                    float[] props = GetSoliderProps(legionConfig.legionId).PropsToInit_Float();
                    props[PropId.HpAdd]        = props[PropId.InitHp] = props[PropId.InitMaxHp];
                    legionData.soliderInitProp = props;
                    unitData.level             = GetSoliderLevel(unitData.legionId);
                    unitData.avatarId          = GetSoliderAvatarId(unitData.legionId);

//					Debug.Log("soliderProps=" + props.ToStrProp());
                }

                // 把“士兵数据”保存到“势力数据"里
                legionData.soliderData = unitData;

//				Debug.Log(string.Format("<color=green>legionId={0}</color>", legionConfig.legionId));

                // 复制士兵斩将率到势力数据
                legionData.legionInitProp[PropId.InitKillHero] = WarFormula.WF_Legion_KillHero(legionData.soliderInitProp[PropId.InitKillHero]);
//				Debug.Log(string.Format("<color=green>legionId={0}, legionData.legionInitProp[PropId.InitKillHero]={1}</color>", legionConfig.legionId, legionData.legionInitProp[PropId.InitKillHero]));
            }
        }
Example #4
0
        bool Rescue()
        {
//			Debug.Log("--------------Rescue--------------");

            // 救援,随机派部队数量
            int sendCount = aiConfig.GetRescueSendCount();

//			Debug.Log("救援,随机派部队数量 sendCount=" + sendCount);
            if (sendCount <= 0)
            {
                return(false);
            }

            UnitCtl rescueUnit     = null;
            float   minRescueScore = 9999999;

            foreach (UnitCtl build in ownBuilds)
            {
                build.unitData.GenerationFromLegionUnitTotalNum();
                if (build.unitData.attackUnitNum > 0)
                {
                    float distance = 0;
                    foreach (UnitCtl buildB in ownBuilds)
                    {
                        if (build == buildB)
                        {
                            continue;
                        }
                        distance += War.scene.GetBuildDistance(build, buildB);
                    }
                    distance = ownBuilds.Count > 1 ? distance / (ownBuilds.Count - 1) : 0;;
                    build.unitData.rescueScore = build.hp + distance * distanceScoreRate_Rescue;

                    if (build.unitData.rescueScore < minRescueScore)
                    {
                        minRescueScore = build.unitData.rescueScore;
                        rescueUnit     = build;
                    }
                }
            }

            if (rescueUnit == null)
            {
                return(false);
            }

            // 救援,生成派兵的建筑
            List <UnitCtl> ownSelectBuilds = new List <UnitCtl>();
            int            index           = 0;

            foreach (UnitCtl build in ownBuilds)
            {
                if (index < sendCount && build != rescueUnit)
                {
                    ownSelectBuilds.Add(build);
                    index++;
                    if (index >= sendCount)
                    {
                        break;
                    }
                }
            }

            if (ownSelectBuilds.Count <= 0)
            {
                return(false);
            }


            bool isSend = true;

            float rescueHP = 0;

            foreach (UnitCtl ownBuild in ownSelectBuilds)
            {
                rescueHP += ownBuild.unitData.hp * aiConfig.sendArmPercent;
            }

            float enemyHP = 0;

            foreach (KeyValuePair <int, int> kvp in rescueUnit.unitData.fromLegionUnitTotalNumDict)
            {
                if (kvp.Value > 0)
                {
                    LegionData itemLegionData = War.GetLegionData(kvp.Key);
                    if (unitData.GetRelation(itemLegionData.legionId) == RelationType.Enemy)
                    {
                        enemyHP += WarFormula.WD_Solider2Casern_Damage(rescueUnit.unitData.def, itemLegionData.soliderInitData.atk, kvp.Value * itemLegionData.soliderData.hp2UnitRate);
                    }
                    else
                    {
                        rescueHP += kvp.Value * itemLegionData.soliderData.hp2UnitRate;
                    }
                }
            }

            isSend = rescueHP > enemyHP;

            if (isSend)
            {
//				Debug.Log("<color=blue>救援</color>");
                foreach (UnitCtl ownBuild in ownSelectBuilds)
                {
                    BSendArming bSendArming = ownBuild.GetComponent <BSendArming>();
                    bSendArming.Send(rescueUnit, aiConfig.sendArmPercent);
                }
            }



            return(isSend);
        }
Example #5
0
        bool Attack()
        {
//			Debug.Log("--------------Attack--------------");
            if (aiConfig.attackLevel == AIAttackLevel.Level_0_Lazy)
            {
                return(false);
            }



            // 攻击,随机派部队数量
            int sendCount = aiConfig.GetAttackSendCount();

//			Debug.Log("攻击,随机派部队数量 sendCount=" + sendCount);
            if (sendCount <= 0)
            {
                return(false);
            }

            // 攻击,生成派兵的建筑
            List <UnitCtl> ownSelectBuilds = new List <UnitCtl>();
            int            index           = 0;

            foreach (UnitCtl build in ownBuilds)
            {
                if (index < sendCount)
                {
                    if (build.hp <= 0)
                    {
                        continue;
                    }
                    if (build.unitData.behit && Random.Range(0f, 1f) > aiConfig.attackBehitRate)
                    {
                        continue;
                    }
                    ownSelectBuilds.Add(build);
                    index++;
                }
                if (index >= sendCount)
                {
                    break;
                }
            }

            // 计算敌人建筑被攻击值
            List <UnitCtl> enemyBuilds = War.scene.GetEnemyBuilds(legionId);

            if (enemyBuilds.Count <= 0)
            {
                return(false);
            }

            foreach (UnitCtl enemyBuild in enemyBuilds)
            {
                float distance = 0;
                foreach (UnitCtl ownBuild in ownSelectBuilds)
                {
                    distance += War.scene.GetBuildDistance(enemyBuild, ownBuild);
                }

                distance /= ownSelectBuilds.Count;
                enemyBuild.unitData.attackScore = enemyBuild.unitData.hp + distance * distanceScoreRate_Attack;

//				Debug.Log(string.Format("<color=grey>id={0}, hp={1}, distance={2}, attackValue={3}</color>", enemyBuild.unitData.id, enemyBuild.unitData.hp, distance, enemyBuild.unitData.attackScore));
            }

            // 排序敌人建筑被攻击值
            enemyBuilds.Sort(delegate(UnitCtl A, UnitCtl B)
            {
                return(Mathf.RoundToInt(A.unitData.attackScore - B.unitData.attackScore));
            });

            // 随机选择敌人建筑
            int enemyIndex = aiConfig.GetAttackTargetIndex();

            if (enemyIndex >= enemyBuilds.Count)
            {
                enemyIndex = enemyBuilds.Count - 1;
            }

//			Debug.Log("随机选择敌人建筑 enemyIndex=" + enemyIndex);

            UnitCtl targetBuild = enemyBuilds[enemyIndex];

            bool isSend = true;

            if (aiConfig.attackLevel == AIAttackLevel.Level_1_Cautious)
            {
                float hp = 0;
                foreach (UnitCtl ownBuild in ownSelectBuilds)
                {
                    hp += ownBuild.unitData.hp * aiConfig.sendArmPercent;
//					Debug.Log("HP" + hp);
                }

                hp     = WarFormula.WD_Solider2Casern_Damage(targetBuild.unitData.def, unitData.legionData.soliderInitData.atk, hp);
                isSend = hp > targetBuild.unitData.hp;
            }


            if (isSend)
            {
//				Debug.Log("<color=blue>攻击</color>");
                foreach (UnitCtl ownBuild in ownSelectBuilds)
                {
//					Debug.LogFormat("<color=blue>ownBuild.hp={0},  aiConfig.sendArmPercent=</color>", ownBuild.hp, aiConfig.sendArmPercent);
                    BSendArming bSendArming = ownBuild.GetComponent <BSendArming>();
                    bSendArming.Send(targetBuild, aiConfig.sendArmPercent);
                }
            }

            return(isSend);
        }
Example #6
0
        /** 生成数据--兵营 */
        public void GenerationBuilds()
        {
            Dictionary <int, float[]> legionHeroTotals = new Dictionary <int, float[]>();
            Dictionary <int, int>     legionHeroCounts = new Dictionary <int, int>();

            foreach (KeyValuePair <int, LegionData> legionKVP in legionDict)
            {
                LegionData legionData = legionKVP.Value;
                float[]    heroTotals = new float[PropId.MAX];
                int        heroCount  = 0;
                foreach (KeyValuePair <int, float[]> heroKVP in  legionData.heroInitProp)
                {
                    heroCount++;
                    heroTotals.PropAdd(heroKVP.Value);
                }

                legionHeroTotals.Add(legionData.legionId, heroTotals);
                legionHeroCounts.Add(legionData.legionId, heroCount);
            }



            foreach (KeyValuePair <int, StageLegionConfig> kvp in stageConfig.legionDict)
            {
                StageLegionConfig legionConfig = kvp.Value;
                LegionData        legionData   = legionDict[legionConfig.legionId];


                float[] soliderInitProp_Final = new float[PropId.MAX];
                soliderInitProp_Final.PropAdd(legionData.soliderInitProp);
                soliderInitProp_Final.Calculate();

                legionHeroTotals[legionData.legionId].Calculate();


                //------------------ 生成势力 士兵属性(士兵模块提供攻击+参战武将战前攻击之和) -----------------------//

                //	Debug.Log(legionData.legionId +  " <color=green>F legionData.soliderData.Props</color>" + legionData.soliderInitProp.ToStrProp());
//				legionData.soliderInitProp[PropId.InitAtk] = WarFormula.WF_Solider_Atk(legionData.levelData.intBattleForce, legionHeroTotals[legionData.legionId][PropId.Atk]);
                legionData.soliderInitProp[PropId.InitBattleForce] = WarFormula.WF_Solider_BattleForce(legionData.levelData.intBattleForce);
                legionData.soliderInitProp[PropId.InitMoveSpeed]   = WarFormula.WF_Solider_MoveSpeed(legionData.levelData.intMoveSpeed, legionHeroTotals[legionData.legionId][PropId.MoveSpeed]);

                //	Debug.Log(legionData.legionId +  " <color=green>B legionData.soliderData.Props=</color>" + legionData.soliderInitProp.ToStrProp());

                //------------------ 生成势力 兵营属性(产兵速度, 防御, 兵力上限) -----------------------//

                float[] props = new float[PropId.MAX];

                // 战前兵营--产兵速度
                props[PropId.InitProduceSpeed] = WarFormula.WF_Casern_ProduceSpeed(legionData.levelData.intProduceSpeed, legionHeroTotals[legionData.legionId][PropId.ProduceSpeed]);
                // 战前兵营--防御
//				props[PropId.InitDef] = WarFormula.WF_Casern_Def(legionData.levelData.intBattleForce, legionHeroTotals[legionData.legionId][PropId.Def]);
                props[PropId.InitBattleForce] = WarFormula.WF_Casern_BattleForce(legionData.levelData.intBattleForce);

                // 战前兵营--兵力上限
                props[PropId.InitMaxHp] = WarFormula.WF_Casern_MaxHP(legionHeroTotals[legionData.legionId][PropId.MaxHp]);
//				// 战前兵营--速攻
//				props[PropId.InitSpeedAtk] = WarFormula.WF_Casern_SpeedAtk(legionData.levelData.intBattleForce, legionHeroTotals[legionData.legionId][PropId.SpeedAtk]);

                //Debug.Log ("legionData.legionId=" + legionData.legionId + "  " +  props.ToStrProp());

                // 设置势力--兵营战前属性
                legionData.buildInitProp = props;
            }


            // 兵营初始兵力(血量Hp)
            foreach (KeyValuePair <int, StagePositionConfig> kvp in stageConfig.buildDict)
            {
                StagePositionConfig buildConfig = kvp.Value;
                LegionData          legionData  = legionDict[buildConfig.legionId];



                float[] full = new float[PropId.MAX];
                full.PropAdd(legionData.buildInitProp);


                float hero_InitSpeedAtk = 0f;
//				HeroData heroData;
//				if(herosByBuild.TryGetValue(buildConfig.index, out heroData))
//				{
//					hero_InitSpeedAtk = legionData.heroInitProp[heroData.heroId][PropId.InitSpeedAtk];
//				}


                // 初始兵力--计算
//				Debug.Log(string.Format("<color=yellow>buildConfig.index={0}, buildConfig.hp={1}</color>, full[PropId.MaxHp]={2}, hasHero={3} heroMaxHp={4}", buildConfig.index, buildConfig.hp, full[PropId.MaxHp],herosByBuild.ContainsKey(buildConfig.index), heroMaxHp));
//				float hp = WarFormula.WF_Casern_Hp(buildConfig.hp, legionData.buildInitProp[PropId.InitMaxHp], herosByBuild.ContainsKey(buildConfig.index), heroMaxHp);
                float hp = WarFormula.WF_Casern_Hp(buildConfig.hp, legionData.levelData.initHP);

                float[] firstProp = new float[PropId.MAX];
                firstProp[PropId.HpAdd] = hp;


                // 兵营初始属性[Hp]
                float[] initProp = new float[PropId.MAX];
                initProp[PropId.InitHp] = hp;

                buildFirstProp.Add(buildConfig.index, firstProp);
                buildInitProp.Add(buildConfig.index, initProp);
            }

            int casernCount = 0;
            int turretCount = 0;
            int spotCount   = 0;

            // 生成兵营UnitData
            foreach (KeyValuePair <int, StagePositionConfig> kvp in stageConfig.buildDict)
            {
                StagePositionConfig positionConfig = kvp.Value;

                UnitData unitData = new UnitData();
                unitData.id                    = positionConfig.index;
                unitData.legionId              = positionConfig.legionId;
                unitData.unitType              = UnitType.Build;
                unitData.buildType             = positionConfig.buildType;
                unitData.level                 = positionConfig.level;
                unitData.position              = positionConfig.position;
                unitData.buildConfig           = positionConfig.buildConfig;
                unitData.we_BuildConfigData    = new WE_BuildConfigData();
                unitData.we_BuildConfigData.hp = (int)positionConfig.hp;
                unitData.we_BuildConfigData.settledPriority = positionConfig.settledPriority;
                unitData.we_BuildConfigData.buildConfig     = unitData.buildConfig;


                buildDict.Add(positionConfig.index, unitData);

                switch (unitData.buildType)
                {
                case BuildType.Casern:
                    casernCount++;
                    break;

                case BuildType.Turret:
                    turretCount++;
                    break;

                case BuildType.Spot:
                    spotCount++;
                    break;
                }
            }

            legionTotalMaxHP = casernCount * ConstConfig.GetFloat(ConstConfig.ID.War_StageLegionTotalMaxHP_Ratio_Casern)
                               + turretCount * ConstConfig.GetFloat(ConstConfig.ID.War_StageLegionTotalMaxHP_Ratio_Turret)
                               + spotCount * ConstConfig.GetFloat(ConstConfig.ID.War_StageLegionTotalMaxHP_Ratio_Spot);


            foreach (KeyValuePair <int, LegionData> kvp in legionDict)
            {
                kvp.Value.totalMaxHP = legionTotalMaxHP;
            }
        }
Example #7
0
        /** 生成数据--英雄 */
        public void GenerationHeros()
        {
            LegionData legionData;

            int    itemLegionId;
            int    itemHeroId;
            int    itemAvatarId;
            string itemName;
            int    quality = 1;
            int    skillId;
            int    skillLevel;
            int    skillId2;
            int    skillLevel2;

            float[] hero2BuildProps;
            float[] props;

            // 生成英雄数据UnitData
            foreach (WarEnterLegionData enterLegionData in enterData.legionList)
            {
                itemLegionId = enterLegionData.legionId;

                legionData = legionDict[itemLegionId];

                foreach (WarEnterHeroData enterHeroData in enterLegionData.heroList)
                {
                    itemHeroId   = enterHeroData.heroId;
                    itemAvatarId = enterHeroData.avatarId;
                    itemName     = enterHeroData.name;
                    skillId      = enterHeroData.skillId;
                    skillLevel   = enterHeroData.level;
                    quality      = enterHeroData.quality;
                    skillId2     = 0;
                    skillLevel2  = 0;


                    // 获取玩家英雄属性
                    hero2BuildProps = new float[PropId.MAX];
                    hero2BuildProps = hero2BuildProps.PropAdd(enterHeroData.props);

                    props = enterHeroData.props.PropsToInit_Float();
                    props[PropId.InitDefKillHero] = WarFormula.WF_Hero_DefKillHero_Player(props[PropId.InitDefKillHero]);

                    CreateHero(itemLegionId, itemHeroId, itemAvatarId, itemName, quality,
                               skillId, skillLevel,
                               hero2BuildProps, props
                               );
                }
            }

            foreach (var kvp in legionDict)
            {
                legionData   = kvp.Value;
                itemLegionId = legionData.legionId;

                if (legionData.type != LegionType.Neutral)
                {
                    itemHeroId   = 1;
                    itemAvatarId = legionData.headAvatarId;
                    itemName     = legionData.name;
                    skillId      = War.config.roleSkillId;
                    skillLevel   = 1;
                    skillId2     = 0;
                    skillLevel2  = 0;


                    // 获取玩家英雄属性
                    hero2BuildProps = new float[PropId.MAX];
                    props           = new float[PropId.MAX];

                    CreateHero(itemLegionId, itemHeroId, itemAvatarId, itemName, quality,
                               skillId, skillLevel,
                               hero2BuildProps, props
                               );
                    legionData.initUseSkillId = skillId;
                }
            }
        }
Example #8
0
        /** 生成数据--势力 */
        public void GenerationLegions()
        {
            // 占用自己颜色的势力
            LegionData occupyMainLegionData = null;

            War.realPlayerCount = 0;

            // 创建势力数据LegionData
            foreach (KeyValuePair <int, StageLegionConfig> kvp in stageConfig.legionDict)
            {
                StageLegionConfig legionConfig = kvp.Value;
                LegionData        legionData;
                if (legionConfig.type == LegionType.Player)
                {
                    legionData = new LegionData(legionConfig.legionId, "Player-" + legionConfig.legionId, LegionType.Player, legionConfig.aiSendArm, legionConfig.aiUplevel, legionConfig.aiSkill, legionConfig.produce);
                    if (enterData.vsmode == VSMode.PVP && legionData.legionId != ownLegionID)
                    {
                        legionData.aiSendArm = false;
                        legionData.aiSkill   = false;
                        legionData.aiUplevel = false;
                    }
                }
                else if (legionConfig.type == LegionType.Computer)
                {
                    legionData = new LegionData(legionConfig.legionId, "Player-" + legionConfig.legionId, LegionType.Computer, legionConfig.aiSendArm, legionConfig.aiUplevel, legionConfig.aiSkill, legionConfig.produce);
                    if (enterData.vsmode == VSMode.PVP && !War.isMainLegion)
                    {
                        legionData.aiSendArm = false;
                        legionData.aiSkill   = false;
                        legionData.aiUplevel = false;
                    }
                }
                else
                {
                    legionData = new LegionData(legionConfig.legionId, "Player-" + legionConfig.legionId, LegionType.Neutral, legionConfig.aiSendArm, legionConfig.aiUplevel, legionConfig.aiSkill, legionConfig.produce);
                    if (enterData.vsmode == VSMode.PVP && !War.isMainLegion)
                    {
                        legionData.aiSendArm = false;
                        legionData.aiSkill   = false;
                        legionData.aiUplevel = false;
                    }
                }



                legionData.produceLimit = legionConfig.produceLimit;
                legionData.colorId      = legionConfig.color;
                legionDict.Add(legionData.legionId, legionData);

                if (legionData.colorId == War.config.ownDefaultColor)
                {
                    occupyMainLegionData = legionData;
                }

                legionData.roleId = enterData.GetRoleId(legionData.legionId);
                if (!roleDict.ContainsKey(legionData.roleId))
                {
                    roleDict.Add(legionData.roleId, legionData);
                }

                legionData.expeditionTotalMaxHP = enterData.GetTotalMaxHP(legionData.legionId);
                legionData.expeditionTotalHP    = enterData.GetTotalHP(legionData.legionId);
                legionData.expeditionInitHP     = legionData.expeditionTotalHP;
                legionData.expeditionLeftHP     = legionData.expeditionTotalHP;


                WarEnterLegionData enterLegionData = enterData.GetEnterLegionData(legionData.legionId);
                if (enterLegionData != null)
                {
                    legionData.name                      = enterLegionData.name;
                    legionData.headAvatarId              = enterLegionData.headAvatarId;
                    legionData.levelData.intBattleForce  = enterLegionData.totalAtk;
                    legionData.levelData.intProduceSpeed = enterLegionData.totalProduceSpeed;
                    legionData.levelData.intMoveSpeed    = enterLegionData.totalMoveSpeed;
                    legionData.levelData.initHP          = enterLegionData.initHP;

                    legionData.levelData.maxBattleForce  = enterLegionData.maxAtk;
                    legionData.levelData.maxProduceSpeed = enterLegionData.maxProduceSpeed;
                    legionData.levelData.maxMoveSpeed    = enterLegionData.maxMovespeed;


                    legionData.levelData.subBattleForce  = enterLegionData.subAtk;
                    legionData.levelData.subProduceSpeed = enterLegionData.subProduceSpeed;
                    legionData.levelData.subMoveSpeed    = enterLegionData.subMoveSpeed;

                    legionData.sendArmRate = enterLegionData.sendArmRate;

                    if (enterLegionData.isRobot)
                    {
                        if (enterData.vsmode == VSMode.PVP && War.isMainLegion && legionData.colorId != 0)
                        {
                            legionData.aiSendArm = true;
                            legionData.aiSkill   = true;
                            legionData.aiUplevel = true;
                        }
                        legionData.type = LegionType.Computer;

                        if (legionData.colorId == 0)
                        {
                            legionData.type = LegionType.Neutral;
                        }
                    }
                    else
                    {
                        legionData.type      = LegionType.Player;
                        legionData.aiSendArm = false;
                        legionData.aiSkill   = false;
                        legionData.aiUplevel = false;
                    }


                    if (enterLegionData.ai > 0)
                    {
                        legionData.aiConfig = War.model.GetAIConfig(enterLegionData.ai);;
                    }
                }
                else
                {
                    NeutralExpConfig roleExpConfig = War.model.GetNeutralExpConfig(stageConfig.neutralRoleLevel);

                    legionData.levelData.intBattleForce  = roleExpConfig.props[PropId.BattleForceAdd];
                    legionData.levelData.intProduceSpeed = roleExpConfig.props[PropId.ProduceSpeedAdd];
                    legionData.levelData.intMoveSpeed    = roleExpConfig.props[PropId.MoveSpeedAdd];
                    legionData.levelData.initHP          = roleExpConfig.props[PropId.HpAdd];


                    if (legionData.colorId == 0)
                    {
                        legionData.type = LegionType.Neutral;
                    }
                    else
                    {
                        legionData.type = LegionType.Computer;
                    }
                }

                if (legionConfig.type == LegionType.Player)
                {
                    War.realPlayerCount++;
                }


                if (War.isEditor)
                {
                    legionData.aiSendArm = false;
                    legionData.aiSkill   = false;
                    legionData.produce   = false;
                    legionData.aiUplevel = false;
                }


                if (War.isTest)
                {
                    if (legionData.type == LegionType.Computer || (legionData.type == LegionType.Player && legionData.legionId != War.ownLegionID))
                    {
                        legionData.aiSendArm = true;
                        legionData.aiSkill   = true;
                        legionData.produce   = true;
                        legionData.aiUplevel = true;
                        legionData.aiConfig  = stageConfig.id >= 71 && stageConfig.id <= 80 ? War.model.GetAIConfig(102) : War.model.GetAIConfig(302);
                    }
                }

                if (War.isRecord)
                {
                    legionData.aiSendArm = false;
                    legionData.aiSkill   = false;
                    legionData.aiUplevel = false;
                }


                int id = GetPlayerUID(legionData.legionId);

                // 势力单位数据
                UnitData unitData = new UnitData();
                unitData.id       = id;
                unitData.legionId = legionData.legionId;
                unitData.unitType = UnitType.Player;
                float x = 5 * Mathf.FloorToInt((legionData.legionId + 1) / 2) * (legionData.legionId % 2 == 0 ? 1 : -1);
                unitData.position   = new Vector3(x, 0f, -11F);
                legionData.unitData = unitData;

                /** 战前势力--怒气上限 */
                legionData.legionInitProp[PropId.InitMaxMage] = WarFormula.WF_Legion_MaxMage();
                /** 战前势力--怒气 */
                legionData.legionInitProp[PropId.MagAdd] = legionData.legionInitProp[PropId.InitMag] = enterData.vsmode != VSMode.PVE_Expedition ? WarFormula.WF_Legion_Mage() : enterData.GetMag(legionData.legionId);
                /** 战前势力--怒气 */
                legionData.legionInitProp[PropId.InitMageSpeed] = ConstConfig.GetFloat(ConstConfig.ID.War_DV_Mag_Recovery_Ratio);



                //TODO Test
                //legionData.aiSendArm = true;
                //legionData.aiSkill = true;
                //legionData.aiConfig = War.model.GetAIConfig(302);
            }

            // 获取自己势力数据
            ownLegion = legionDict[ownLegionID];


            // 交换势力颜色
            if (occupyMainLegionData != null && occupyMainLegionData != ownLegion)
            {
                int tempColorId = ownLegion.colorId;
                ownLegion.colorId            = occupyMainLegionData.colorId;
                occupyMainLegionData.colorId = tempColorId;
            }
            else
            {
                ownLegion.colorId = War.config.ownDefaultColor;
            }


            // 创建势力联盟数据LegionGroupData
            foreach (StageLegionGroupConfig groupConfig in stageConfig.legionGroups)
            {
                LegionGroupData groupData = new LegionGroupData(groupConfig.id);
                legionGroupDict.Add(groupData.id, groupData);

                foreach (StageLegionConfig legionConfig in groupConfig.list)
                {
                    groupData.AddLegion(legionDict[legionConfig.legionId]);
                }
            }


            List <int> colorIdList = new List <int>();

            foreach (KeyValuePair <int, LegionData> legionKVP in War.sceneData.legionDict)
            {
                colorIdList.Add(legionKVP.Value.colorId);
            }

            colorIds = colorIdList.ToArray();
        }