Example #1
0
        public static bool CollidesWith(Animation objectA, Animation objectB, Matrix aTransform, Matrix bTransform, bool calcPerPixel)
        {
            Rectangle objectARectangle = CalculateBoundingRectangle(
                     new Rectangle(0, 0, objectA.frameWidth, objectA.frameHeight),
                     aTransform);

            Rectangle objectBRectangle = CalculateBoundingRectangle(
                    new Rectangle(0, 0, objectB.frameWidth, objectB.frameHeight),
                    bTransform);

            if (objectBRectangle.Intersects(objectARectangle))
            {
                objectA.collisionData();
                objectB.collisionData();
                if (IntersectPixels(aTransform, objectA.frameWidth,
                                    objectA.frameHeight, objectA.colorData,
                                    bTransform, objectB.frameWidth,
                                    objectB.frameHeight, objectB.colorData))
                {
                    return true;
                }
            }

            return false;
        }
Example #2
0
 public void Initialize(Vector2 pos, Animation buttonAnimation, string buttonname, int menunum)
 {
     menuNum = menunum;
     this.buttonName = buttonname;
     this.buttonAnimation = buttonAnimation;
     buttonAnimation.Initialize(1, 1, pos, 0f, Color.White, true);
     position = pos;
 }
Example #3
0
 public void Initialize(Animation pickupAnimation, Vector2 intpos, Vector2 gravity,Vector2 intialVel, int score)
 {
     this.velocity = intialVel;
         active = true;
        this.gravity = gravity;
         position = intpos;
         this.score = score;
         this.pickupAnimation = pickupAnimation;
         pickupAnimation.Initialize(1, 1, intpos, 0f, Color.White);
         hitBox = new Rectangle((int)position.X - pickupAnimation.frameWidth / 2, (int)position.Y - pickupAnimation.frameHeight / 2, pickupAnimation.frameWidth, pickupAnimation.frameHeight);
 }
Example #4
0
 public void Initialize(Animation projectileAnimation, Vector2 position,float speed, Vector2 angle, float damage)
 {
     active = true;
     this.projectileAnimation = projectileAnimation;
     this.position = position;
     this.angle = angle;
     this.speed = speed;
     this.damage = damage;
     if (angle.X == 0 && angle.Y == 0)
     {
         angle = new Vector2(0, 1);
     }
     angle.Normalize();
     hitBox = new Rectangle((int)position.X - projectileAnimation.frameWidth / 2, (int)position.Y - projectileAnimation.frameHeight / 2, projectileAnimation.frameWidth, projectileAnimation.frameHeight);
 }
Example #5
0
        public void Initialize(Animation weaponAnimation, Texture2D projectileTex, Vector2 position, Vector2 shootOffset, Vector2 weaponHandle, float gunAngle,
            bool pickedUp, float shootSpeed, TimeSpan fireRate, float damage, PlayerIndex playerNumber)
        {
            this.weaponHandle = weaponHandle;
            flipped = false;
            this.gunAngle = gunAngle;
            this.shootSpeed = shootSpeed;
            this.projectileTex = projectileTex;
            this.playerNumber = playerNumber;
            this.weaponAnimation = weaponAnimation;

            this.position = position;
            this.pickedUp = pickedUp;
            this.fireRate = fireRate;
            this.damage = damage;
            weaponAnimation.Initialize(1, 1, position, 0, Color.White);
            shootOffset = new Vector2(weaponAnimation.frameWidth + weaponHandle.X + 26 - projectileTex.Width / 2, weaponHandle.Y + projectileTex.Height / 2);
            active = true;
            hitBox = new Rectangle((int)position.X - weaponAnimation.frameWidth / 2, (int)position.Y - weaponAnimation.frameHeight / 2, weaponAnimation.frameWidth, weaponAnimation.frameHeight);
        }
