Exemplo n.º 1
0
        public World GenerateWorld()
        {
            _world.Initialize(_width, _height);
            var rand = new Random();

            for (int x = 0; x < _width; x++)
            {
                for (int y = 0; y < _height; y++)
                {
                    //TODO Change isexplored to false. For now it is set to true for testing!
                    if (rand.Next(0, 7) < 6)
                    {
                        var plains = new Plains(x, y, _world.GetCell(x, y));
                        _world.SetTileProperty(plains, x, y, false, true, true);
                    }
                    else
                    {
                        var mount = new Mountain(x, y, _world.GetCell(x, y));
                        _world.SetTileProperty(mount, x, y, false, true, true);
                    }
                }
            }

            GenerateOceans();

            return(_world);
        }
Exemplo n.º 2
0
        public void TestPlainsAddGetUpdateDelete()
        {
            //Add-Get-Тест
            int numberOfSeats = 20;

            Plains expectedPlains = new Plains();

            expectedPlains.NumberOfSeats = numberOfSeats;

            DataAccessPlains plains = new DataAccessPlains();

            plains.AddElement(expectedPlains);
            var actualPLains = plains.GetAll().Last();

            Assert.AreEqual(expectedPlains, actualPLains);

            //Update - Тест
            expectedPlains = actualPLains;
            expectedPlains.NumberOfSeats = 30;
            plains.UpdateElement(expectedPlains);
            actualPLains = plains.GetElement(expectedPlains.CodePlane);
            Assert.AreEqual(expectedPlains, actualPLains);

            //Delete-Тест
            int expectedCount = plains.GetAll().Count() - 1;

            plains.DeleteElement(actualPLains);
            int actualCount = plains.GetAll().Count();

            Assert.AreEqual(expectedCount, actualCount);
        }
Exemplo n.º 3
0
        private static Location GetTile(int x, int y)
        {
            Location result = null;

            switch (RngThreadSafe.Next(1, 3))
            {
            case 1: result = new Forest(x, y); break;

            case 2: result = new Plains(x, y); break;

            default: result = new Lake(x, y); break;
            }
            return(result);
        }
Exemplo n.º 4
0
            public override void Create()
            {
                Name = "EastEarth";
                var island  = new Island();
                var forest  = new Forest();
                var plains1 = new Plains();
                var plains2 = new Plains();

                Areas = new Area[]
                {
                    island, forest, plains1, plains2
                };

                foreach (var area in Areas)
                {
                    area.Create();
                }
            }
        private void generateGeography()
        {
            List <double> heightArr = new List <double>();

            foreach (double[] row in myHeightMap)
            {
                foreach (double d in row)
                {
                    heightArr.Add(d);
                }
            }

            heightArr.Sort();

            double waterline = heightArr[(int)(heightArr.Count * WATER_LEVEL)];
            double treeline  = heightArr[(int)(heightArr.Count * TREE_LINE)];
            double hillline  = heightArr[(int)(heightArr.Count * HILL_LINE)];

            for (int i = 0; i < myHeightMap[0].Length; i++)
            {
                for (int j = 0; j < myHeightMap.Length; j++)
                {
                    double temp = myHeightMap[i][j];

                    // create geography types
                    if (temp < waterline)
                    {
                        myTerrain[i][j] = new Water(temp);
                    }
                    else if (temp > hillline && temp < treeline)
                    {
                        myTerrain[i][j] = new Hill(temp);
                    }
                    else if (temp > treeline)
                    {
                        myTerrain[i][j] = new Mountain(temp);
                    }
                    else
                    {
                        myTerrain[i][j] = new Plains(temp);
                    }
                }
            }
        }
Exemplo n.º 6
0
            public override void Create()
            {
                Name = "MiddleEarth";
                var island   = new Island();
                var forest   = new Forest();
                var swamp    = new Swamp();
                var mountain = new Mountain();
                var plains   = new Plains();

                Areas = new Area[]
                {
                    island, forest, swamp, mountain, plains
                };

                foreach (var area in Areas)
                {
                    area.Create();
                }
            }
