Пример #1
0
        // Create some random monsters with random attack and defense values
        // and drop them all over the map in
        // random places.
        private void CreateMonsters()
        {
            // number of monsters to create
            int numMonsters = 10;

            // Create several monsters and
            // pick a random position on the map to place them.
            // check if the placement spot is blocking (e.g. a wall)
            // and if it is, try a new position
            for (int i = 0; i < numMonsters; i++)
            {
                int     monsterPosition = 0;
                NonHero newMonster      = new NonHero(Color.Blue, Color.Transparent);
                while (CurrentMap.Tiles[monsterPosition].IsBlockingMovement)
                {
                    // pick a random spot on the map
                    monsterPosition = rndNum.Next(0, CurrentMap.Width * CurrentMap.Height);
                }

                // plug in some magic numbers for attack and defense values
                newMonster.Defense       = rndNum.Next(0, 10);
                newMonster.DefenseChance = rndNum.Next(0, 50);
                newMonster.Attack        = rndNum.Next(0, 10);
                newMonster.AttackChance  = rndNum.Next(0, 50);
                newMonster.Name          = "Orc";

                // Set the monster's new position
                // Note: this fancy math will be replaced by a new helper method
                // in the next revision of SadConsole
                newMonster.Position = new Point(monsterPosition % CurrentMap.Width, monsterPosition / CurrentMap.Width);
                CurrentMap.Add(newMonster);
            }
        }
Пример #2
0
 public DefensiveState(NonHero enemy)
 {
     this.enemy = enemy;
 }
Пример #3
0
 public AggresiveState(NonHero enemy)
 {
     this.enemy = enemy;
 }
Пример #4
0
 public FleeingState(NonHero enemy)
 {
     this.enemy = enemy;
 }