Example #6
0
 public void StartGame()
 {
     HatLoad();
     currentGameLength = TimeSpan.FromSeconds(0);
     projectiles = new List<Projectile>();
     playerBody = new Animation();
     playerHead = new Animation();
     playerArm = new Animation();
     playerRunning = new Animation();
     playerJump = new Animation();
     playerWalking = new Animation();
     playerCrouch = new Animation();
     weaponAnimation = new Animation();
     bulletAnimation = new Animation();
     platformAnimation = new Animation();
     backGroundAnimation = new Animation();
     scoreAnimation = new Animation();
     platformRectangles = new List<Rectangle>();
     pickups = new List<Pickup>();
     stairRectangles = new List<Rectangle>();
     scoreAnimation.LoadTexture(scoreTex);
     backGroundAnimation.LoadTexture(backGroundTex);
     scoreAnimation.Initialize(1, 1, new Vector2(graphics.PreferredBackBufferWidth / 2, 0), 0, Color.White);
    
     backGroundAnimation.Initialize(1, 1, new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2), 0, Color.White);
     LoadPlayers();
     AddPlatform();
     AddStairs();
 }
Example #7
0
 public void Shoot(GameTime gameTime)
 {
     if (gameTime.TotalGameTime - previousFireTime > fireRate)
     {
         if (GamePad.GetState(playerNumber).Triggers.Right >= 0.5f)
         {
             Projectile projectile = new Projectile();
             projectileAnimation = new Animation();
             projectileAnimation.LoadTexture(projectileTex);
             projectileAnimation.Initialize(1, 1, shootPosition, 0, Color.White);
             previousFireTime = gameTime.TotalGameTime;
             projectile.Initialize(projectileAnimation, shootPosition,shootSpeed, shootAngle, damage);
             Game1.projectiles.Add(projectile);
         }
     }
 }
