// This is probably hella slow, but it's the easy way to do this. Would be better to cache lists by biome in a System.
        private MonsterList GetMonsterList(ISystemContainer systemContainer, IEntity branch)
        {
            var list = new MonsterList();

            var monsters = systemContainer.EntityEngine
                           .AllEntities
                           .Where(e => e.HasAll(new SystemComponents {
                typeof(Biome), typeof(Health), typeof(Prototype)
            }))
                           .Where(e => HasMatchingBiome(branch, e));

            foreach (var monster in monsters)
            {
                var cr = monster.Has <Challenge>() ? monster.Get <Challenge>().ChallengeRating : 0;

                if (list.ContainsKey(cr))
                {
                    list[cr].Add(monster);
                }
                else
                {
                    list.Add(cr, new HashSet <IEntity> {
                        monster
                    });
                }
            }

            return(list);
        }
Пример #2
0
        /// <summary>
        /// Add Monsters to the Round
        ///
        /// Because Monsters can be duplicated, will add 1, 2, 3 to their name
        ///

        /*
         * Hint:
         * I don't have crudi monsters yet so will add 6 new ones...
         * If you have crudi monsters, then pick from the list
         *
         * Consdier how you will scale the monsters up to be appropriate for the characters to fight
         */
        /// </summary>
        /// <returns></returns>
        public int AddMonstersToRound()
        {
            List <MonsterModel> SelectedMonsterList = DefaultData.LoadData(new MonsterModel());

            for (int i = 0; i < MaxNumberPartyMonsters; i++)
            {
                PlayerInfoModel CurrentMonster = new PlayerInfoModel(SelectedMonsterList[i]);
                CurrentMonster.ScaleLevel(GetAverageCharacterLevel());
                MonsterList.Add(CurrentMonster);
            }

            //Hack #31, When Round Count exceeds 100, Monster power becomes 10x
            if (BattleScore.RoundCount > 100)
            {
                foreach (PlayerInfoModel Monster in MonsterList)
                {
                    Monster.Attack        = 10 * Monster.Attack;
                    Monster.Speed         = 10 * Monster.Speed;
                    Monster.Defense       = 10 * Monster.Defense;
                    Monster.CurrentHealth = 10 * Monster.CurrentHealth;
                    Monster.MaxHealth     = 10 * Monster.MaxHealth;
                }
            }
            return(MonsterList.Count);
        }
        /// <summary>
        /// Add Monsters to the Round
        ///
        /// Because Monsters can be duplicated, will add 1, 2, 3 to their name
        ///

        /*
         * Hint:
         * I don't have crudi monsters yet so will add 6 new ones...
         * If you have crudi monsters, then pick from the list
         * Consdier how you will scale the monsters up to be appropriate for the characters to fight
         *
         */
        /// </summary>
        /// <returns></returns>
        public int AddMonstersToRound()
        {
            var    monsterModel = MonsterIndexViewModel.Instance;
            Random rnd          = new Random();
            int    TargetLevel  = 1;
            int    MaxLevel     = 20;


            if (CharacterList.Count() > 0)
            {
                // Get the Min Character Level (linq is soo cool....)
                TargetLevel = Convert.ToInt32(CharacterList.Min(m => m.Level));
                MaxLevel    = Convert.ToInt32(CharacterList.Max(m => m.Level));
            }

            /* Hack 31 has been implemented. If the round count is > 100
             * then the monster's speed, defense, attack, current health, and max health
             * are buffed 10x
             */
            for (var i = 0; i < MaxNumberPartyMonsters; i++)
            {
                int index = rnd.Next(0, MaxNumberPartyMonsters - 1);
                var data  = monsterModel.Dataset[index];
                data.Level         = TargetLevel;
                data.Speed         = getAttributeLevel();
                data.Defense       = getAttributeLevel();
                data.Attack        = getAttributeLevel();
                data.MaxHealth     = DiceHelper.RollDice(TargetLevel, 10);
                data.CurrentHealth = data.MaxHealth;

                MonsterList.Add(new PlayerInfoModel(data));
            }

            return(MonsterList.Count());
        }
        public override Task OnActivateAsync()
        {
            if (this.GetPrimaryKeyLong() == (long)BiomeId.Savanna)
            {
                BiomeProperties.BaseHeight      = 0.125f;
                BiomeProperties.HeightVariation = 0.05f;
                BiomeProperties.Temperature     = 1.2f;
                BiomeProperties.Rainfall        = 0.0f;
                BiomeProperties.EnableSnow      = false;
                BiomeProperties.WaterColor      = 16777215;
                BiomeProperties.EnableRain      = false;
            }

            TopBlock    = BlockStates.GrassBlock();
            FillerBlock = BlockStates.Dirt();

            PlantsList.Add(PlantsType.TallGrass);
            PlantsList.Add(PlantsType.AcaciaTree);

            PassiveMobList.Add(MobType.Cow);
            PassiveMobList.Add(MobType.Sheep);
            PassiveMobList.Add(MobType.Horse);

            MonsterList.Add(MobType.Creeper);
            MonsterList.Add(MobType.Skeleton);
            MonsterList.Add(MobType.Zombie);
            MonsterList.Add(MobType.Spider);

            return(Task.CompletedTask);
        }
