Beispiel #1
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;
 }
Beispiel #2
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);
 }
Beispiel #3
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);
        }
Beispiel #4
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);
         }
     }
 }
Beispiel #5
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);

        }
Beispiel #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();
 }
Beispiel #7
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;
            
        }
Beispiel #8
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);
 }