Пример #1
0
 public static void SaveMap(FileStream fileStream)
 {
     BinaryFormatter formatter = new BinaryFormatter();
     Map mapita = new Map (
         background.Index,
         MapSquares.squares,
         foreground.f,
         MapWidth,
         MapHeight,
         MAPVERSION);
     formatter.Serialize(fileStream, mapita);
     fileStream.Close();
 }
Пример #2
0
        public void StartGame(string MenuFileSelected, string AmountOfPlayers, bool sound, bool effects)
        {
            map = new Map(@"Maps\" + MapSelected + ".xml", this.Game);
            this.Game.Components.Add(map);

            ScreenTitle += " (" + map.Name + ")";
            this.Game.Window.Title = ScreenTitle;

            music = new Audio("Menu", AudioSettings, AudioWaveBank, AudioSoundsBank, this.Game);
            this.Game.Components.Add(music);

            if (sound)
            {
                //Add sound
            }

            if (effects)
            {
                //Add effects
            }

            Controls controls1 = new Controls();
            controls1.Up = Keys.W;
            controls1.Down = Keys.S;
            controls1.Left = Keys.A;
            controls1.Right = Keys.D;
            controls1.Drop = Keys.Q;

            Controls controls2 = new Controls();
            controls2.Up = Keys.I;
            controls2.Down = Keys.K;
            controls2.Left = Keys.J;
            controls2.Right = Keys.L;
            controls2.Drop = Keys.U;

            characters.Add(new Character(map, controls1, 17, @"Sprites\White", this.Game, characters));
            this.Game.Components.Add(characters[0]);

            characters.Add(new Character(map, controls2, 29, @"Sprites\Green", this.Game, characters));
            this.Game.Components.Add(characters[1]);

            if (AmountOfPlayers == "3 players" || AmountOfPlayers == "4 players")
            {
                Controls controls3 = new Controls();
                controls3.Up = Keys.Up;
                controls3.Down = Keys.Down;
                controls3.Left = Keys.Left;
                controls3.Right = Keys.Right;
                controls3.Drop = Keys.RightControl;

                characters.Add(new Character(map, controls3, 167, @"Sprites\Red", this.Game, characters));
                this.Game.Components.Add(characters[2]);

                if (AmountOfPlayers == "4 players")
                {
                    Controls controls4 = new Controls();
                    controls4.Up = Keys.NumPad8;
                    controls4.Down = Keys.NumPad2;
                    controls4.Left = Keys.NumPad4;
                    controls4.Right = Keys.NumPad6;
                    controls4.Drop = Keys.NumPad0;

                    characters.Add(new Character(map, controls4, 179, @"Sprites\Black", this.Game, characters));
                    this.Game.Components.Add(characters[3]);
                }
            }
        }
Пример #3
0
 public Character(Map map, Controls controls, int currentTile, string sprite, Game game, List<Character> characterList)
     : base(game)
 {
     this.characterList = characterList;
     this.map = map;
     this.controls = controls;
     this.parent = game;
     this.currentTile = currentTile;
     this.sprite = sprite;
     this.direction = CharDirection.Down;
     this.charSpawnLocation = currentTile;
     this.x = ((currentTile % this.map.MapSize.Width) - 1) * this.map.SpriteSize.Width;
     this.y = (float)Math.Floor((decimal)(currentTile / this.map.MapSize.Width)) * this.map.SpriteSize.Height;
     this.baseX = this.x;
     this.baseY = this.y;
 }
Пример #4
0
 public Bomb(Game game, int currentTile, Map map, List<Character> characterList)
     : base(game)
 {
     this.characterList = characterList;
     this.currentTile = currentTile;
     this.map = map;
     this.game = game;
 }
Пример #5
0
        private Map BuildEmptyMap(int width, int height)
        {
            Map result = new Map(new Point(50, 50), 256, width, height);
            Point size = result.TileSize;
            int xMax = size.X * width;
            int yMax = size.Y * height;

            var noise = new PerlinNoise(100, 100);

            for (int x = 0; x < xMax; x = x + size.X)
            {
                for (int y = 0; y < yMax; y = y + size.Y)
                {
                    int tileSelection = random.Next(0, 3);
                    Vector2 position = new Vector2((float)x, (float)y);
                    Tile newTile = new Tile(position, size);

                    var perlin = noise.GetRandomHeight((position.X / xMax) * 100, (position.Y / yMax) * 100, 1.0f, 1.0f, 0.0000000001f, 1.0f, 4);

                    if (perlin < 0.5f && perlin >= 0.0f)
                        newTile.AddEntity(new DirtEntity(newTile, this.dirtTexture[tileSelection], Color.White, false));
                    if (perlin < 0.9f && perlin >= 0.5f)
                        newTile.AddEntity(new MudEntity(newTile, this.muckTexture[tileSelection], Color.White, false));
                    if (perlin <= 1.0f && perlin >= 0.9f)
                        newTile.AddEntity(new SludgeEntity(newTile, this.sludgeTexture[tileSelection], Color.White, false));

                    result.Add(newTile);
                }
            }

            result.CalculateAdjacentTiles();
            result.CalculateTileIntensity();

            return result;
        }