public void Update(GameTime gameTime, PlayerSprite player)
        {
            Vector2   playerPos  = player.getPosition();
            Rectangle playerRect = player.getRectangle();

            center = new Vector2((playerPos.X + playerRect.Width / 2) - (GlobalClass.ScreenWidth / 2),
                                 (playerPos.Y + playerRect.Height / 2) - (GlobalClass.ScreenHeight / 2));

            // clamping
            // top
            if (center.Y < 0)
            {
                center.Y = 0;
            }
            // left
            if (center.X < 0)
            {
                center.X = 0;
            }
            // bottom
            if (center.Y + GlobalClass.ScreenHeight > game.GetRoom(game.GetRoomID()).GetRoomRectangle().Height)
            {
                center.Y = game.GetRoom(game.GetRoomID()).GetRoomRectangle().Height - GlobalClass.ScreenHeight;
            }
            // right
            if (center.X + GlobalClass.ScreenWidth > 2410)
            {
                center.X = 2410 - GlobalClass.ScreenWidth;
            }

            //move camera to follow player
            transform = Matrix.CreateScale(new Vector3(1, 1, 0)) *
                        Matrix.CreateTranslation(new Vector3(-center.X, -center.Y, 0));
        }
Exemple #2
0
        public override void Initialize()
        {
            //set up player clamping
            Boundary       = new Rectangle((int)boundaryPosition.X, (int)boundaryPosition.Y + 150, 800, 576);
            leftBoundary   = (int)boundaryPosition.X;
            topBoundary    = (int)boundaryPosition.Y + 15;
            rightBoundary  = roomWidth - 110;
            bottomBoundary = roomHeight - 270;

            base.Initialize();

            //set up building doors
            buildingDoorPos = new Vector2(300f, 84f);

            //se up outside doors
            topDoorPos    = new Vector2(1900, 200);
            leftDoorPos   = new Vector2(15, 400);
            rightDoorPos  = new Vector2(2350, 380);
            bottomDoorPos = new Vector2(1900, 500);

            //set up wall clamps
            topWallPos    = new Vector2((topDoorPos.X - 150f), (topDoorPos.Y - 160f));
            leftWallPos   = new Vector2((leftDoorPos.X - 20f), (leftDoorPos.Y - 110f));
            rightWallPos  = new Vector2((rightDoorPos.X + 30f), (rightDoorPos.Y - 110f));
            bottomWallPos = new Vector2((bottomDoorPos.X - 150f), (bottomDoorPos.Y + 40f));

            //set up door teleports
            topTeleport      = new Vector2(bottomDoorPos.X, bottomDoorPos.Y - offset);
            leftTeleport     = new Vector2(rightDoorPos.X - offset, rightDoorPos.Y);
            rightTeleport    = new Vector2(leftDoorPos.X + offset, leftDoorPos.Y);
            bottomTeleport   = new Vector2(topDoorPos.X, topDoorPos.Y + offset);
            buildingTeleport = new Vector2(buildingDoorPos.X, buildingDoorPos.Y + 128);

            switch (id)
            {
            case 0:
                game.Components.Add(new Barricade(game, "Images//WallWide", topWallPos));
                game.Components.Add(new Barricade(game, "Images//WallEnd", leftWallPos));
                game.Components.Add(new Door(game, "Images//door", rightDoorPos, rightTeleport, true, 1));
                game.Components.Add(new Door(game, "Images//door", bottomDoorPos, bottomTeleport, true, 3));
                // figure something out to link interior to exterior
                game.Components.Add(new Door(game, "Images//DoorClosed", buildingDoorPos, buildingTeleport, true, 9));
                break;

            case 1:
                game.Components.Add(new Barricade(game, "Images//WallWide", topWallPos));
                game.Components.Add(new Door(game, "Images//door", leftDoorPos, leftTeleport, true, 0));
                game.Components.Add(new Door(game, "Images//door", rightDoorPos, rightTeleport, true, 2));
                game.Components.Add(new Door(game, "Images//door", bottomDoorPos, bottomTeleport, true, 4));
                // nope
                game.Components.Add(new Door(game, "Images//DoorClosed", buildingDoorPos, buildingTeleport, true, 10));
                break;

            case 2:
                game.Components.Add(new Barricade(game, "Images//WallWide", topWallPos));
                game.Components.Add(new Barricade(game, "Images//WallEnd", rightWallPos));
                game.Components.Add(new Door(game, "Images//door", leftDoorPos, leftTeleport, true, 1));
                game.Components.Add(new Door(game, "Images//door", bottomDoorPos, bottomTeleport, true, 5));
                // no
                game.Components.Add(new Door(game, "Images//DoorClosed", buildingDoorPos, buildingTeleport, true, 11));
                break;

            case 3:
                game.Components.Add(new Barricade(game, "Images//WallEnd", leftWallPos));
                game.Components.Add(new Door(game, "Images//door", topDoorPos, topTeleport, true, 0));
                game.Components.Add(new Door(game, "Images//door", rightDoorPos, rightTeleport, true, 4));
                game.Components.Add(new Door(game, "Images//door", bottomDoorPos, bottomTeleport, true, 6));
                // nah
                game.Components.Add(new Door(game, "Images//DoorClosed", buildingDoorPos, buildingTeleport, true, 12));
                break;

            case 4:
                game.Components.Add(new Door(game, "Images//door", topDoorPos, topTeleport, true, 1));
                game.Components.Add(new Door(game, "Images//door", rightDoorPos, rightTeleport, true, 5));
                game.Components.Add(new Door(game, "Images//door", leftDoorPos, leftTeleport, true, 3));
                game.Components.Add(new Door(game, "Images//door", bottomDoorPos, bottomTeleport, true, 7));
                // nuh-uh
                game.Components.Add(new Door(game, "Images//DoorClosed", buildingDoorPos, buildingTeleport, true, 13));
                break;

            case 5:
                game.Components.Add(new Barricade(game, "Images//WallEnd", rightWallPos));
                game.Components.Add(new Door(game, "Images//door", leftDoorPos, leftTeleport, true, 4));
                game.Components.Add(new Door(game, "Images//door", topDoorPos, topTeleport, true, 2));
                game.Components.Add(new Door(game, "Images//door", bottomDoorPos, bottomTeleport, true, 8));
                // fix it!
                game.Components.Add(new Door(game, "Images//DoorClosed", buildingDoorPos, buildingTeleport, true, 14));
                break;

            case 6:
                game.Components.Add(new Barricade(game, "Images//WallWide", bottomWallPos));
                game.Components.Add(new Barricade(game, "Images//WallEnd", leftWallPos));
                game.Components.Add(new Door(game, "Images//door", topDoorPos, topTeleport, true, 3));
                game.Components.Add(new Door(game, "Images//door", rightDoorPos, rightTeleport, true, 7));
                // stahp
                game.Components.Add(new Door(game, "Images//DoorClosed", buildingDoorPos, buildingTeleport, true, 15));
                break;

            case 7:
                game.Components.Add(new Barricade(game, "Images//WallWide", bottomWallPos));
                game.Components.Add(new Door(game, "Images//door", topDoorPos, topTeleport, true, 4));
                game.Components.Add(new Door(game, "Images//door", rightDoorPos, rightTeleport, true, 8));
                game.Components.Add(new Door(game, "Images//door", leftDoorPos, leftTeleport, true, 6));
                // no no
                game.Components.Add(new Door(game, "Images//DoorClosed", buildingDoorPos, buildingTeleport, true, 16));
                break;

            case 8:
                game.Components.Add(new Barricade(game, "Images//WallWide", bottomWallPos));
                game.Components.Add(new Barricade(game, "Images//WallEnd", rightWallPos));
                game.Components.Add(new Door(game, "Images//door", topDoorPos, topTeleport, true, 5));
                game.Components.Add(new Door(game, "Images//door", leftDoorPos, leftTeleport, true, 7));
                // your code is bad and you should feel bad
                game.Components.Add(new Door(game, "Images//DoorClosed", buildingDoorPos, buildingTeleport, true, 17));
                break;



            // indoor
            case 9:
                game.Components.Add(new Door(game, "Images//DoorClosed", buildingDoorPos, buildingTeleport, true, 0));
                break;

            case 10:
                game.Components.Add(new Door(game, "Images//DoorClosed", buildingDoorPos, buildingTeleport, true, 1));
                break;

            case 11:
                game.Components.Add(new Door(game, "Images//DoorClosed", buildingDoorPos, buildingTeleport, true, 2));
                break;

            case 12:
                game.Components.Add(new Door(game, "Images//DoorClosed", buildingDoorPos, buildingTeleport, true, 3));
                break;

            case 13:
                game.Components.Add(new Door(game, "Images//DoorClosed", buildingDoorPos, buildingTeleport, true, 4));
                break;

            case 14:
                game.Components.Add(new Door(game, "Images//DoorClosed", buildingDoorPos, buildingTeleport, true, 5));
                break;

            case 15:
                game.Components.Add(new Door(game, "Images//DoorClosed", buildingDoorPos, buildingTeleport, true, 6));
                break;

            case 16:
                game.Components.Add(new Door(game, "Images//DoorClosed", buildingDoorPos, buildingTeleport, true, 7));
                break;

            case 17:
                game.Components.Add(new Door(game, "Images//DoorClosed", buildingDoorPos, buildingTeleport, true, 8));
                break;
            }

            SpawnObjective();

            // exclude objective room
            if (((Game1)Game).GetObjRoom() != this.id)
            {
                //load in random zombie count
                //spawn bosses
                int bossChance = randomNumGen(0, 3);
                if (bossChance == 0)
                {
                    //int xLoc = rand.Next(boundingBox.Width);
                    int     xLoc     = Game1.Random.Next(200, 2210);
                    int     yLoc     = Game1.Random.Next(200, 400);
                    Vector2 location = new Vector2(xLoc, yLoc);

                    while (Vector2.Distance(location, player.getPosition()) < 700)
                    {
                        location.X = Game1.Random.Next(200, 2210);
                        location.Y = Game1.Random.Next(200, 400);
                    }
                    Enemy temp = new Boss(game, "Images//enemyWalk", location, 2, 5);
                    game.Components.Add(temp);
                }

                int zombieNum = randomNumGen(1, maxZombie);

                for (int i = 0; i <= zombieNum; i++)
                {
                    // int xLoc = rand.Next(boundingBox.Width);
                    int     xLoc     = Game1.Random.Next(200, 2210);
                    int     yLoc     = Game1.Random.Next(200, 400);
                    Vector2 location = new Vector2(xLoc, yLoc);

                    while (Vector2.Distance(location, player.getPosition()) < 500)
                    {
                        location.X = Game1.Random.Next(200, 2210);
                        location.Y = Game1.Random.Next(200, 400);
                    }
                    Enemy temp = new Enemy(game, "Images//enemyWalk", location, 2, 5);
                    game.Components.Add(temp);
                }
            }
            drawRectangle1   = new Rectangle(0, 0, 804, 576);
            sourceRectangle1 = new Rectangle(0, 0, 402, 288);
            drawRectangle2   = new Rectangle(804, 0, 804, 576);
            sourceRectangle2 = new Rectangle(402, 0, 402, 288);
            drawRectangle3   = new Rectangle(1608, 0, 802, 576);
            sourceRectangle3 = new Rectangle(804, 0, 401, 288);
            roomRectangle    = new Rectangle(0, 0, roomWidth, roomHeight);
        }