Пример #1
0
        public bool Act(Monster monster, CommandSystem commandSystem)
        {
            DungeonMap map = RogueGame.DungeonMap;

            // Ooze only splits when wounded
            if (monster.Health >= monster.MaxHealth)
            {
                return(false);
            }

            int halfHealth = monster.MaxHealth / 2;

            if (halfHealth <= 0)
            {
                // Health would be too low so bail out
                return(false);
            }

            Cell cell = FindClosestUnoccupiedCell(map, monster.X, monster.Y);

            if (cell == null)
            {
                // No empty cells so bail out
                return(false);
            }

            // Make a new ooze with half the health of the old one
            Ooze newOoze = Monster.Clone(monster) as Ooze;

            if (newOoze != null)
            {
                newOoze.TurnsAlerted = 1;
                newOoze.X            = cell.X;
                newOoze.Y            = cell.Y;
                newOoze.MaxHealth    = halfHealth;
                newOoze.Health       = halfHealth;
                map.AddMonster(newOoze);
                RogueGame.MessageLog.Add($"{monster.Name} splits itself in two");
            }
            else
            {
                // Not an ooze so bail out
                return(false);
            }

            // Halve the original ooze's health too
            monster.MaxHealth = halfHealth;
            monster.Health    = halfHealth;

            return(true);
        }
Пример #2
0
        public static Monster CreateMonster(int level, Point location)
        {
            Pool <Monster> monsterPool = new Pool <Monster>();

            monsterPool.Add(Kobold.Create(level), 25);
            monsterPool.Add(Ooze.Create(level), 25);
            monsterPool.Add(Goblin.Create(level), 50);

            Monster monster = monsterPool.Get();

            monster.X = location.X;
            monster.Y = location.Y;

            return(monster);
        }
Пример #3
0
        //Create some Monsters and place them
        private void CreateMonsters()
        {
            int numMonsters = 30;

            Random rndNum = new Random();

            //Spawn numMonsters at random points on the map
            for (int i = 0; i < numMonsters; i++)
            {
                int     monsterPosition = 0;
                Monster newMonster      = new Ooze();
                //If the monster is in a wall, randomly move it until it isn't
                while (CurrentMap.Tiles[monsterPosition].IsBlockingMove)
                {
                    monsterPosition = rndNum.Next(0, CurrentMap.Width * CurrentMap.Height);
                }

                //Set the position of the new monster and add it to the entities
                newMonster.Position = new Point(monsterPosition & CurrentMap.Width, monsterPosition / CurrentMap.Width);
                GameLoop.EntityManager.Entities.Add(newMonster);
            }
        }
 public MorgA()
 {
     moveBehavior = new Ooze();
 }