示例#1
0
        public GameManager(Game game, int level)
        {
            mGame = game;

            mPlayer1 = new Character(game, new Pointf(400, 200), new Size(32, 32), new Velocity(), PlayerIndex.One);
            mPlayer2 = new Character(game, new Pointf(350, 200), new Size(32, 32), new Velocity(), PlayerIndex.Two);
            mBoss = null;
            mLevel = level;
            switch (level)
            {
                case 1:
                    mMap = MapBuilder.BuildLevel1(mGame, new Size(game.Window.ClientBounds.Width, game.Window.ClientBounds.Height - Hud.HUD_HEIGHT), ref mPlayer1);
                    mPlayer1.mPosition = new Pointf(MapHelper.GetPointForColumnAndLevel(0.5f, 1));
                    mPlayer2.mPosition = new Pointf(MapHelper.GetPointForColumnAndLevel(0.5f, 1));
                    mBackgroundSong = mGame.Content.Load<Song>("music/Electrolyte - New Mission");
                    break;
                case 2:
                    mMap = MapBuilder.BuildSolo(mGame, new Size(game.Window.ClientBounds.Width, game.Window.ClientBounds.Height - Hud.HUD_HEIGHT), ref mPlayer1);
                    mPlayer1.mPosition = new Pointf(MapHelper.GetPointForColumnAndLevel(0.5f, 1));
                    mPlayer2.mPosition = new Pointf(MapHelper.GetPointForColumnAndLevel(MapHelper.GetLastColumn()-1.5f, 1));
                    mBackgroundSong = mGame.Content.Load<Song>("music/Electrolyte - Plus vs Minus");
                    break;
                case 3:
                    mMap = MapBuilder.BuildBossLevel(mGame, new Size(game.Window.ClientBounds.Width, game.Window.ClientBounds.Height - Hud.HUD_HEIGHT), ref mPlayer1);
                    mBoss = new Character(game, new Pointf(350, MapHelper.GetPlatformYAtLevel(1.5f)), new Size(64, 64), new Velocity(), PlayerIndex.Three);
                    mBackgroundSong = mGame.Content.Load<Song>("music/Electrolyte - Volt");
                    break;
            }

            mHud = new Hud(new Pointf(0, game.Window.ClientBounds.Height - Hud.HUD_HEIGHT), mGame, level);

            mIsPlayingSound = false;
            mGangnamSound = game.Content.Load<SoundEffect>("newgangnam");
            mGangnamInstance = mGangnamSound.CreateInstance();
        }
示例#2
0
        public static MapModel BuildBossLevel(Game game, Size mapSize, ref Character aChar)
        {
            MapModel map = new MapModel(game, mapSize, Score.GenerateDefaultScore(), "bg");
            MapHelper.SetPlayerInfo(aChar.JumpHeight, aChar.mSize);
            MapHelper.SetMap(ref map);

            MapHelper.BuildMapBorders();

            ExitDoorModel door1 = MapHelper.BuildExitDoor(0, 8, PlayerIndex.One);
            ExitDoorModel door2 = MapHelper.BuildExitDoor(MapHelper.GetLastColumn() - 3, 8, PlayerIndex.Two);

            map.AssignExitDoors(ref door1, ref door2);

            return map;
        }
示例#3
0
        public static float GetColumnXAt(float column, ref MapModel map)
        {
            if (DEFAULT_PLATFORM_HEIGHT == -1) throw new Exception("Cannot use MapHelper.GetColumnXAt before SetPlayerInfo is called");
            float temp = OFFSET + column * DEFAULT_PLATFORM_WIDTH;
            if (temp >= map.Right)
            {
                temp = map.Right - map.Origin.X - OFFSET;
            }

            return temp;
        }
示例#4
0
 public static ElevatorModel BuildElevatorAtX(float column, float platformLevel, float elevatorWidth, float maxMovementHeight, ref MapModel map)
 {
     return BuildElevator(GetPointForColumnAndLevel(column, platformLevel, ref map), elevatorWidth, maxMovementHeight, ref map);
 }