Example #8
0
        public void Update(GameTime gameTime)
        {
            if (active)
            {
                prePosition = position;
                gamePadState = GamePad.GetState(playerNumber, GamePadDeadZone.None);
                GetInputLeft();
                GetInputRight();
                GetAngle();
                ApplyFriction(gameTime);
                ControllerMove(gameTime);
                StateManager();

                ApplyGravity(gameTime);
                Jump(gameTime);

                DirectionCheck();

                position += velocity;
                position.X = MathHelper.Clamp(position.X, playerBody.frameWidth / 2, windowWidth - playerBody.frameWidth / 2);
                position.Y = MathHelper.Clamp(position.Y, (playerBody.frameHeight + playerHead.frameHeight) / 2, windowHeight - playerBody.frameHeight / 2);

                if (currentMoveState == MoveState.Standing)
                {
                    playerWalking.active = false;
                    playerBody.active = true;
                    playerRunning.active = false;
                    playerJump.active = false;
                    playerCrouch.active = false;
                    activeAnimation = playerBody;
                    headPosition = new Vector2(position.X, position.Y - (playerBody.frameHeight + playerHead.frameHeight) / 2);
                    armPosition = new Vector2(position.X, position.Y - (playerBody.frameHeight) / 2);

                }
                if (currentMoveState == MoveState.Walking)
                {
                    playerWalking.active = true;
                    playerBody.active = false;
                    playerRunning.active = false;
                    playerJump.active = false;
                    playerCrouch.active = false;
                    activeAnimation = playerWalking;
                    headPosition = new Vector2(position.X, position.Y - (playerBody.frameHeight + playerHead.frameHeight) / 2);
                    armPosition = new Vector2(position.X, position.Y - (playerBody.frameHeight) / 2);

                }
                if (currentMoveState == MoveState.Running && (currentState != State.Jumping && currentState != State.Falling))
                {
                    playerWalking.active = false;
                    playerBody.active = false;
                    playerRunning.active = true;
                    playerJump.active = false;
                    playerCrouch.active = false;
                    activeAnimation = playerRunning;
                    if (!flipped)
                    {
                        headPosition = new Vector2(position.X + 25, position.Y + 9 - (playerBody.frameHeight + playerHead.frameHeight) / 2);
                        armPosition = new Vector2(position.X + 18, position.Y + 8 - (playerBody.frameHeight) / 2);
                        if (velocity.X < 0)
                        {
                            playerWalking.reversed = true;
                            playerRunning.reversed = true;
                        }
                        else
                        {
                            playerWalking.reversed = false;
                            playerRunning.reversed = false;
                        }
                    }
                    else
                    {
                        if (velocity.X > 0)
                        {
                            playerWalking.reversed = true;
                            playerRunning.reversed = true;
                        }
                        else
                        {
                            playerWalking.reversed = false;
                            playerRunning.reversed = false;
                        }
                        headPosition = new Vector2(position.X - 25, position.Y + 9 - (playerBody.frameHeight + playerHead.frameHeight) / 2);

                        armPosition = new Vector2(position.X - 18, position.Y + 8 - (playerBody.frameHeight) / 2);
                    }
                }

                if (gamePadState.IsButtonDown(Buttons.X) || gamePadState.IsButtonDown(Buttons.B))
                {
                    if (currentMoveState == MoveState.Standing)
                    {
                        playerWalking.active = false;
                        playerBody.active = false;
                        playerRunning.active = false;
                        playerJump.active = false;
                        playerCrouch.active = true;
                        activeAnimation = playerJump;

                        if (!flipped)
                        {
                            headPosition = new Vector2(position.X - 5, position.Y + jumpList[4 - playerCrouch.frameIndex] - (playerBody.frameHeight + playerHead.frameHeight) / 2);
                            armPosition = new Vector2(position.X - 5, position.Y + jumpList[4 - playerCrouch.frameIndex] - (playerBody.frameHeight) / 2);
                        }
                        else
                        {
                            headPosition = new Vector2(position.X + 5, position.Y + jumpList[4 - playerCrouch.frameIndex] - (playerBody.frameHeight + playerHead.frameHeight) / 2);
                            armPosition = new Vector2(position.X + 5, position.Y + jumpList[4 - playerCrouch.frameIndex] - (playerBody.frameHeight) / 2);
                        }
                    }
                    if (gamePadState.IsButtonDown(Buttons.B))
                    {
                        currentMoveState = MoveState.Crouch;
                    }
                }

                if (currentState == State.Jumping || currentState == State.Falling)
                {
                    playerWalking.active = false;
                    playerJump.active = true;
                    playerBody.active = false;
                    playerRunning.active = false;
                    playerCrouch.active = false;
                    activeAnimation = playerJump;
                    headPosition = new Vector2(position.X, position.Y + jumpList[playerJump.frameIndex] - (playerBody.frameHeight + playerHead.frameHeight) / 2);
                    armPosition = new Vector2(position.X, position.Y + jumpList[playerJump.frameIndex] - (playerBody.frameHeight) / 2);

                }

                playerWalking.position = position;
                playerCrouch.position = position;
                playerJump.position = position;
                playerRunning.position = position;
                playerBody.position = position;
                playerHead.position = headPosition;
                playerArm.position = armPosition;
                footBox = new Rectangle((int)position.X - playerBody.frameWidth / 2, (int)position.Y + (playerBody.frameHeight / 2) - 20, playerBody.frameWidth, 20);

                mainHitbox = new Rectangle((int)position.X - activeAnimation.frameWidth / 2, (int)position.Y - activeAnimation.frameHeight / 2, activeAnimation.frameWidth, activeAnimation.frameHeight);
                PlatformCollision();
                StairCollision();
                playerJump.Update(gameTime);
                playerBody.Update(gameTime);
                playerHead.Update(gameTime);
                playerWalking.Update(gameTime);
                playerArm.angle = armAngle;
                playerArm.Update(gameTime);
                playerCrouch.Update(gameTime);
                playerRunning.Update(gameTime);
                activeAnimation.Update(gameTime);

                if (flipped)
                {
                    playerArm.origin = new Vector2(playerArm.frameWidth, 0);

                }
                else
                {
                    playerArm.origin = new Vector2(0, 0);
                }

                if (flipped)
                {

                    weaponPosition = armPosition;
                }
                else
                {
                    weaponPosition = armPosition;
                }
                if (activeWeapon != null)
                {
                    activeWeapon.position = weaponPosition;
                    activeWeapon.gunAngle = armAngle;

                }
                if (activeWeapon != null)
                {
                    activeWeapon.Update(gameTime);
                }

                headHitbox = new Rectangle((int)headPosition.X - playerHead.frameWidth / 2, (int)headPosition.Y - playerHead.frameHeight / 2, playerHead.frameWidth, playerHead.frameHeight);
                playerTransformation =
                           Matrix.CreateTranslation(new Vector3(-activeAnimation.origin, 0.0f)) *
                           Matrix.CreateScale(activeAnimation.scale) *
                           Matrix.CreateTranslation(new Vector3(activeAnimation.position, 0.0f));
                Matrix.CreateTranslation(new Vector3(activeAnimation.position, 0.0f));

                headTransformation = Matrix.CreateTranslation(new Vector3(-playerHead.origin, 0.0f)) *
                           Matrix.CreateScale(playerHead.scale) *
                           Matrix.CreateTranslation(new Vector3(playerHead.position, 0.0f));
                Matrix.CreateTranslation(new Vector3(playerHead.position, 0.0f));

                 hatAnimation.position = headPosition - new Vector2((playerHead.frameWidth / 2), playerHead.frameHeight / 2) * 2 + hatPos;

                hatAnimation.Update(gameTime);

                    hatAnimation.origin = new Vector2(0, 0);

                if(health <=0)
                {
                    PlayerDeath();
                    active = false;
                }
            }
        }