Exemplo n.º 7
0
        private void LoadMap(Bytemap bitmap)
        {
            _tiles = new ITile[WIDTH, HEIGHT];

            for (int x = 0; x < WIDTH; x++)
            {
                for (int y = 0; y < HEIGHT; y++)
                {
                    ITile tile;
                    bool  special = TileIsSpecial(x, y);
                    switch (bitmap[x, y])
                    {
                    case 2: tile = new Forest(x, y, special); break;

                    case 3: tile = new Swamp(x, y, special); break;

                    case 6: tile = new Plains(x, y, special); break;

                    case 7: tile = new Tundra(x, y, special); break;

                    case 9: tile = new River(x, y); break;

                    case 10: tile = new Grassland(x, y); break;

                    case 11: tile = new Jungle(x, y, special); break;

                    case 12: tile = new Hills(x, y, special); break;

                    case 13: tile = new Mountains(x, y, special); break;

                    case 14: tile = new Desert(x, y, special); break;

                    case 15: tile = new Arctic(x, y, special); break;

                    default: tile = new Ocean(x, y, special); break;
                    }
                    _tiles[x, y] = tile;
                }
            }
        }
Exemplo n.º 8
0
        public void ChangeTileType(int x, int y, Terrain type)
        {
            bool special  = TileIsSpecial(x, y);
            bool road     = _tiles[x, y].Road;
            bool railRoad = _tiles[x, y].RailRoad;

            switch (type)
            {
            case Terrain.Forest: _tiles[x, y] = new Forest(x, y, special); break;

            case Terrain.Swamp: _tiles[x, y] = new Swamp(x, y, special); break;

            case Terrain.Plains: _tiles[x, y] = new Plains(x, y, special); break;

            case Terrain.Tundra: _tiles[x, y] = new Tundra(x, y, special); break;

            case Terrain.River: _tiles[x, y] = new River(x, y); break;

            case Terrain.Grassland1:
            case Terrain.Grassland2: _tiles[x, y] = new Grassland(x, y); break;

            case Terrain.Jungle: _tiles[x, y] = new Jungle(x, y, special); break;

            case Terrain.Hills: _tiles[x, y] = new Hills(x, y, special); break;

            case Terrain.Mountains: _tiles[x, y] = new Mountains(x, y, special); break;

            case Terrain.Desert: _tiles[x, y] = new Desert(x, y, special); break;

            case Terrain.Arctic: _tiles[x, y] = new Arctic(x, y, special); break;

            case Terrain.Ocean: _tiles[x, y] = new Ocean(x, y, special); break;
            }
            _tiles[x, y].Road     = road;
            _tiles[x, y].RailRoad = railRoad;
        }
Exemplo n.º 9
0
        private void MergeElevationAndLatitude(int[,] elevation, int[,] latitude)
        {
            Log("Map: Stage 3 - Merge elevation and latitude into the map");

            // merge elevation and latitude into the map
            for (int y = 0; y < HEIGHT; y++)
            {
                for (int x = 0; x < WIDTH; x++)
                {
                    bool special = TileIsSpecial(x, y);
                    switch (elevation[x, y])
                    {
                    case 0: _tiles[x, y] = new Ocean(x, y, special); break;

                    case 1:
                    {
                        switch (latitude[x, y])
                        {
                        case 0: _tiles[x, y] = new Desert(x, y, special); break;

                        case 1: _tiles[x, y] = new Plains(x, y, special); break;

                        case 2: _tiles[x, y] = new Tundra(x, y, special); break;

                        case 3: _tiles[x, y] = new Arctic(x, y, special); break;
                        }
                    }
                    break;

                    case 2: _tiles[x, y] = new Hills(x, y, special); break;

                    default: _tiles[x, y] = new Mountains(x, y, special); break;
                    }
                }
            }
        }
Exemplo n.º 10
0
    public static MapCell create_cell(int ID, int tier, Tile tile, Pos pos)
    {
        MapCell mc = null;

        // Don't extract name from tile if provided.
        if (ID == PLAINS_ID)
        {
            mc = new Plains(tier, tile, pos);
        }
        else if (ID == FOREST_ID)
        {
            mc = new Forest(tier, tile, pos);
        }
        else if (ID == RUINS_ID)
        {
            mc = new Ruins(tier, tile, pos);
        }
        else if (ID == CLIFF_ID)
        {
            mc = new Cliff(tier, tile, pos);
        }
        else if (ID == CAVE_ID)
        {
            mc = new Cave(tier, tile, pos);
        }
        else if (ID == STAR_ID)
        {
            mc = new Star(tier, tile, pos);
        }
        else if (ID == TITRUM_ID)
        {
            mc = new Titrum(tier, tile, pos);
        }
        else if (ID == LUSH_LAND_ID)
        {
            mc = new LushLand(tier, tile, pos);
            //} else if (name == MIRE) {
            //mc = new Mire(tier, tile, pos);
        }
        else if (ID == MOUNTAIN_ID)
        {
            mc = new Mountain(tier, tile, pos);
        }
        else if (ID == SETTLEMENT_ID)
        {
            mc = new Settlement(tier, tile, pos);
        }
        else if (ID == RUNE_GATE_ID)
        {
            mc = new RuneGate(tier, tile, pos);
        }
        else if (ID == CITY_ID)
        {
            mc = new CityCell(tier, tile, pos);
        }
        else if (ID == GUARDIAN_PASS_ID)
        {
            mc = new GuardianPass(tier, tile, pos);
        }
        else if (ID == CITY_ID)
        {
            mc = new CityCell(tier, tile, pos);
        }
        else
        {
            mc = new MapCell(0, tier, tile, pos);
        }
        //mc.tile_type_ID = tile_type_ID;
        return(mc);
    }