Пример #5
0
        // Add Monsters
        // Scale them to meet Character Strength...
        public void AddMonstersToRound()
        {
            // Check to see if the monster list is full, if so, no need to add more...
            if (MonsterList.Count() >= GameGlobals.MaxNumberPartyPlayers)
            {
                return;
            }

            // Make Sure Monster List exists and is loaded...
            var myMonsterViewModel = MonstersViewModel.Instance;

            if (myMonsterViewModel.Dataset.Count() > 0)
            {
                // Scale monsters to be within the range of the Characters

                var ScaleLevelMax     = 1;
                var ScaleLevelMin     = 1;
                var ScaleLevelAverage = 1;

                if (CharacterList.Any())
                {
                    ScaleLevelMax     = GetMaxCharacterLevel();
                    ScaleLevelMin     = GetMinCharacterLevel();
                    ScaleLevelAverage = GetAverageCharacterLevel();
                }

                // Get 1 monsters
                do
                {
                    //Force Random Roll here. Important for the debug override setting.
                    //Game will not work without a random value here
                    var rnd = HelperEngine.RollDice(1, myMonsterViewModel.Dataset.Count, true);
                    {
                        var monster = new Monster(myMonsterViewModel.Dataset[rnd - 1]);

                        // Help identify which monster it is...
                        monster.Name += " " + (1 + MonsterList.Count()).ToString();

                        // Scale the monster to be between the average level of the characters+1
                        var rndScale = HelperEngine.RollDice(1, ScaleLevelAverage + 1);
                        monster.ScaleLevel(rndScale);
                        MonsterList.Add(monster);
                    }
                } while (MonsterList.Count() < 1);
            }
            else
            {
                // No monsters in DB, so add 1 new ones...
                for (var i = 0; i < 1; i++)
                {
                    var item = new Monster();
                    // Help identify which monster it is...
                    item.Name += " " + MonsterList.Count() + 1;
                    MonsterList.Add(item);
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Adds monsters to the round.
        /// Since monsters may be duplicated, appends a number to the name of each monster.
        /// </summary>
        /// <returns></returns>
        public int AddMonstersToRound(List <MonsterModel> monsters)
        {
            for (var i = 0; i < MaxNumberMonsters; i++)
            {
                var data = monsters[i];

                MonsterList.Add(data);
            }

            return(MonsterList.Count());
        }
Пример #7
0
        /// <summary>
        /// Add Monsters to the Round
        ///
        /// Because Monsters can be duplicated, will add 1, 2, 3 to their name
        /// </summary>
        /// <returns></returns>
        public int AddMonstersToRound()
        {
            for (var i = 0; i < MaxNumberPartyMonsters; i++)
            {
                var data = new MonsterModel();
                // Help identify which Monster it is
                data.Name += " " + MonsterList.Count() + 1;
                MonsterList.Add(new PlayerInfoModel(data));
            }

            return(MonsterList.Count());
        }
Пример #8
0
        /// <summary>
        /// Add Monsters to the Round
        /// </summary>
        /// <returns></returns>
        public int AddMonstersToRound()
        {
            foreach (var data in MonsterIndexViewModel.Instance.Dataset)
            {
                if (MonsterList.Count() >= MaxNumberPartyMonsters)
                {
                    break;
                }
                //data.Attack += 50;
                //data.Level = 10;
                MonsterList.Add(new EntityInfoModel(data));
            }

            return(MonsterList.Count());
        }
Пример #9
0
        public override Task OnActivateAsync()
        {
            if (this.GetPrimaryKeyLong() == (long)BiomeId.Plains)
            {
                BiomeProperties.BaseHeight      = 0.125f;
                BiomeProperties.HeightVariation = 0.05f;
                BiomeProperties.Temperature     = 0.8f;
                BiomeProperties.Rainfall        = 0.4f;
                BiomeProperties.EnableSnow      = false;
            }
            else if (this.GetPrimaryKeyLong() == (long)BiomeId.SunflowerPlains)
            {
                BiomeProperties.BaseHeight      = 0.125f;
                BiomeProperties.HeightVariation = 0.05f;
                BiomeProperties.Temperature     = 0.8f;
                BiomeProperties.Rainfall        = 0.4f;
                BiomeProperties.EnableSnow      = false;
            }
            else if (this.GetPrimaryKeyLong() == (long)BiomeId.SnowyTundra)
            {
                BiomeProperties.BaseHeight      = 0.125f;
                BiomeProperties.HeightVariation = 0.05f;
                BiomeProperties.Temperature     = 0.0f;
                BiomeProperties.Rainfall        = 0.5f;
                BiomeProperties.EnableSnow      = true;
            }

            BiomeProperties.WaterColor = 16777215;
            BiomeProperties.EnableRain = true;
            TopBlock    = BlockStates.GrassBlock();
            FillerBlock = BlockStates.Dirt();

            PlantsList.Add(PlantsType.TallGrass);
            PlantsList.Add(PlantsType.Poppy);
            PlantsList.Add(PlantsType.Dandelion);

            PassiveMobList.Add(MobType.Cow);
            PassiveMobList.Add(MobType.Sheep);
            PassiveMobList.Add(MobType.Horse);
            PassiveMobList.Add(MobType.Donkey);

            MonsterList.Add(MobType.Creeper);
            MonsterList.Add(MobType.Skeleton);
            MonsterList.Add(MobType.Zombie);
            MonsterList.Add(MobType.Spider);

            return(Task.CompletedTask);
        }
Пример #10
0
        // Add Monsters
        // Scale them to meet Character Strength...
        private void AddMonstersToRound()
        {
            // Check to see if the monster list is full, if so, no need to add more...
            if (MonsterList.Count() >= 6)
            {
                return;
            }

            // TODO, determine the character strength
            // add monsters up to that strength...
            var ScaleLevelMax = 2;
            var ScaleLevelMin = 1;

            // Make Sure Monster List exists and is loaded...
            var myMonsterViewModel = MonstersViewModel.Instance;

            myMonsterViewModel.ForceDataRefresh();

            if (myMonsterViewModel.Dataset.Count() > 0)
            {
                // Get 6 monsters
                do
                {
                    var rnd = HelperEngine.RollDice(1, myMonsterViewModel.Dataset.Count);
                    {
                        var item = new Monster(myMonsterViewModel.Dataset[rnd - 1]);

                        // Help identify which monster it is...
                        item.Name += " " + (1 + MonsterList.Count()).ToString();

                        var rndScale = HelperEngine.RollDice(ScaleLevelMin, ScaleLevelMax);
                        item.ScaleLevel(rndScale);
                        MonsterList.Add(item);
                    }
                } while (MonsterList.Count() < 6);
            }
            else
            {
                // No monsters in DB, so add 6 new ones...
                for (var i = 0; i < 6; i++)
                {
                    var item = new Monster();
                    // Help identify which monster it is...
                    item.Name += " " + MonsterList.Count() + 1;
                    MonsterList.Add(item);
                }
            }
        }
Пример #11
0
        ///// <summary>
        ///// Hackathon Scenario 33 - unlucky things happen on round 13
        ///// Random character falls down dead
        ///// </summary>
        //public void UnluckyRound()
        //{
        //    // first, check whether forced dice rolls are being used
        //    // if they are, exit to avoid trying to access an invalid index or create an endless loop
        //    if (DiceHelper.ForceConstantRoll == true)
        //    {
        //        var index = DiceHelper.ForcedDiceRollValue - 1;
        //        if (index >= 0 && index < CharacterList.Count())
        //        {
        //            MakeEntityList();
        //            var character = CharacterList[index];
        //            if (character.Alive)
        //                TargetDied(EntityList.First(a => a.Id == character.Id));
        //        }
        //        return;
        //    }

        //    int count = 0;
        //    while (count == 0)
        //    {
        //        var diceroll = DiceHelper.RollDice(1, CharacterList.Count()) - 1;
        //        var character = CharacterList[diceroll];
        //        if (character.Alive)
        //        {
        //            TargetDied(EntityList.First(a => a.Id == character.Id));
        //            BattleMessages.TurnMessageSpecial = character.Name + " dies a horribly unlucky death!";
        //            Debug.WriteLine(BattleMessages.TurnMessageSpecial);
        //            count++;
        //        }
        //    }


        //}

        /// <summary>
        /// Adds monsters to the round.
        /// Since monsters may be duplicated, appends a number to the name of each monster.
        /// </summary>
        /// <returns></returns>
        public int AddMonstersToRound()
        {
            // used for scaling monsters to level of characters
            int averageLevel = GetAverageCharacterLevel();
            var level        = averageLevel;
            var range        = new List <int> {
                averageLevel
            };

            if (averageLevel > 2 && averageLevel < 20)
            {
                range = new List <int> {
                    averageLevel - 1, averageLevel, averageLevel + 1, averageLevel + 2
                };
            }


            for (var i = 0; i < MaxNumberMonsters; i++)
            {
                var data = new MonsterModel(RandomEntityHelper.GetMonsterType());
                // slightly randomizes Monster levels
                if (range.Count > 1)
                {
                    var dice = DiceHelper.RollDice(1, range.Count()) - 1;
                    if (dice >= 0 && dice < range.Count())
                    {
                        level = range.ElementAt(dice);
                    }
                }

                data.ChangeLevel(level);
                if (level == 1)
                {
                    // MONSTERS SHOULDN'T GIVE ZERO EXPERIENCE :(
                    data.ExperienceGiven = 100;
                }

                MonsterList.Add(data);
            }

            return(MonsterList.Count());
        }
Пример #12
0
        public ArcarinasSquare(short id) : base(id)
        {
            MapExits.Add(new MapExit(86, new Rect(59, 0, 67, 2), 63, 105));

            NpcList.Add(new NpcObject(0, "Transporter", 61456, 6, 85, 46, 2, Id));
            NpcList.Add(new NpcObject(1, "North Gate Guard", 61458, 1, 58, 10, 2, Id));
            NpcList.Add(new NpcObject(2, "North Gate Guard", 61458, 1, 67, 10, 2, Id));

            MonsterList.Add(new MonsterObject(0, 1, 68, 36, 2, Id));

            PetList.Add(new PetObject(0, 1, 101, 6, 2, Id));
            PetList.Add(new PetObject(1, 2, 104, 6, 2, Id));
            PetList.Add(new PetObject(2, 3, 107, 6, 2, Id));
            PetList.Add(new PetObject(3, 4, 110, 6, 2, Id));
            PetList.Add(new PetObject(4, 5, 113, 6, 2, Id));
            PetList.Add(new PetObject(5, 6, 116, 9, 3, Id));
            PetList.Add(new PetObject(6, 7, 116, 12, 3, Id));
            PetList.Add(new PetObject(7, 8, 116, 15, 3, Id));
            PetList.Add(new PetObject(8, 9, 116, 18, 3, Id));
            PetList.Add(new PetObject(9, 10, 116, 21, 3, Id));
        }
Пример #13
0
        public override Task OnActivateAsync()
        {
            if (this.GetPrimaryKeyLong() == (long)BiomeId.Ocean)
            {
                BiomeProperties.BaseHeight      = -1.0f;
                BiomeProperties.HeightVariation = 0.1f;
                BiomeProperties.Temperature     = 0.5f;
                BiomeProperties.Rainfall        = 0.5f;
                BiomeProperties.EnableSnow      = false;
            }
            else if (this.GetPrimaryKeyLong() == (long)BiomeId.FrozenOcean)
            {
                BiomeProperties.BaseHeight      = -1.0f;
                BiomeProperties.HeightVariation = 0.1f;
                BiomeProperties.Temperature     = 0.0f;
                BiomeProperties.Rainfall        = 0.5f;
                BiomeProperties.EnableSnow      = true;
            }
            else if (this.GetPrimaryKeyLong() == (long)BiomeId.DeepOcean)
            {
                BiomeProperties.BaseHeight      = -1.8f;
                BiomeProperties.HeightVariation = 0.1f;
                BiomeProperties.Temperature     = 0.5f;
                BiomeProperties.Rainfall        = 0.5f;
                BiomeProperties.EnableSnow      = false;
            }

            TopBlock    = BlockStates.Dirt();
            FillerBlock = BlockStates.Dirt();

            MonsterList.Add(MobType.Creeper);
            MonsterList.Add(MobType.Skeleton);
            MonsterList.Add(MobType.Zombie);
            MonsterList.Add(MobType.Spider);

            return(Task.CompletedTask);
        }
Пример #14
0
        /// <summary>
        /// Add Monsters to the Round
        ///
        /// Because Monsters can be duplicated, will add 1, 2, 3 to their name
        ///

        /*
         * Hint:
         * I don't have crudi monsters yet so will add 6 new ones...
         * If you have crudi monsters, then pick from the list
         *
         * Consdier how you will scale the monsters up to be appropriate for the characters to fight
         *
         */
        /// </summary>
        /// <returns></returns>
        public int AddMonstersToRound()
        {
            // TODO: Teams, You need to implement your own Logic can not use mine.



            int TargetLevel = 1;

            if (CharacterList.Count() > 0)
            {
                // Get the Min Character Level (linq is soo cool....)
                TargetLevel = Convert.ToInt32(CharacterList.Min(m => m.Level));
            }

            for (var i = 0; i < MaxNumberPartyMonsters; i++)
            {
                var data = Helpers.RandomPlayerHelper.GetRandomMonster(TargetLevel);

                // Help identify which Monster it is
                data.Name += " " + MonsterList.Count() + 1;

                //Scenario 31
                if (BattleScore.RoundCount >= 100)
                {
                    data.Attack     *= 10;
                    data.Speed      *= 10;
                    data.Defense    *= 10;
                    data.CurrHealth *= 10;
                    data.MaxHealth  *= 10;
                }


                MonsterList.Add(new PlayerInfoModel(data));
            }


            if ((BossBattleFunctionality && DiceHelper.RollDice(1, 100) > 90) || testBossHack)
            {
                Debug.WriteLine("BOSS MONSTER APPROACHING!!!!!");
                MonsterList.Clear();
                int scaleFactor = 0;
                for (int i = 0; i < CharacterList.Count; i++)
                {
                    scaleFactor += CharacterList[i].Level;
                }
                if (scaleFactor > 20)
                {
                    scaleFactor = 20;
                }



                var data = new BaseMonster();
                data.LevelUpToValue(scaleFactor);

                data.Attack    = 5000;
                data.Defense   = 5000;
                data.Speed     = 10000;
                data.MaxHealth = data.CurrHealth = 1000;

                MonsterList.Add(new PlayerInfoModel(data));
            }


            return(MonsterList.Count());
        }
Пример #15
0
        // Add Monsters
        // Scale them to meet Character Strength...
        public void AddMonstersToRound()
        {
            // Check to see if the monster list is full, if so, no need to add more...
            if (MonsterList.Count() >= 6)
            {
                return;
            }


            // init monster scaling
            var ScaleLevelMax = 6;
            var ScaleLevelMin = 6;

            // scale based on game harder which is enabled by default
            if (GameGlobals.EnableGameHarder)
            {
                // Scale monsters based on round count.. higher round higher and stronger monsters
                if (BattleScore.RoundCount <= 1)
                {
                    ScaleLevelMax = 1;
                    ScaleLevelMin = 1;
                }
                if (BattleScore.RoundCount > 0 && BattleScore.RoundCount <= 2)
                {
                    ScaleLevelMax = 2;
                    ScaleLevelMin = 2;
                }

                if (BattleScore.RoundCount > 2 && BattleScore.RoundCount <= 4)
                {
                    ScaleLevelMax = 4;
                    ScaleLevelMin = 4;
                }

                if (BattleScore.RoundCount > 4 && BattleScore.RoundCount <= 8)
                {
                    ScaleLevelMax = 8;
                    ScaleLevelMin = 8;
                }


                if (BattleScore.RoundCount > 8 && BattleScore.RoundCount <= 16)
                {
                    ScaleLevelMax = 16;
                    ScaleLevelMin = 16;
                }
                if (BattleScore.RoundCount > 50)
                {
                    ScaleLevelMax = 20;
                    ScaleLevelMin = 20;
                }
            }

            else
            {
                ScaleLevelMax = 6;
                ScaleLevelMin = 6;
            }



            // Make Sure Monster List exists and is loaded...
            var myMonsterViewModel = MonstersViewModel.Instance;

            //myMonsterViewModel.ForceDataRefresh();

            if (myMonsterViewModel.Dataset.Count() > 0)
            {
                // Get 6 monsters based on the scaling that was set earlier and assign unique items to monster
                do
                {
                    var RndMon = HelperEngine.RollDice(1, myMonsterViewModel.Dataset.Count);

                    {
                        var mons = new Monster(myMonsterViewModel.Dataset[RndMon - 1]);

                        // Help identify which monster it is...
                        mons.Name += " " + (1 + MonsterList.Count()).ToString();


                        var rndScale = HelperEngine.RollDice(ScaleLevelMin, ScaleLevelMax);
                        mons.ScaleLevel(rndScale);


                        MonsterList.Add(mons);
                    }
                } while (MonsterList.Count() < 6);
            }
            else
            {
                // No monsters in DB, so add 6 new ones...
                for (var i = 0; i < 6; i++)
                {
                    var mon = new Monster();
                    // Help identify which monster it is...
                    mon.Name += " " + MonsterList.Count() + 1;

                    MonsterList.Add(mon);
                }
            }
        }
Пример #16
0
        // Add Monsters
        // Scale them to meet Character Strength...
        private void AddMonstersToRound()
        {
            // Check to see if the monster list is full, if so, no need to add more...
            if (MonsterList.Count() >= 6)
            {
                return;
            }

            // Make suure monster list exists and is loaded...
            var myMonsterViewModel = MonstersViewModel.Instance;

            //myMonsterViewModel.ForceDataRefresh();

            // Scale monsters based on current character levels
            if (myMonsterViewModel.Dataset.Count() > 0)
            {
                // Scale monsters to be within the range of the characters
                var ScaleLevelMax     = 1;
                var ScaleLevelMin     = 1;
                var ScaleLevelAverage = 1;

                // If there are any characters get min, max, and average levels of all of them
                if (CharacterList.Any())
                {
                    ScaleLevelMin     = GetMinCharacterLevel();
                    ScaleLevelMax     = GetMaxCharacterLevel();
                    ScaleLevelAverage = GetAverageCharacterLevel();
                }

                // Get 6 monsters
                do
                {
                    // Roll dice to get random monster from dataset
                    var rnd = HelperEngine.RollDice(1, myMonsterViewModel.Dataset.Count);
                    {
                        // Ensure rnd number is less than dataset size
                        if (rnd > myMonsterViewModel.Dataset.Count())
                        {
                            rnd = myMonsterViewModel.Dataset.Count();
                        }

                        // Create a new monster from the monster in the dataset
                        var monster = new Monster(myMonsterViewModel.Dataset[rnd - 1]);

                        // Scale the monster to be between the average level of the characters+1
                        var rndScale = HelperEngine.RollDice(1, ScaleLevelAverage + 1);

                        // Scale monster to be harder later...
                        monster.ScaleLevel(rndScale);

                        // Add monster to the list
                        MonsterList.Add(monster);
                    }
                } while (MonsterList.Count() < 6);
            }
            else
            {
                // No mosnters in DB, so add 6 new ones...
                for (var i = 0; i < 6; i++)
                {
                    var monster = new Monster();

                    // Help identify which monster it is....
                    monster.Name += " " + MonsterList.Count() + 1;

                    // Add monster to the list
                    MonsterList.Add(monster);
                }
            }

            // Debug output text for chosen monsters
            var monstersOutput = "Chosen monsters: \n";

            monstersOutput += "Count: " + MonsterList.Count() + "\n";;

            // Add name of each monster to debug output statement
            foreach (var mon in MonsterList)
            {
                monstersOutput += mon.FormatOutput() + "\n";
            }

            // Write the debug output statement
            Debug.WriteLine(monstersOutput);
        }
Пример #17
0
        /// <summary>
        /// 初始化怪
        /// </summary>
        public void LoadMonsters()
        {
            string fileName = string.Format("Config/Monsters.xml");

            XElement xml = GameManager.MonsterZoneMgr.AllMonstersXml;

            if (xml == null)
            {
                throw new Exception(string.Format("加载系统怪物配置文件:{0}, 失败。没有找到相关XML配置文件!", fileName));
            }

            XElement monsterXml = Global.GetSafeXElement(xml, "Monster", "ID", Code.ToString());

            //添加到怪物名称管理
            MonsterNameManager.AddMonsterName(Code, Global.GetSafeAttributeStr(monsterXml, "SName"));

            //首先根据地图编号定位地图文件

            fileName = string.Format("GuaiWu/{0}.xml",
                                     Global.GetSafeAttributeStr(monsterXml, "ResName"));

            string defaultFileName = string.Format("GuaiWu/ceshi_guaiwu.unity3d.xml");

            try
            {
                xml = XElement.Load(Global.ResPath(fileName));
            }
            catch (Exception)
            {
                xml = null;
            }

            if (null == xml)
            {
                LogManager.WriteLog(LogTypes.Info, string.Format("加载指定怪物的衣服文件:{0}, {1}, 失败。启用默认XML配置文件!", Global.GetSafeAttributeStr(monsterXml, "SName"), fileName));
                fileName = defaultFileName;

                xml = XElement.Load(Global.ResPath(fileName));
                if (null == xml)
                {
                    throw new Exception(string.Format("加载指定怪物的衣服代号:{0}, 失败。没有找到相关XML配置文件!", fileName));
                }
            }

            //先取子节点,便于获取
            XElement xmlFrameConfig = Global.GetSafeXElement(xml, "FrameConfig");
            XElement xmlSpeedConfig = Global.GetSafeXElement(xml, "SpeedConfig");
            double   moveSpeed      = Global.GetSafeAttributeDouble(xmlSpeedConfig, "UnitSpeed") / 100.0;

            double monsterSpeed = Global.GetSafeAttributeDouble(monsterXml, "MonsterSpeed"); //怪物移动的速度

            moveSpeed *= monsterSpeed;

            double maxLifeV  = (int)Global.GetSafeAttributeLong(monsterXml, "MaxLife");  //当前生命值
            double maxMagicV = (int)Global.GetSafeAttributeLong(monsterXml, "MaxMagic"); //当前魔法值

            if (maxLifeV <= 0)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("怪物部署的时,怪物的数据配置错误,生命值不能小于等于0: MonsterID={0}, MonsterName={1}",
                                                                  (int)Global.GetSafeAttributeLong(monsterXml, "ID"), Global.GetSafeAttributeStr(monsterXml, "SName")));

                return;
            }

            Monster monster = null;

            if (!IsFuBenMap) //如果不是副本地图
            {
                for (int i = 0; i < TotalNum; i++)
                {
                    //初始化怪物数据
                    monster = InitMonster(monsterXml, maxLifeV, maxMagicV, xmlFrameConfig, /*xmlPictureConfig, */ moveSpeed /*, speedTickList*/);
                    if (MonsterTypes.None == MonsterType)
                    {
                        MonsterType = (MonsterTypes)monster.MonsterType;
                    }

                    //加入当前区域队列
                    MonsterList.Add(monster);

                    //添加到全局的队列
                    GameManager.MonsterMgr.AddNewMonster(monster);
                }
            }
            else //如果是副本地图,则只生成一个怪物的样本
            {
                //初始化怪物数据
                monster = InitMonster(monsterXml, maxLifeV, maxMagicV, xmlFrameConfig, /*xmlPictureConfig, */ moveSpeed /*, speedTickList*/);
                if (MonsterTypes.None == MonsterType)
                {
                    MonsterType = (MonsterTypes)monster.MonsterType;
                }

                // SeedMonster = monster;
            }
        }
        /// <summary>
        /// Order the Players in Turn Sequence
        /// </summary>
        public List <PlayerInfoModel> OrderPlayerListByTurnOrder()
        {
            // Order is based by...
            // Order by Speed (Desending)
            // Then by Highest level (Descending)
            // Then by Highest Experience Points (Descending)
            // Then by Character before MonsterModel (enum assending)
            // Then by Alphabetic on Name (Assending)
            // Then by First in list order (Assending

            /*
             * Every 5th round, the sort order for turn order changes and list is sorted by Characters first,
             * then lowest health, then lowest speed.
             */
            if (BattleScore.RoundCount % 5 == 0)
            {
                PlayerList = PlayerList.OrderBy(a => a.PlayerType)
                             .ThenBy(a => a.CurrentHealth)
                             .ThenBy(a => a.Speed)
                             .ToList();
            }
            else
            {
                PlayerList = PlayerList.OrderByDescending(a => a.GetSpeed())
                             .ThenByDescending(a => a.Level)
                             .ThenByDescending(a => a.ExperienceTotal)
                             .ThenByDescending(a => a.PlayerType)
                             .ThenBy(a => a.Name)
                             .ThenBy(a => a.ListOrder)
                             .ToList();
            }

            /*
             * The first character in the player list gets their base Attack, Speed, Defense
             * values buffed by 2x for the time they are the first in the list.
             */
            int index = 0;

            var firstCharacter = PlayerList[index];
            int currentSpeed   = firstCharacter.Speed;
            int currentAttack  = firstCharacter.Attack;
            int currentDefense = firstCharacter.Defense;

            firstCharacter.Speed   = (currentSpeed * 2);
            firstCharacter.Attack  = (currentAttack * 2);
            firstCharacter.Defense = (currentDefense * 2);

            PlayerList[index] = firstCharacter;

            /*
             * Check the round number.  If it is round 13, then bad things happen to characters.
             * They will randomly drop items, loose heath, may even fall over dead.
             * You decide how unlucky their day will be.
             */
            if (BattleScore.RoundCount == 13)
            {
                foreach (PlayerInfoModel item in PlayerList)
                {
                    if (item.PlayerType == PlayerTypeEnum.Character)
                    {
                        item.CurrentHealth -= 13;
                    }
                }
            }
            int MaxLevel = 20;

            foreach (PlayerInfoModel monster in PlayerList)
            {
                if (BattleScore.RoundCount >= 100)
                {
                    monster.Level         = MaxLevel;
                    monster.Speed         = (monster.GetSpeed() * 10);
                    monster.Defense       = (monster.GetDefense() * 10);
                    monster.Attack        = (monster.GetAttack() * 10);
                    monster.CurrentHealth = (monster.CurrentHealth * 10);
                    monster.MaxHealth     = (monster.MaxHealth * 10);
                    MonsterList.Add(new PlayerInfoModel(monster));
                }
            }



            return(PlayerList);
        }
Пример #19
0
        // Add Monsters
        // Scale them to meet Character Strength...
        public void AddMonstersToRound()
        {
            // Check to see if the monster list is full, if so, no need to add more...
            if (MonsterList.Count() >= GameGlobals.MaxNumberPartyPlayers)
            {
                return;
            }

            // Make Sure Monster List exists and is loaded...
            var myMonsterViewModel = MonstersViewModel.Instance;

            if (myMonsterViewModel.Dataset.Count() > 0)
            {
                // Scale monsters to be within the range of the Characters

                var ScaleLevelMax     = 1;
                var ScaleLevelMin     = 1;
                var ScaleLevelAverage = 1;

                if (CharacterList.Any())
                {
                    ScaleLevelMax     = GetMaxCharacterLevel();
                    ScaleLevelMin     = GetMinCharacterLevel();
                    ScaleLevelAverage = GetAverageCharacterLevel();
                }

                // Get 6 monsters

                //IF BOSS BATTLE THIS CHANGES

                if (GameGlobals.BossBattles)
                {
                    //roll D100
                    //determine if BB are enabled
                    Random random     = new Random();
                    int    checkValue = random.Next(0, 100);
                    //determine if BB is enabled
                    if (checkValue < GameGlobals.BossBattleChance * 100)
                    {
                        //enable BB and the battle is a boss
                        //this is General Woundwort

                        var monster = new Monster(myMonsterViewModel.Dataset[0]);
                        monster.Name += " " + (1 + MonsterList.Count()).ToString();
                        // Scale the monster to be between the average level of the characters+1
                        //but bc its a boss make it stronger
                        var rndScale = HelperEngine.RollDice(1, ScaleLevelAverage + 4);
                        monster.ScaleLevel(rndScale);
                        MonsterList.Add(monster);
                    }
                    else
                    {
                        do
                        {
                            var rnd = HelperEngine.RollDice(1, myMonsterViewModel.Dataset.Count);
                            {
                                var monster = new Monster(myMonsterViewModel.Dataset[rnd - 1]);

                                // Help identify which monster it is...
                                monster.Name += " " + (1 + MonsterList.Count()).ToString();

                                // Scale the monster to be between the average level of the characters+1
                                var rndScale = HelperEngine.RollDice(1, ScaleLevelAverage + 1);
                                monster.ScaleLevel(rndScale);
                                MonsterList.Add(monster);
                            }
                        } while (MonsterList.Count() < GameGlobals.MaxNumberPartyPlayers);
                    }
                }
                else
                {
                    do
                    {
                        var rnd = HelperEngine.RollDice(1, myMonsterViewModel.Dataset.Count);
                        {
                            var monster = new Monster(myMonsterViewModel.Dataset[rnd - 1]);

                            // Help identify which monster it is...
                            monster.Name += " " + (1 + MonsterList.Count()).ToString();

                            // Scale the monster to be between the average level of the characters+1
                            var rndScale = HelperEngine.RollDice(1, ScaleLevelAverage);
                            monster.ScaleLevel(rndScale);
                            MonsterList.Add(monster);
                        }
                    } while (MonsterList.Count() < GameGlobals.MaxNumberPartyPlayers);
                }


                //// No monsters in DB, so add 6 new ones...
                //for (var i = 0; i < GameGlobals.MaxNumberPartyPlayers; i++)
                //{
                //    var item = new Monster();
                //    // Help identify which monster it is...
                //    item.Name += " " + MonsterList.Count() + 1;
                //    MonsterList.Add(item);
                //}
            }
        }