Exemplo n.º 1
0
        private Tile Create(Tile.TileType type)
        {
            //This method is used to create objects and also place them on the map.

            Tile tempTile   = null;
            int  randomX    = random.Next(1, mapWidth);
            int  randomY    = random.Next(1, mapHeight);
            int  gold       = random.Next(1, 6);
            int  heroHP     = 0;
            char heroSymbol = 'H';

            while (mapArray[randomX, randomY] != null)
            {
                randomX = random.Next(1, mapWidth);
                randomY = random.Next(1, mapHeight);
            }

            switch (type)
            {
            case Tile.TileType.Hero:
                tempTile = new Hero(randomX, randomY, heroHP, heroSymbol);
                break;

            case Tile.TileType.Enemy:
                //Q.3.1. Integrate the Gold and Mage classes into your existing GameEngine and Map classes.

                //Your Enemy array in map should now randomize between Goblins and Mages.
                int typeEnemy = random.Next(3);
                if (typeEnemy <= 1)
                {
                    tempTile = new Goblin(randomX, randomY);
                }
                else
                {
                    tempTile = new Mage(randomX, randomY);
                }

                break;

            case Tile.TileType.Gold:
                tempTile = new Gold(randomX, randomY);
                break;

            case Tile.TileType.Weapon:
                break;

            default:
                break;
            }
            mapArray[randomX, randomY] = tempTile;
            return(tempTile);
        }
Exemplo n.º 2
0
        private Tile Create(Tile.TileType type)
        {
            //This method is used to create objects and also place them on the map.

            random = new Random();
            Tile tempTile   = null;
            int  randomX    = random.Next(1, mapWidth - 1);
            int  randomY    = random.Next(1, mapHeight - 1);
            int  gold       = random.Next(1, 6);
            int  heroHP     = 0;
            char heroSymbol = 'H';

            while ((mapArray[randomX, randomY] is EmptyTile) == false)
            {
                randomX = random.Next(1, mapWidth);
                randomY = random.Next(1, mapHeight);
            }

            switch (type)
            {
            case Tile.TileType.Hero:
                tempTile = new Hero(randomX, randomY, heroHP, heroSymbol);
                break;

            case Tile.TileType.Enemy:

                //Integrate the Gold and Mage classes into your existing GameEngine and Map classes.

                //Your Enemy array in map should now randomize between Goblins, Mages and Leaders.

                int typeEnemy = random.Next(4);

                if (typeEnemy <= 1)
                {
                    tempTile = new Goblin(randomX, randomY);
                }
                else if (typeEnemy <= 2)
                {
                    tempTile = new Mage(randomX, randomY);
                }
                else if (typeEnemy <= 3)
                {
                    tempTile = new Leader(randomX, randomY);
                }
                break;

            case Tile.TileType.Gold:
                tempTile = new Gold(randomX, randomY);
                break;

            case Tile.TileType.Weapon:

                int typeWeapon = random.Next(4);

                if (typeWeapon <= 1)
                {
                    tempTile = new MeleeWeapon(randomX, randomY, 'D', MeleeWeapon.Types.Dagger);
                }
                else if (typeWeapon <= 2)
                {
                    tempTile = new MeleeWeapon(randomX, randomY, 'S', MeleeWeapon.Types.Longsword);
                }
                else if (typeWeapon <= 3)
                {
                    tempTile = new RangedWeapon(randomX, randomY, 'R', RangedWeapon.Types.Rifle);
                }
                else if (typeWeapon <= 4)
                {
                    tempTile = new RangedWeapon(randomX, randomY, 'B', RangedWeapon.Types.Longbow);
                }
                break;

            default:
                break;
            }
            mapArray[randomX, randomY] = tempTile;
            return(tempTile);
        }