Exemplo n.º 11
0
        private void Create()
        {
#if DEBUG
            Debugger.Log(1, "Main", "Started initialization phase.\n");
#endif
            Rectangle window = new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            sky = new Sky(skyTex, window);
            yat = new Yat(yatClimbing, yatRunning, yatSmashing, yatFalling, snapEffect, window);
            BlockManager blockManager = new BlockManager(ground3Tex, ground2Tex, ground1Tex, ladder, window);
            level      = new Level(blockManager, window);
            experience = new Experiencebar(yat, cage, xpBar, button14, new Vector2(50, window.Height - 50), new Resize(DockType.LowerLeft, new Vector2(cage.Width, cage.Height), new Vector2(25)), 0, 100, AmountType.AmountAndTotal);
            XPManager       xpManager = new XPManager(yat, experience, xpOrb, xpEffect);
            MushroomFactory mgen      = new MushroomFactory(mushroomSheet, fireballSheet, Mushroom.Size, level, yat, flameEffect, squashEffect, xpManager, window);
            CoinFactory     cgen      = new CoinFactory(level, yat, coin, coinEffect, window);
            BirdFactory     bgen      = new BirdFactory(level, yat, birdSheet, hawkEffect, xpManager, window);
            PotionManager   pmanager  = new PotionManager(yat, (Experiencebar)experience, new Texture2D[] { potionRed, potionGreen, potionBlue, potionYellow }, potionEffect, 20);
            yat.Init(level, pmanager);
            Plains hillzone = new Plains(ground3Tex, ground2Tex, ground1Tex, ladder, 2, 7, Rand.Next(10, 20), window);
            level.Init(new IFactory <ILevelObject>[] { cgen }, new IFactory <IEntity>[] { mgen, bgen }, new ITerrain[] { hillzone });
            fpsCounter    = new FPSCounter(new Vector2(10), new Resize(new Vector2(10)), window, button14, Color.Black);
            score         = new Score(new Vector2(0, 10), new Resize(new Vector2(2, 0), new Vector2(0, 35)), window, button36, Color.Black);
            gameoverLabel = new Button(new Vector2(0, window.Height / 3), new Resize(new Vector2(2, 3), new Vector2(0, 0)), window, "Game over", button72, true, Color.Black, Color.Black, false, null, tint);
            mainMenuLabel = new Button(new Vector2(0, window.Height / 3 + 100), new Resize(new Vector2(2, 3), new Vector2(0, 100)), window, "Main menu", button36, true, Color.Black, Color.Red, true, new Request(0, 2,
                                                                                                                                                                                                                   delegate()
            {
                Actions.Gameover = false;
                Score.Points     = 0;
            }));
            soundButton = new ImageButton(new Vector2(window.Width - 50, 20), new Resize(DockType.UpperRight, new Vector2(soundLoud.Width, soundLoud.Height), new Vector2(50, 20)), new Action[] {
                delegate()
                {
                    Settings.PlaySounds = false;
                    MediaPlayer.IsMuted = true;
                },
                delegate()
                {
                    Settings.PlaySounds = true;
                    MediaPlayer.IsMuted = false;
                }
            },
                                          window,
                                          null,
                                          false,
                                          soundLoud,
                                          soundMute);

            playPauseButton = new ImageButton(new Vector2(window.Width - 120, 20), new Resize(DockType.UpperRight, new Vector2(pauseButton.Width, pauseButton.Height), new Vector2(120, 20)), new Request[] {
                new Request(1, 2),
                new Request(3, 2)
            },
                                              window,
                                              'P',
                                              true,
                                              pauseButton,
                                              playButton);
            healthbar = new Healthbar(yat, cage, healthBar, button14, new Vector2(window.Width - 200, window.Height - 50), new Resize(DockType.LowerRight, new Vector2(cage.Width, cage.Height), new Vector2(25)), Yat.health, Yat.health, AmountType.Percentage);
            clock     = new Clock(button36, new Vector2(window.Width / 2, 75), new Resize(new Vector2(2, 0), new Vector2(0, 75)), Color.Black, window);
            gameplay  = new Screen(1, new IButton[] { fpsCounter, score, clock, soundButton, playPauseButton, healthbar, experience }, new IObject[] { sky, level, yat }, gameplaySong, true);
            Button title      = new Button(new Vector2(0, window.Height / 3), new Resize(new Vector2(2, 3), new Vector2(0)), window, "Yat Sprint", button72, true, Color.Black, Color.DimGray, false, null);
            Button play       = new Button(new Vector2(0, window.Height / 3 + 100), new Resize(new Vector2(2, 3), new Vector2(0, 100)), window, "Play", button36, true, Color.Black, Color.DimGray, true, new Request(1, 1));
            Button fullscreen = new Button(new Vector2(0, window.Height / 3 + 150), new Resize(new Vector2(2, 3), new Vector2(0, 150)), window, "Fullscreen", button36, true, Color.Black, Color.DimGray, true, new Request(-1, 1, delegate()
            {
                if (graphics.IsFullScreen)
                {
                    graphics.PreferredBackBufferWidth  = 800;
                    graphics.PreferredBackBufferHeight = 600;
                    graphics.ApplyChanges();
                }
                else
                {
                    graphics.PreferredBackBufferWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                    graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
                    graphics.ApplyChanges();
                }
                display.UpdateWindow(new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight));
                Actions.ToggleFullscreen = true;
            }));
            Button exit = new Button(new Vector2(0, window.Height / 3 + 200), new Resize(new Vector2(2, 3), new Vector2(0, 200)), window, "Exit", button36, true, Color.Black, Color.DimGray, true, new Request(-1, 1, delegate()
            {
                Actions.Exitgame = true;
            }));

            Button motd = new Button(new Vector2(window.Width / 2 + 250, window.Width / 3 + 10), new Resize(new Vector2(2, 3), new Vector2(250, 25)), window, Messages[Rand.Next(Messages.Length)], button14, false, Color.Black, Color.Black, false, null);
            motd.SetRotation(Rand.Next(-45, -20));
            titleScreen = new Screen(0, new IButton[] { fpsCounter, soundButton, title, motd, play, fullscreen, exit }, new IObject[] { sky }, mainmenuSong, true);
            gameover    = new Screen(2, new IButton[] { fpsCounter, score, soundButton, gameoverLabel, mainMenuLabel }, new IObject[] { sky }, gameplaySong, true);
            Button pauseTitle    = new Button(new Vector2(0, window.Height / 3), new Resize(new Vector2(2, 3), new Vector2(0)), window, "Paused", button72, true, Color.Black, Color.Black, false, null, tint);
            Button resumeButton  = new Button(new Vector2(0, window.Height / 3 + 100), new Resize(new Vector2(2, 3), new Vector2(0, 100)), window, "Resume", button36, true, Color.Black, Color.Gray, true, new Request(1, 2));
            Button mainMenuPause = new Button(new Vector2(0, window.Height / 3 + 150), new Resize(new Vector2(2, 3), new Vector2(0, 150)), window, "Main Menu", button36, true, Color.Black, Color.Gray, true, new Request(0, 2));
            paused  = new Screen(3, new IButton[] { fpsCounter, score, soundButton, playPauseButton, pauseTitle, resumeButton, mainMenuPause }, new IObject[] { sky }, gameplaySong, false);
            display = new Display();
            display.Add(gameplay);
            display.Add(titleScreen);
            display.Add(gameover);
            display.Add(paused);

            MediaPlayer.Play(mainmenuSong);