Example #9
0
 public void LoadPlayers()
 {
     players = new List<Player>();
     for (int i = 0; i < noPlayers; i++)
     {     playerBody = new Animation();
         playerHead = new Animation();
         playerArm = new Animation();
         playerRunning = new Animation();
         playerJump = new Animation();
         playerWalking = new Animation();
         playerCrouch = new Animation();
         weaponAnimation = new Animation();
         bulletAnimation = new Animation();
         playerBody.LoadTexture(playerBodyTex);
         playerRunning.LoadTexture(playerRunningTex);
         playerHead.LoadTexture(playerHeadTex);
         playerArm.LoadTexture(playerArmTex);
         playerJump.LoadTexture(playerJumpTex);
         playerCrouch.LoadTexture(playerCrouchTex);
         playerWalking.LoadTexture(playerWalkingTex);
         weaponAnimation.LoadTexture(weaponTex);
         
        Weapon weapon = new Weapon();
        weapon.Initialize(weaponAnimation, bulletTex, new Vector2(0, 0), new Vector2(10, 0), new Vector2(6, 14), 0, true, 1f, TimeSpan.FromSeconds(0.3), 10, (PlayerIndex)i);
         Player player = new Player();
         player.Initialize(healthTexture,playerBody, playerRunning, playerWalking, playerCrouch, playerJump, playerHead, playerArm,
           new Vector2(random.Next(1920), random.Next(1080)), graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height,
             new Vector2(0, 40f), 200, new Vector2(0, 15), (PlayerIndex)i, 0, hatTexs[playerHatNums[i]], hatPos[playerHatNums[i]]);
         player.activeWeapon = weapon;
         players.Add(player);
     }
 }