示例#5
0
        public static void BuildMapBorders(ref MapModel map)
        {
            // top wall
            Wall wall = new Wall(map.Game, new Pointf(0, 0), new Size(map.mSize.Width, OFFSET), Wall.Colors.WHITE);
            map.AddComponent(wall);

            // left wall
            wall = new Wall(map.Game, new Pointf(0, 0), new Size(OFFSET, map.mSize.Height), Wall.Colors.WHITE);
            map.AddComponent(wall);

            // bottom wall
            wall = new Wall(map.Game, new Pointf(0, map.mSize.Height - OFFSET), new Size(map.mSize.Width, OFFSET), Wall.Colors.WHITE);
            map.AddComponent(wall);

            // right wall
            wall = new Wall(map.Game, new Pointf(map.mSize.Width - OFFSET, 0), new Size(OFFSET, map.mSize.Height), Wall.Colors.WHITE);
            map.AddComponent(wall);
        }
示例#6
0
 public static ElevatorModel BuildElevator(Pointf elevatorPosition, float elevatorWidth, float maxMovementHeight, ref MapModel map)
 {
     ElevatorModel elev = new ElevatorModel(map.Game, elevatorWidth, maxMovementHeight, elevatorPosition);
     map.AddComponent(elev);
     return elev;
 }
示例#7
0
 public static ElevatorModel BuildElevator(float column, float platformLevel, ref MapModel map)
 {
     return BuildElevator(GetPointForColumnAndLevel(column, platformLevel, ref map), ref map);
 }
示例#8
0
 public static Collectable BuildCollectable(float column, float platformLevel, ref MapModel map, int points)
 {
     return BuildCollectable(GetPointForColumnAndLevel(column, platformLevel), ref map, points);
 }
示例#9
0
 public static Pointf GetPointForColumnAndLevel(float column, float level, ref MapModel map)
 {
     return new Pointf(GetColumnXAt(column, ref map), GetPlatformYAtLevel(level, ref map));
 }
示例#10
0
 public static Resistor BuildResistor(float column, float platformLevel, Resistor.Type index, ref MapModel map)
 {
     platformLevel--;
     platformLevel += 0.05f;
     return BuildResistor(GetPointForColumnAndLevel(column, platformLevel), index, ref map);
 }
示例#11
0
 public static Collectable BuildCollectable(Pointf position, ref MapModel map, int points)
 {
     Collectable c = new Collectable(map.Game, position, points);
     map.AddComponent(c);
     return c;
 }
示例#12
0
 public static Wall BuildPlatform(float column, float platformLevel, float columnSpan, Wall.Colors color, ref MapModel map)
 {
     return BuildWall(GetPointForColumnAndLevel(column, platformLevel, ref map), new Size(columnSpan * DEFAULT_PLATFORM_WIDTH, OFFSET), color, ref map);
 }
示例#13
0
 public static Resistor BuildResistor(Pointf position, Resistor.Type index, ref MapModel map)
 {
     Resistor res = new Resistor(map.Game, position, index);
     map.AddComponent(res);
     return res;
 }
示例#14
0
 public static MoveableBox BuildMoveableBoxAtX(float posX, float platformLevel, Size boxSize, ref MapModel map)
 {
     return BuildMoveableBox(new Pointf(posX, GetPlatformYAtLevel(platformLevel, ref map)), boxSize, ref map);
 }
示例#15
0
 public static MoveableBox BuildMoveableBox(float column, float platformLevel, Size boxSize, ref MapModel map)
 {
     return BuildMoveableBox(GetPointForColumnAndLevel(column, platformLevel, ref map), boxSize, ref map);
 }
示例#16
0
 public static MoveableBox BuildMoveableBox(Pointf boxPosition, Size boxSize, ref MapModel map)
 {
     MoveableBox box = new MoveableBox(map.Game, boxPosition, boxSize);
     map.AddComponent(box);
     return box;
 }
示例#17
0
 public static int GetLastColumn(ref MapModel map)
 {
     if (DEFAULT_PLATFORM_HEIGHT == -1) throw new Exception("Cannot use MapHelper.GetLastColumn before SetPlayerInfo is called");
     return (int)(map.mSize.Width / DEFAULT_PLATFORM_WIDTH) +1;
 }