#if DEBUG
            Debugger.Log(1, "Main", "Finished initialization phase.\n");
#endif
        }
    void Generate(string[] tokens)
    {
        int terrainHeight = int.Parse(tokens[0]);
        int terrainWidth  = int.Parse(tokens[1]);

        Terrain[][] allTiles;
        allTiles = new Terrain[terrainHeight][];

        Terrain.allTiles      = allTiles;
        Terrain.terrainHeight = terrainHeight;
        Terrain.terrainWidth  = terrainWidth;

        for (int height = 0; height < terrainHeight; height++)
        {
            allTiles[height] = new Terrain[terrainWidth];
            for (int width = 0; width < terrainWidth; width++)
            {
                int tokenPos = height * terrainWidth + width + 2;
                if (tokens[tokenPos] == "p") // planice
                {
                    allTiles[height][width] = new Plains(width, height);
                }
                else if (tokens[tokenPos] == "f") // floresta
                {
                    allTiles[height][width] = new Forest(width, height);
                }
                else if (tokens[tokenPos] == "m") // montanha, impassavel
                {
                    allTiles[height][width] = new Mountain(width, height);
                }
                else if (tokens[tokenPos] == "r") // rio
                {
                    allTiles[height][width] = new River(width, height);
                }
                else if (tokens[tokenPos] == "t") // fortaleza
                {
                    allTiles[height][width] = new Fortress(width, height);
                }
                else
                {
                    Debug.Log(tokens[tokenPos]);
                }
            }
        }
        for (int aux = terrainHeight * terrainWidth + 2; aux < tokens.Length; aux += 5)
        {
            int y    = int.Parse(tokens[aux + 3]);
            int x    = int.Parse(tokens[aux + 4]);
            int team = int.Parse(tokens[aux + 2]);
            int race = int.Parse(tokens[aux + 1]);

            if (tokens[aux] == "s") // escudeiro
            {
                if (race == 0)
                {
                    new HumanSoldier(x, y, team);
                }
                else
                {
                    new UndeadSoldier(x, y, team);
                }
            }
            else if (tokens[aux] == "a") // archer
            {
                if (race == 0)
                {
                    new HumanArcher(x, y, team);
                }
                else
                {
                    new UndeadArcher(x, y, team);
                }
            }
            else if (tokens[aux] == "t")// siege
            {
                if (race == 0)
                {
                    new HumanSiege(x, y, team);
                }
                else
                {
                    new UndeadSiege(x, y, team);
                }
            }
            else if (tokens[aux] == "k") // knight
            {
                if (race == 0)
                {
                    new HumanKnight(x, y, team);
                }
                else
                {
                    new UndeadKnight(x, y, team);
                }
            }
            else if (tokens[aux] == "h") // hero
            {
                if (race == 0)
                {
                    new HumanHero(x, y, team);
                }
                else
                {
                    new UndeadHero(x, y, team);
                }
            }
        }
        Camera.main.GetComponent <cameraControl>().middleCamera();
    }
