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