Ejemplo n.º 1
0
        public void playerControls()
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Space))
            {
                uiManager.calculatePower();
                chargingShot = true;
            }

            if (Keyboard.GetState().IsKeyUp(Keys.Space) && chargingShot)
            {
                currentTank.shoot(power);
                chargingShot = false;
                shotFired    = true;
                setPreviousShotLine();
            }

            //Controller Check for shooting
            if (controller.IsButtonDown(Buttons.RightTrigger))
            {
                uiManager.calculatePower();
                chargingShot2 = true;
            }
            if (controller.IsButtonUp(Buttons.RightTrigger) && chargingShot2)
            {
                currentTank.shoot(power);
                chargingShot2 = false;
                shotFired     = true;
                setPreviousShotLine();
            }

            if (Keyboard.GetState().IsKeyDown(Keys.D1))
            {
                currentTank.type = BulletType.BasicBullet;
            }

            if (Keyboard.GetState().IsKeyDown(Keys.D2))
            {
                if (currentTank.inventory.getShotCount(BulletType.HeavyShot) > 0)
                {
                    currentTank.type = BulletType.HeavyShot;
                }
            }

            if (Keyboard.GetState().IsKeyDown(Keys.D3))
            {
                if (currentTank.inventory.getShotCount(BulletType.ScatterShot) > 0)
                {
                    currentTank.type = BulletType.ScatterShot;
                }
            }

            if (Keyboard.GetState().IsKeyDown(Keys.D4))
            {
                currentTank.type = BulletType.TeleportShot;
            }

            if (Keyboard.GetState().IsKeyDown(Keys.D5))
            {
                currentTank.type = BulletType.MissileDrop;
            }

            //Swapping Weapons
            if (controller.IsButtonDown(Buttons.RightShoulder) & !rightSwap)
            {
                currentTank.type = currentTank.nextWeapon();
                rightSwap        = true;
            }
            if (controller.IsButtonUp(Buttons.RightShoulder))
            {
                rightSwap = false;
            }
            if (controller.IsButtonDown(Buttons.LeftShoulder) & !leftSwap)
            {
                currentTank.type = currentTank.previousWeapon();
                leftSwap         = true;
            }
            if (controller.IsButtonUp(Buttons.LeftShoulder))
            {
                leftSwap = false;
            }

            //Gives UIManager the Bullet Type for display
            uiManager.takeBulletType(currentTank.type, currentTank.inventory.getShotCount(currentTank.type));
        }