Exemplo n.º 13
0
        private void GenerateRectangleIsland(Rectangle island)
        {
            var random   = new Random();
            int distance = 1;
            var tiles    = _world.GetTilesInRectangle(island);

            foreach (var tile in tiles)
            {
                //
                if (tile.Y > _world.Height - 5)
                {
                    var winter = new Tundra(tile.X, tile.Y, tile.Cell);
                    _world.SetTileProperty(winter, tile.X, tile.Y, true, true, false);
                }
                else if (tile.Y > _world.Height - 10)
                {
                    var desert = new Dessert(tile.X, tile.Y, tile.Cell);
                    _world.SetTileProperty(desert, tile.X, tile.Y, true, true, false);
                }
                else if (tile.Y < 5)
                {
                    var winter = new Tundra(tile.X, tile.Y, tile.Cell);
                    _world.SetTileProperty(winter, tile.X, tile.Y, true, true, false);
                }
                else if (tile.Y < 10)
                {
                    var desert = new Dessert(tile.X, tile.Y, tile.Cell);
                    _world.SetTileProperty(desert, tile.X, tile.Y, true, true, false);
                }
                else
                {
                    var tileType = random.Next(0, 99);
                    if (tileType < 30)
                    {
                        var plains = new Plains(tile.X, tile.Y, tile.Cell);
                        _world.SetTileProperty(plains, tile.X, tile.Y, true, true, false);
                    }
                    else if (tileType < 50)
                    {
                        var Forest = new Plains(tile.X, tile.Y, tile.Cell);
                        _world.SetTileProperty(Forest, tile.X, tile.Y, true, true, false);
                    }
                    else if (tileType < 65)
                    {
                        var hill = new Hills(tile.X, tile.Y, tile.Cell);
                        _world.SetTileProperty(hill, tile.X, tile.Y, true, true, false);
                    }
                    else if (tileType < 75)
                    {
                        var mountain = new Mountain(tile.X, tile.Y, tile.Cell);
                        _world.SetTileProperty(mountain, tile.X, tile.Y, true, true, false);
                    }
                    else if (tileType < 90)
                    {
                        var marsh = new Marsh(tile.X, tile.Y, tile.Cell);
                        _world.SetTileProperty(marsh, tile.X, tile.Y, true, true, false);
                    }
                    else
                    {
                        var plain = new Plains(tile.X, tile.Y, tile.Cell);
                        _world.SetTileProperty(plain, tile.X, tile.Y, true, true, false);
                    }
                }
            }

            var beachTiles =
                _world.GetTilesAlongLine(island.Left - distance, island.Top - distance, island.Right, island.Top - distance).ToList();

            beachTiles.
            AddRange(_world.GetTilesAlongLine(island.Left - distance, island.Bottom, island.Right, island.Bottom));
            beachTiles.
            AddRange(_world.GetTilesAlongLine(island.Left - distance, island.Top - distance, island.Left - distance, island.Bottom));
            beachTiles.
            AddRange(_world.GetTilesAlongLine(island.Right, island.Top - distance, island.Right, island.Bottom));
            foreach (var t in beachTiles)
            {
                var coast = new Coast(t.X, t.Y, t.Cell);
                _world.SetTileProperty(coast, t.X, t.Y, true, true, false);
            }
        }