Example #10
0
        public void InitializeSelectScreen()
        {
           
            readyPlayers = 0;
            readyPlayerChecker = new List<bool>();
            readyPlayerChecker.Add(false);
            readyPlayerChecker.Add(false);
            readyPlayerChecker.Add(false);

            readyPlayerChecker.Add(false);
            selectHats = new List<Animation>();
            selectIconsBody = new List<Animation>();
            selectIconsHead = new List<Animation>();
            selectIcon = new Animation();
            selectIcon.LoadTexture(playerBodyTex);
            selectIcon.Initialize(1, 1, new Vector2(graphics.PreferredBackBufferWidth / 5, graphics.PreferredBackBufferHeight * 2 / 3), 0, Color.White);
            selectIconsBody.Add(selectIcon);
            selectIcon = new Animation();
            selectIcon.LoadTexture(playerBodyTex);
            selectIcon.Initialize(1, 1, new Vector2(graphics.PreferredBackBufferWidth*2 / 5, graphics.PreferredBackBufferHeight *2/ 3), 0, Color.White);
            selectIconsBody.Add(selectIcon);
            selectIcon = new Animation();
            selectIcon.LoadTexture(playerBodyTex);
            selectIcon.Initialize(1, 1, new Vector2(graphics.PreferredBackBufferWidth * 3 / 5, graphics.PreferredBackBufferHeight * 2 / 3), 0, Color.White);
            selectIconsBody.Add(selectIcon);
            selectIcon = new Animation();
            selectIcon.LoadTexture(playerBodyTex);
            selectIcon.Initialize(1, 1, new Vector2(graphics.PreferredBackBufferWidth * 4 / 5, graphics.PreferredBackBufferHeight * 2 / 3), 0, Color.White);
            selectIconsBody.Add(selectIcon);

            selectIcon = new Animation();
            selectIcon.LoadTexture(playerHeadTex);
            selectIcon.Initialize(1, 1, new Vector2(graphics.PreferredBackBufferWidth / 5, graphics.PreferredBackBufferHeight * 2 / 3 - playerHeadTex.Height / 2 - playerBodyTex.Height / 2), 0, Color.White);
            selectIconsHead.Add(selectIcon);
            selectIcon = new Animation();
            selectIcon.LoadTexture(playerHeadTex);
            selectIcon.Initialize(1, 1, new Vector2(graphics.PreferredBackBufferWidth * 2 / 5, graphics.PreferredBackBufferHeight * 2 / 3 - playerHeadTex.Height / 2 - playerBodyTex.Height / 2), 0, Color.White);
            selectIconsHead.Add(selectIcon);
            selectIcon = new Animation();
            selectIcon.LoadTexture(playerHeadTex);
            selectIcon.Initialize(1, 1, new Vector2(graphics.PreferredBackBufferWidth * 3 / 5, graphics.PreferredBackBufferHeight * 2 / 3 - playerHeadTex.Height / 2 - playerBodyTex.Height / 2), 0, Color.White);
            selectIconsHead.Add(selectIcon);
            selectIcon = new Animation();
            selectIcon.LoadTexture(playerHeadTex);
            selectIcon.Initialize(1, 1, new Vector2(graphics.PreferredBackBufferWidth * 4 / 5, graphics.PreferredBackBufferHeight * 2 / 3 - playerHeadTex.Height / 2 - playerBodyTex.Height / 2), 0, Color.White);
            selectIconsHead.Add(selectIcon);

            selectIcon = new Animation();
            selectIcon.LoadTexture(playerHeadTex);
            selectIcon.Initialize(1, 1, new Vector2(graphics.PreferredBackBufferWidth / 5, graphics.PreferredBackBufferHeight * 2 / 3 - playerBodyTex.Height / 2), 0, Color.White);
            selectHats.Add(selectIcon);
            selectIcon = new Animation();
            selectIcon.LoadTexture(playerHeadTex);
            selectIcon.Initialize(1, 1, new Vector2(graphics.PreferredBackBufferWidth * 2 / 5, graphics.PreferredBackBufferHeight * 2 / 3 - playerBodyTex.Height / 2), 0, Color.White);
            selectHats.Add(selectIcon);
            selectIcon = new Animation();
            selectIcon.LoadTexture(playerHeadTex);
            selectIcon.Initialize(1, 1, new Vector2(graphics.PreferredBackBufferWidth * 3 / 5, graphics.PreferredBackBufferHeight * 2 / 3 - playerBodyTex.Height / 2), 0, Color.White);
            selectHats.Add(selectIcon);
            selectIcon = new Animation();
            selectIcon.LoadTexture(playerHeadTex);
            selectIcon.Initialize(1, 1, new Vector2(graphics.PreferredBackBufferWidth * 4 / 5, graphics.PreferredBackBufferHeight * 2 / 3 - -playerBodyTex.Height / 2), 0, Color.White);
            selectHats.Add(selectIcon);

        }
Example #11
0
  public static void AddPickupPlayerDeath(float x,float y, Vector2 vel,Vector2 vel2)
  {
      Pickup pickup = new Pickup();
      pickupAnimation = new Animation();
      pickupAnimation.LoadTexture(pickupTex);
      pickup.Initialize(pickupAnimation, new Vector2(x, y), vel, vel2, 10);
 
      pickups.Add(pickup);
  }
Example #12
0
        public static void RespawnPlayer(int playerNum)
        {
            int score = players[playerNum].score;
            playerBody = new Animation();
            playerHead = new Animation();
            playerArm = new Animation();
            playerRunning = new Animation();
            playerJump = new Animation();
            playerWalking = new Animation();
            playerCrouch = new Animation();
            weaponAnimation = new Animation();
            bulletAnimation = new Animation();
            playerBody.LoadTexture(playerBodyTex);
            playerRunning.LoadTexture(playerRunningTex);
            playerHead.LoadTexture(playerHeadTex);
            playerArm.LoadTexture(playerArmTex);
            playerJump.LoadTexture(playerJumpTex);
            playerCrouch.LoadTexture(playerCrouchTex);
            playerWalking.LoadTexture(playerWalkingTex);

            weaponAnimation.LoadTexture(weaponTex);
            Weapon weapon = new Weapon();
            weapon.Initialize(weaponAnimation, bulletTex, new Vector2(0, 0), new Vector2(10, 0), new Vector2(6, 14), 0, true, 1f, TimeSpan.FromSeconds(0.3), 10, (PlayerIndex)playerNum);
             
            players[playerNum] = new Player();
            players[playerNum].Initialize(healthTexture, playerBody, playerRunning, playerWalking, playerCrouch, playerJump, playerHead, playerArm,
                   new Vector2(random.Next(1920), random.Next(1080)), graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height,
                    new Vector2(0, 40f), 200, new Vector2(0, 15), (PlayerIndex)playerNum, score, hatTexs[playerHatNums[playerNum]], hatPos[playerHatNums[playerNum]]);
            players[playerNum].activeWeapon = weapon;
        }