示例#18
0
 public static SwitchModel BuildSwitch(Pointf switchPosition, ref MapModel map)
 {
     SwitchModel toAdd = new SwitchModel(map.Game, switchPosition);
     map.AddComponent(toAdd);
     return toAdd;
 }
示例#19
0
 public static int GetLastLevel(ref MapModel map)
 {
     if (DEFAULT_PLATFORM_HEIGHT == -1) throw new Exception("Cannot use MapHelper.GetLastLevel before SetPlayerInfo is called");
     return (int)(map.mSize.Height / DEFAULT_PLATFORM_HEIGHT) +1;
 }
示例#20
0
 public static SwitchModel BuildSwitch(float column, float platformLevel, ref MapModel map)
 {
     Pointf switchPos = GetPointForColumnAndLevel(column, platformLevel, ref map);
     switchPos.Y -= OFFSET/2;
     return BuildSwitch(switchPos, ref map);
 }
示例#21
0
 public static float GetPlatformYAtLevel(float level, ref MapModel map)
 {
     if (DEFAULT_PLATFORM_HEIGHT == -1) throw new Exception("Cannot use MapHelper.GetPlatformYAtLevel before SetPlayerInfo is called");
     return (map.mSize.Height - OFFSET) - (DEFAULT_PLATFORM_HEIGHT * level);
 }
示例#22
0
 public static SwitchModel BuildSwitchAtX(float posX, float platformLevel, ref MapModel map)
 {
     float yLevel = GetPlatformYAtLevel(platformLevel, ref map) - OFFSET * 3;
     return BuildSwitch(new Pointf(posX, yLevel), ref map);
 }
示例#23
0
 public static void SetMap(ref MapModel map)
 {
     if (map == null) throw new Exception("Null MapModel passed to MapHelper.SetMap");
     mMap = map;
 }
示例#24
0
 public static Wall BuildWall(Pointf wallPosition, Size wallSize, Wall.Colors wallColor, ref MapModel map)
 {
     Wall wall = new Wall(map.Game, new Pointf(wallPosition.X, wallPosition.Y), new Size(wallSize.Width, wallSize.Height), wallColor);
     map.AddComponent(wall);
     return wall;
 }
示例#25
0
 public static ElevatorModel BuildElevator(Pointf elevatorPosition, ref MapModel map)
 {
     return BuildElevator(elevatorPosition, GetDefaultElevatorColumnSpan() * DEFAULT_PLATFORM_WIDTH, GetDefaultElevatorLevelSplan() * DEFAULT_PLATFORM_HEIGHT, ref map);
 }
示例#26
0
 public static ExitDoorModel BuildExitDoor(float column, float platformLevel, PlayerIndex playerIndex, ref MapModel map)
 {
     return BuildExitDoor(GetPointForColumnAndLevel(column, platformLevel, ref map), playerIndex, ref map);
 }
示例#27
0
 public static ElevatorModel BuildElevator(float column, float platformLevel, float columnSpan, float levelSpan, ref MapModel map)
 {
     return BuildElevator(GetPointForColumnAndLevel(column, platformLevel, ref map), columnSpan * DEFAULT_PLATFORM_WIDTH, levelSpan * DEFAULT_PLATFORM_HEIGHT, ref map);
 }
示例#28
0
 public static Wall BuildWallAtX(float posX, float platformLevel, Size wallSize, Wall.Colors wallColor, ref MapModel map)
 {
     return BuildWall(new Pointf(posX, GetPlatformYAtLevel(platformLevel, ref map)), wallSize, wallColor, ref map);
 }
示例#29
0
 public static Wall BuildWall(float column, float platformLevel, Size wallSize, Wall.Colors wallColor, ref MapModel map)
 {
     return BuildWall(GetPointForColumnAndLevel(column, platformLevel, ref map), wallSize, wallColor, ref map);
 }
示例#30
0
 public static ExitDoorModel BuildExitDoorAtX(float posX, float platformLevel, PlayerIndex playerIndex, ref MapModel map)
 {
     return BuildExitDoor(new Pointf(posX, GetPlatformYAtLevel(platformLevel, ref map)), playerIndex, ref map);
 }