Exemplo n.º 14
0
 public override void RemoveFightComponent(FightComponent component)
 {
     Plains.Remove(component);
 }
Exemplo n.º 15
0
 public override void AddFightComponent(FightComponent component)
 {
     Plains.Add(component);
 }
Exemplo n.º 16
0
        private void AgeAdjustments()
        {
            Log("Map: Stage 5 - Age adjustments");

            int x         = 0;
            int y         = 0;
            int ageRepeat = (int)(((float)800 * (1 + _age) / (80 * 50)) * (WIDTH * HEIGHT));

            for (int i = 0; i < ageRepeat; i++)
            {
                if (i % 2 == 0)
                {
                    x = Common.Random.Next(WIDTH);
                    y = Common.Random.Next(HEIGHT);
                }
                else
                {
                    switch (Common.Random.Next(8))
                    {
                    case 0: { x--; y--; break; }

                    case 1: { y--; break; }

                    case 2: { x++; y--; break; }

                    case 3: { x--; break; }

                    case 4: { x++; break; }

                    case 5: { x--; y++; break; }

                    case 6: { y++; break; }

                    default: { x++; y++; break; }
                    }
                    if (x < 0)
                    {
                        x = 1;
                    }
                    if (y < 0)
                    {
                        y = 1;
                    }
                    if (x >= WIDTH)
                    {
                        x = WIDTH - 2;
                    }
                    if (y >= HEIGHT)
                    {
                        y = HEIGHT - 2;
                    }
                }

                bool special = TileIsSpecial(x, y);
                switch (_tiles[x, y].Type)
                {
                case Terrain.Forest: _tiles[x, y] = new Jungle(x, y, special); break;

                case Terrain.Swamp: _tiles[x, y] = new Grassland(x, y); break;

                case Terrain.Plains: _tiles[x, y] = new Hills(x, y, special); break;

                case Terrain.Tundra: _tiles[x, y] = new Hills(x, y, special); break;

                case Terrain.River: _tiles[x, y] = new Forest(x, y, special); break;

                case Terrain.Grassland1:
                case Terrain.Grassland2: _tiles[x, y] = new Forest(x, y, special); break;

                case Terrain.Jungle: _tiles[x, y] = new Swamp(x, y, special); break;

                case Terrain.Hills: _tiles[x, y] = new Mountains(x, y, special); break;

                case Terrain.Mountains:
                    if ((x == 0 || _tiles[x - 1, y - 1].Type != Terrain.Ocean) &&
                        (y == 0 || _tiles[x + 1, y - 1].Type != Terrain.Ocean) &&
                        (x == (WIDTH - 1) || _tiles[x + 1, y + 1].Type != Terrain.Ocean) &&
                        (y == (HEIGHT - 1) || _tiles[x - 1, y + 1].Type != Terrain.Ocean))
                    {
                        _tiles[x, y] = new Ocean(x, y, special);
                    }
                    break;

                case Terrain.Desert: _tiles[x, y] = new Plains(x, y, special); break;

                case Terrain.Arctic: _tiles[x, y] = new Mountains(x, y, special); break;
                }
            }
        }