Example #13
0
 public void Initialize(Texture2D healthtexture,Animation playerBody, Animation playerRunning, Animation playerWalking, Animation playerCrouch, Animation playerJump, Animation playerHead, Animation playerArm, Vector2 position, float windowWidth, float windowHeight, Vector2 gravity,
   float playerSpeed, Vector2 jumpSpeed, PlayerIndex playerNumber, int score,Texture2D hatTex, Vector2 hatPos )
 {
     this.hatAnimation =new Animation();
     this.healthtexture = healthtexture;
     this.hatPos = hatPos;
     State currentState = State.OnGround;
     MoveState currentMoveState = MoveState.Standing;
     active = true;
     this.score = score;
     health = 100;
     this.playerWalking = playerWalking;
     this.playerCrouch = playerCrouch;
     this.playerJump = playerJump;
     this.playerRunning = playerRunning;
     this.jumpSpeed = jumpSpeed;
     this.gravity = gravity;
     this.playerNumber = playerNumber;
     this.playerSpeed = playerSpeed;
     this.playerBody = playerBody;
     this.playerHead = playerHead;
     this.playerArm = playerArm;
     this.position = position;
     this.windowWidth = windowWidth;
     this.windowHeight = windowHeight;
     headPosition = new Vector2(position.X, position.Y - (playerBody.frameHeight + playerHead.frameHeight) / 2);
     armPosition = new Vector2(position.X, position.Y - (playerBody.frameHeight) / 2);
     playerBody.Initialize(1, 1, position, 0, Color.White);
     playerWalking.Initialize(20, 0.5f, position, 0, Color.White);
     playerRunning.Initialize(20, 0.4f, position, 0, Color.White);
     playerJump.Initialize(true, 5,0.2f, position, 0, Color.White);
     playerCrouch.Initialize(true, 5, 0.2f, position, 0, Color.White);
     playerRunning.active = false;
     playerCrouch.active = false;
     playerJump.active = false;
     playerWalking.active = false;
     playerHead.Initialize(1, 1, headPosition, 0, Color.White);
     playerArm.Initialize(1, 1, armPosition, 0, Color.White);
     mainHitbox = new Rectangle((int)position.X - playerBody.frameWidth / 2, (int)position.Y - playerBody.frameHeight / 2, playerBody.frameWidth, playerBody.frameHeight);
     headHitbox = new Rectangle((int)headPosition.X - playerHead.frameWidth / 2, (int)headPosition.Y - playerHead.frameHeight / 2, playerHead.frameWidth, playerHead.frameHeight);
     footBox = new Rectangle((int)position.X - playerBody.frameWidth / 2, (int)position.Y + playerBody.frameHeight / 2 -10, playerBody.frameWidth, 10);
     jumpList.Add(26);
     jumpList.Add(22);
     jumpList.Add(16);
     jumpList.Add(9);
     jumpList.Add(0);
     activeAnimation = playerBody;
     hatAnimation.LoadTexture(hatTex);
     hatAnimation.Initialize(1, 1, new Vector2(0, 0), 0, Color.White);
 }
Example #14
0
 public void AddPickup()
 {
     Pickup pickup = new Pickup();
     pickupAnimation = new Animation();
     switch (random.Next(1, 5))
     {
         case 1:
             pickupTex = clockTex;
             break;
         case 2:
             pickupTex = noteTex;
             break;
         case 3:
             pickupTex = coinsTex;
             break;
         case 4:
             pickupTex = piggybankTex;
             break;
     }
     pickupAnimation.LoadTexture(pickupTex);
     pickup.Initialize(pickupAnimation, new Vector2(random.Next(1920), random.Next(1080)), new Vector2(0, 40f),new Vector2 (0,0), 10);
     pickups.Add(pickup);
 }
