Example #1
0
        public static void RefreshLevelEnemy()
        {
            foreach (int levelID in DBConfigMgr.Instance.MapLevel.Keys)
            {
                Formation f1 = new Formation();
                f1.InitNPCFormation(levelID, false);
                foreach (NPCEnemy enemy in f1.NPCFormation.Values)
                {
                    enemy.SoldierConfigID = DBConfigMgr.Instance.MapGeneral[enemy.GeneralConfigID].InitialSoldier;
                    enemy.GeneralLevel = DBConfigMgr.Instance.MapLevel[levelID].RefLevel;
                    enemy.SoldierLevel = DBConfigMgr.Instance.MapLevel[levelID].RefLevel;
                }
                RefreshOneLevelEnemy(levelID, f1.NPCFormation, false);

                Formation f2 = new Formation();
                f2.InitNPCFormation(levelID, true);
                foreach (NPCEnemy enemy in f2.NPCFormation.Values)
                {
                    enemy.SoldierConfigID = DBConfigMgr.Instance.MapGeneral[enemy.GeneralConfigID].InitialSoldier;
                    enemy.GeneralLevel = DBConfigMgr.Instance.MapLevel[levelID].EliteRefLevel;
                    enemy.SoldierLevel = DBConfigMgr.Instance.MapLevel[levelID].EliteRefLevel;
                }
                RefreshOneLevelEnemy(levelID, f2.NPCFormation, true);
            }
        }
Example #2
0
        /// <summary>
        /// 模拟队伍1是否取胜
        /// </summary>
        /// <param name="f1"></param>
        /// <param name="f2"></param>
        /// <returns></returns>
        public static bool ComputeTeamOneWin(Formation f1, Formation f2)
        {
            if (f1.TeamBattlePowerPoint / 2 > f2.TeamBattlePowerPoint)
                return true;
            else if (f1.TeamBattlePowerPoint * 2 < f2.TeamBattlePowerPoint)
                return false;

            double winPossiblity = 0.9;

            int battlePointGap = f1.TeamBattlePowerPoint - f2.TeamBattlePowerPoint;
            if (battlePointGap > 0) // f1 > f2
            {
                winPossiblity += battlePointGap / (10 * f2.TeamBattlePowerPoint); // = 0.9 + (A-B)/10B
            }
            else // f1 < f2
            {
                winPossiblity += battlePointGap / (0.9 * f2.TeamBattlePowerPoint);
            }

            Random r = new Random();
            return r.NextDouble() <= winPossiblity;
        }