Exemplo n.º 17
0
        private void ClimateAdjustments()
        {
            Log("Map: Stage 4 - Climate adjustments");

            int wetness, latitude;

            for (int y = 0; y < HEIGHT; y++)
            {
                int yy = (int)(((float)y / HEIGHT) * 50);

                wetness  = 0;
                latitude = Math.Abs(25 - yy);

                for (int x = 0; x < WIDTH; x++)
                {
                    if (_tiles[x, y].Type == Terrain.Ocean)
                    {
                        // wetness yield
                        int wy = latitude - 12;
                        if (wy < 0)
                        {
                            wy = -wy;
                        }
                        wy += (_climate * 4);

                        if (wy > wetness)
                        {
                            wetness++;
                        }
                    }
                    else if (wetness > 0)
                    {
                        bool special  = TileIsSpecial(x, y);
                        int  rainfall = Common.Random.Next(7 - (_climate * 2));
                        wetness -= rainfall;

                        switch (_tiles[x, y].Type)
                        {
                        case Terrain.Plains: _tiles[x, y] = new Grassland(x, y); break;

                        case Terrain.Tundra: _tiles[x, y] = new Arctic(x, y, special); break;

                        case Terrain.Hills: _tiles[x, y] = new Forest(x, y, special); break;

                        case Terrain.Desert: _tiles[x, y] = new Plains(x, y, special); break;

                        case Terrain.Mountains: wetness -= 3; break;
                        }
                    }
                }

                wetness  = 0;
                latitude = Math.Abs(25 - yy);

                // reset row wetness to 0
                for (int x = WIDTH - 1; x >= 0; x--)
                {
                    if (_tiles[x, y].Type == Terrain.Ocean)
                    {
                        // wetness yield
                        int wy = (latitude / 2) + _climate;
                        if (wy > wetness)
                        {
                            wetness++;
                        }
                    }
                    else if (wetness > 0)
                    {
                        bool special  = TileIsSpecial(x, y);
                        int  rainfall = Common.Random.Next(7 - (_climate * 2));
                        wetness -= rainfall;

                        switch (_tiles[x, y].Type)
                        {
                        case Terrain.Swamp: _tiles[x, y] = new Forest(x, y, special); break;

                        case Terrain.Plains: new Grassland(x, y); break;

                        case Terrain.Grassland1:
                        case Terrain.Grassland2: _tiles[x, y] = new Jungle(x, y, special); break;

                        case Terrain.Hills: _tiles[x, y] = new Forest(x, y, special); break;

                        case Terrain.Mountains: _tiles[x, y] = new Forest(x, y, special); wetness -= 3; break;

                        case Terrain.Desert: _tiles[x, y] = new Plains(x, y, special); break;
                        }
                    }
                }
            }
        }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            {
/* Welkom bij Simple Adventure
 * Hier zie je een raamwerk van een text based rpg
 * De classes en subclasses zijn al aangemaakt, subclasses staan in de mapjes
 * Aan jou de taak om hier een invulling aan te geven!
 * Wat moet je laten zien:
 *  - Dat je OOP beheerst
 *  - Dat je inheritance beheerst
 *  - Dat je in staat bent om output naar de console te krijgen op basis van de classes
 *  - Het hoeft geen volledig spel te zijn, maar het moet iets doen en het moet werken
 *  - En natuurlijk op de juiste manier in elkaar zitten
 * Waar scoor ik bonuspunten mee:
 *  - Gebruik polymorphism d.m.v. virtual methods en/of verschillende constructors (bijvoorbeeld subclasses)
 *  - Je hebt een speelbare game gemaakt
 *  - Je hebt zinvolle en werkende uitbreidingen gemaakt op het raamwerk
 * Kwaliteit gaat boven kwantiteit, ga pas uitbreiden als je basis goed is
 * Werk alleen: als ik bij twee personen dezelfde code zie, krijgen jullie allebei een onvoldoende
 * Gebruik comments ten overvloede! Leg uit wat je doet! Hoe de comments kort, duidelijk en volledig!
 */
            }

            Player player;

            Forest forest = new Forest();
            Swamp  swamp  = new Swamp();
            Plains plains = new Plains();

            Direwolf wolf   = new Direwolf();
            Goblin   goblin = new Goblin();
            Orc      orc    = new Orc();

            Chest   chest = new Chest();
            Diamond dia   = new Diamond();
            Key     key   = new Key();

            int    userNumber;
            string tempName;

            //creating player
            #region playerSetup
            Console.WriteLine("Greeting new player");
            Console.WriteLine("Welcome to SimpelAdventure");
            Console.ReadLine();

            Console.WriteLine("What is your name?");
            tempName = Console.ReadLine();

            Console.WriteLine("Choose a class!");
            Console.WriteLine("1. Babarian: You like hitting people with sharp stuff || 2. Sorcerer: You like hitting stuff but with lighting");
            userNumber = makeDecision(2);


            if (userNumber == 1)
            {
                player = new Barbarian(tempName);
            }
            else
            {
                player = new Sorcerer(tempName);
            }

            Console.Clear();

            Console.WriteLine("Your name is " + player.name);
            Console.WriteLine("You Choose class " + player.classname);

            Console.ReadLine();
            Console.Clear();
            #endregion

            Console.Clear();
            do
            {
                //end the game if you find both key and chest
                if (key.hasItem && chest.hasItem)
                {
                    dia.hasItem = true;
                    Console.WriteLine("You use the key on the chest and you find a diamond!");
                    Console.WriteLine("This mean you won the game for some reason");
                    Console.WriteLine("Thanks for playing the game");
                    Console.ReadLine();
                }
                else
                {
                    Console.WriteLine("Choose where you want to go");
                    Console.WriteLine("1. Church: For your healling needs 2. Forest: Lots of murder puppies\n3. Plains: Boring place nothing special 4. Swamp: What are you doing here!");
                    userNumber = makeDecision(4);

                    switch (userNumber)
                    {
                    case 1:
                        EnterChurch(player);
                        break;

                    case 2:
                        EnterLoc(forest, wolf);
                        break;

                    case 3:
                        EnterLoc(plains, goblin);
                        break;

                    case 4:
                        EnterLoc(swamp, orc);
                        break;

                    default:
                        Console.WriteLine("Something went very wrong");
                        break;
                    }
                }
            } while (!dia.hasItem);

            int makeDecision(int maxNumber)
            {
                //This is for whevenever the player has to make a decision
                string userInput;

                do
                {
                    Console.WriteLine("Choose a number between 1 and " + maxNumber);
                    userInput = Console.ReadLine();
                    int.TryParse(userInput, out userNumber);
                } while (userNumber < 1 || userNumber > maxNumber);

                Console.Clear();
                return(userNumber);
            }

            //turn based combat
            void Battle(Player p, Enemy e)
            {
                Console.WriteLine("You are fighting a " + e.name);
                Console.WriteLine("It has " + e.str);
                do
                {
                    p.health -= e.DealDamage();
                    Console.WriteLine(p.name + " has " + p.health + " hp left");
                    e.health -= p.DealDamage();
                    Console.WriteLine(e.name + " has " + e.health + " hp left");
                    Console.ReadLine();
                } while (p.health > 0 && e.health > 0);

                e.ResetHealth();

                //Earn item
                if (e.name == "Direwolf" || e.name == "Goblin")
                {
                    FindItem(key);
                }
                else if (e.name == "Orc" || e.name == "Goblin")
                {
                    FindItem(chest);
                }

                Console.ReadLine();
                Console.Clear();
            }

            //works on everytinh execpt church
            void EnterLoc(Location loc, Enemy e)
            {
                loc.welcome();

                do
                {
                    loc.options();
                    userNumber = makeDecision(2);

                    if (userNumber == 1)
                    {
                        Battle(player, e);
                    }
                    else
                    {
                        loc.Leave();
                    }
                } while (userNumber != 2);
            }

            void EnterChurch(Player p)
            {
                Church church = new Church();

                church.welcome();

                do
                {
                    church.options();
                    userNumber = makeDecision(2);

                    if (userNumber == 1)
                    {
                        Console.WriteLine("You are fully healed!");
                        church.FullHeal(p);
                    }
                    else
                    {
                        church.Leave();
                    }
                } while (userNumber != 2);
            }

            void FindItem(Item item)
            {
                Random rnd = new Random();
                int    i   = rnd.Next(2);

                if (i == 1)
                {
                    item.hasItem = true;
                    Console.WriteLine("You found " + item.itemName);
                }
                else
                {
                    Console.WriteLine("You found no loot");
                }
            }
        }