Example #15
0
        public void HatLoad()
        {
         hatsHats = new List<List<Animation>>();
                 hatTexs = new List<Texture2D>() ;
                 hats = new List<Animation>();
                 hatPos = new List<Vector2>();
                 Texture2D hatTexture = LoadContent(this.Content, "ricehat");
                 hatTexs.Add(hatTexture);

                 hatPos.Add(new Vector2(8, 10));
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatTexture = LoadContent(this.Content, "boater");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(15, 8));
                 hatTexture = LoadContent(this.Content, "chefhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(14, 1));
                 hatTexture = LoadContent(this.Content, "christmashat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(14, 5));
                 hatTexture = LoadContent(this.Content, "dmed");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(14, 6));
                 hatTexture = LoadContent(this.Content, "elfhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(18, 3));
                 hatTexture = LoadContent(this.Content, "fez");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(19, 3));
                 hatTexture = LoadContent(this.Content, "vikinghat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(13, 4));

                 hatTexture = LoadContent(this.Content, "pilgrimmhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(18, 4));

                 hatTexture = LoadContent(this.Content, "piratehat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(11, 7));

                 hatTexture = LoadContent(this.Content, "russianhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(13, 11));
                 hatTexture = LoadContent(this.Content, "stetson");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(12, 0));
                 hatTexture = LoadContent(this.Content, "wizardhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(17, 2));
                 hatsHats.Add(hats);

                 hatTexs = new List<Texture2D>();
                 hats = new List<Animation>();
                 hatPos = new List<Vector2>();
                 hatTexture = LoadContent(this.Content, "ricehat");
                 hatTexs.Add(hatTexture);

                 hatPos.Add(new Vector2(8, 10));
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatTexture = LoadContent(this.Content, "boater");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(15, 8));
                 hatTexture = LoadContent(this.Content, "chefhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(14, 1));
                 hatTexture = LoadContent(this.Content, "christmashat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(14, 5));
                 hatTexture = LoadContent(this.Content, "dmed");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(14, 6));
                 hatTexture = LoadContent(this.Content, "elfhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(18, 3));
                 hatTexture = LoadContent(this.Content, "fez");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(19, 3));
                 hatTexture = LoadContent(this.Content, "vikinghat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(13, 4));

                 hatTexture = LoadContent(this.Content, "pilgrimmhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(18, 4));

                 hatTexture = LoadContent(this.Content, "piratehat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(11, 7));

                 hatTexture = LoadContent(this.Content, "russianhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(13, 11));
                 hatTexture = LoadContent(this.Content, "stetson");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(12, 0));
                 hatTexture = LoadContent(this.Content, "wizardhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(17, 2));
                 hatsHats.Add(hats);

                 hatTexs.Add(hatTexture);
                 hatTexs = new List<Texture2D>();
                 hats = new List<Animation>();
                 hatPos = new List<Vector2>();
                  hatTexture = LoadContent(this.Content, "ricehat");
                 hatTexs.Add(hatTexture);

                 hatPos.Add(new Vector2(8, 10));
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
              
                 hatTexture = LoadContent(this.Content, "boater");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(15, 8));
                 hatTexture = LoadContent(this.Content, "chefhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(14, 1));
                 hatTexture = LoadContent(this.Content, "christmashat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(14, 5));
                 hatTexture = LoadContent(this.Content, "dmed");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(14, 6));
                 hatTexture = LoadContent(this.Content, "elfhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(18, 3));
                 hatTexture = LoadContent(this.Content, "fez");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(19, 3));
                 hatTexture = LoadContent(this.Content, "vikinghat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(13, 4));

                 hatTexture = LoadContent(this.Content, "pilgrimmhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(18, 4));

                 hatTexture = LoadContent(this.Content, "piratehat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(11, 7));

                 hatTexture = LoadContent(this.Content, "russianhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(13, 11));
                 hatTexture = LoadContent(this.Content, "stetson");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(12, 0));
                 hatTexture = LoadContent(this.Content, "wizardhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(17, 2));

                 hatsHats.Add(hats);
                 hatTexs.Add(hatTexture);
                 hatTexs = new List<Texture2D>();
                 hats = new List<Animation>();
                 hatPos = new List<Vector2>();
                 hatTexture = LoadContent(this.Content, "ricehat");
                 hatTexs.Add(hatTexture);
                 hatPos.Add(new Vector2(8, 10));

                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatTexture = LoadContent(this.Content, "boater");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(15, 8));
                 hatTexture = LoadContent(this.Content, "chefhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(14, 1));
                 hatTexture = LoadContent(this.Content, "christmashat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(14, 5));
                 hatTexture = LoadContent(this.Content, "dmed");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(14, 6));
                 hatTexture = LoadContent(this.Content, "elfhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(18, 3));
                 hatTexture = LoadContent(this.Content, "fez");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(19, 3));
                 hatTexture = LoadContent(this.Content, "vikinghat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(13, 4));

                 hatTexture = LoadContent(this.Content, "pilgrimmhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(18, 4));

                 hatTexture = LoadContent(this.Content, "piratehat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(11, 7));

                 hatTexture = LoadContent(this.Content, "russianhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(13, 11));
                 hatTexture = LoadContent(this.Content, "stetson");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(12, 0));
                 hatTexture = LoadContent(this.Content, "wizardhat");
                 hatTexs.Add(hatTexture);
                 hat = new Animation();
                 hat.LoadTexture(hatTexture);
                 hats.Add(hat);
                 hatPos.Add(new Vector2(17, 2));

                 hatsHats.Add(hats);


        }
Example #16
0
        public void HatSelect(GameTime gameTime, int num)
        {
            
            if (0 <= playerHatNums[num ] && playerHatNums[num ] < hatTexs.Count)
            {
                menuTime = 1000;
                elapsedTime += gameTime.ElapsedGameTime.Milliseconds;
                if (elapsedTime > menuTime)
                {
                    int plyerindex = num;
                    if ((int)(GamePad.GetState((PlayerIndex)(plyerindex)).ThumbSticks.Left.X) >= 1)
                    {
                    playerHatNums[num ] += 1;
                    
                    elapsedTime = 0;
                    }
                    if ((int)(GamePad.GetState((PlayerIndex)(plyerindex)).ThumbSticks.Left.X) <= -1)
                    {
                        playerHatNums[num] -= 1;

                        elapsedTime = 0;
                    }


                }

            }


            if (0 > playerHatNums[num])
            {
                playerHatNums[num] = 0;
                
            }
            if (playerHatNums[num] >= 13)
            {
                playerHatNums[num ] = 12;
            }
            selectIcon = new Animation();
            selectIcon = hatsHats[num][playerHatNums[num]];
            Vector2 headPos = new Vector2(graphics.PreferredBackBufferWidth * (num + 1) / 5   ,
                 graphics.PreferredBackBufferHeight * 2 / 3 - playerBodyTex.Height/2 - playerHeadTex.Height/2);
            selectIcon.Initialize(1, 1, headPos  - new Vector2(playerHeadTex.Width / 2, playerHeadTex.Height / 2) * 2 + hatPos[playerHatNums[num]], 0, Color.White);
           
            selectHats[num] = selectIcon;
            
        }
Example #17
0
        public void InitializeMainMenu()
        {
            playButtonAnimation = new Animation();
            playButtonAnimation.LoadTexture(playButtonTex);
            exitButtonAnimation = new Animation();
            exitButtonAnimation.LoadTexture(exitButtonTex);
            menuButtons = new List<Button>();

            
            Button button = new Button();
            button.Initialize(new Vector2((1920) / 2, 500 + 140 / 2), playButtonAnimation, "play", 1);
            menuButtons.Add(button);

            button = new Button();
            button.Initialize(new Vector2((1920) / 2, 700 + 140 / 2), exitButtonAnimation, "exit", 2);
            menuButtons.Add(button);
        }
Example #18
0
 public static bool CollidesWith(Animation objectA, Animation objectB, Matrix aTransform, Matrix bTransform)
 {
     return CollidesWith(objectA, objectB, aTransform, bTransform, true);
 }
Example #19
0
 public static bool CollidesWith(Animation objectA, Animation objectB, Matrix aTransform, Matrix bTransform, Point lineorigin, Point lineend)
 {
     return CollidesWith(objectA, objectB, aTransform, bTransform, true);
 }