Exemplo n.º 1
0
        protected override void Update()
        {
            if (IsEnabled)
            {
                switch (ControllerType)
                {
                case SupportedControllers.ArcadeBoard:

                    // Shoot Main Weapon on B1 Press
                    if ((ArcadeControls.ButtonHeldDown(Player, Buttons.B1)) && (CanShootMain))
                    {
                        audioManager.Play("Shoot", Random.Range(.04f, .1f), Random.Range(.9f, 1f));
                        CanShootMain = false;
                        StartCoroutine(base.ShootMainWeapon(Vector2.up, 10, (int)Player + 1));
                    }

                    // Shoot Alt Weapon on B2 Press
                    if ((ArcadeControls.ButtonPress(Player, Buttons.B2)) && (CanShootAlt))
                    {
                        audioManager.PlayFromTime("MissileShoot", .5f, .2f);
                        CanShootAlt = false;
                        StartCoroutine(base.ShootAltWeapon(Vector2.up, 10, (int)Player + 1));
                    }

                    // Use Special Move on B3 Press
                    if ((ArcadeControls.ButtonPress(Player, Buttons.B3)) && (CanUseSpecialMove))
                    {
                        ExecuteSpecialMove();
                    }

                    // Shield - Protect from bolts
                    if ((ArcadeControls.ButtonPress(Player, Buttons.B4)) && (CanChangeSheildType))
                    {
                        ActiveShieldType = ShieldTypes.Bolts;
                        PlayerStats.shieldSwitches++;
                    }

                    // Shield - Protect from misisles
                    if ((ArcadeControls.ButtonPress(Player, Buttons.B5)) && (CanChangeSheildType))
                    {
                        ActiveShieldType = ShieldTypes.Missiles;
                        PlayerStats.shieldSwitches++;
                    }

                    // Shield - Regen Shields
                    if ((ArcadeControls.ButtonPress(Player, Buttons.B6)) && (CanChangeSheildType))
                    {
                        ActiveShieldType = ShieldTypes.Regen;
                        PlayerStats.shieldSwitches++;
                    }

                    break;

                case SupportedControllers.GamePadBoth:

                    // Shoot Main Weapon on B1 Press
                    if ((ControllerControls.ButtonHeldDown(ConvertToPlayers(), ControllerButtons.A)) && (CanShootMain))
                    {
                        audioManager.Play("Shoot", Random.Range(.04f, .1f), Random.Range(.9f, 1f));
                        CanShootMain = false;
                        StartCoroutine(base.ShootMainWeapon(Vector2.up, 10, (int)Player + 1));
                    }

                    // Shoot Alt Weapon on B2 Press
                    if ((ControllerControls.ButtonPress(ConvertToPlayers(), ControllerButtons.B)) && (CanShootAlt))
                    {
                        audioManager.PlayFromTime("MissileShoot", .5f, .2f);
                        CanShootAlt = false;
                        StartCoroutine(base.ShootAltWeapon(Vector2.up, 10, (int)Player + 1));
                    }

                    // Use Special Move on B3 Press
                    if ((ControllerControls.ButtonPress(ConvertToPlayers(), ControllerButtons.X)) && (CanUseSpecialMove))
                    {
                        ExecuteSpecialMove();
                    }

                    // Shield - Protect from bolts
                    if ((ControllerControls.ButtonPress(ConvertToPlayers(), ControllerButtons.LB)) && (CanChangeSheildType))
                    {
                        ActiveShieldType = ShieldTypes.Bolts;
                        PlayerStats.shieldSwitches++;
                    }

                    // Shield - Protect from misisles
                    if ((ControllerControls.ButtonPress(ConvertToPlayers(), ControllerButtons.RB)) && (CanChangeSheildType))
                    {
                        ActiveShieldType = ShieldTypes.Missiles;
                        PlayerStats.shieldSwitches++;
                    }

                    // Shield - Regen Shields
                    if ((ControllerControls.ButtonPress(ConvertToPlayers(), ControllerButtons.Y)) && (CanChangeSheildType))
                    {
                        ActiveShieldType = ShieldTypes.Regen;
                        PlayerStats.shieldSwitches++;
                    }

                    break;

                case SupportedControllers.KeyboardBoth:

                    // Shoot Main Weapon on B1 Press
                    if ((KeyboardControls.ButtonHeldDown(ConvertToPlayers(), Buttons.B1)) && (CanShootMain))
                    {
                        audioManager.Play("Shoot", Random.Range(.04f, .1f), Random.Range(.9f, 1f));
                        CanShootMain = false;
                        StartCoroutine(base.ShootMainWeapon(Vector2.up, 10, (int)Player + 1));
                    }

                    // Shoot Alt Weapon on B2 Press
                    if ((KeyboardControls.ButtonPress(ConvertToPlayers(), Buttons.B2)) && (CanShootAlt))
                    {
                        audioManager.PlayFromTime("MissileShoot", .5f, .2f);
                        CanShootAlt = false;
                        StartCoroutine(base.ShootAltWeapon(Vector2.up, 10, (int)Player + 1));
                    }

                    // Use Special Move on B3 Press
                    if ((KeyboardControls.ButtonPress(ConvertToPlayers(), Buttons.B3)) && (CanUseSpecialMove))
                    {
                        ExecuteSpecialMove();
                    }

                    // Shield - Protect from bolts
                    if ((KeyboardControls.ButtonPress(ConvertToPlayers(), Buttons.B4)) && (CanChangeSheildType))
                    {
                        ActiveShieldType = ShieldTypes.Bolts;
                        PlayerStats.shieldSwitches++;
                    }

                    // Shield - Protect from misisles
                    if ((KeyboardControls.ButtonPress(ConvertToPlayers(), Buttons.B5)) && (CanChangeSheildType))
                    {
                        ActiveShieldType = ShieldTypes.Missiles;
                        PlayerStats.shieldSwitches++;
                    }

                    // Shield - Regen Shields
                    if ((KeyboardControls.ButtonPress(ConvertToPlayers(), Buttons.B6)) && (CanChangeSheildType))
                    {
                        ActiveShieldType = ShieldTypes.Regen;
                        PlayerStats.shieldSwitches++;
                    }

                    break;

                case SupportedControllers.KeyboardP1ControllerP2:

                    if (ConvertToPlayers() == Players.P1)
                    {
                        // Shoot Main Weapon on B1 Press
                        if ((KeyboardControls.ButtonHeldDown(Players.P1, Buttons.B1)) && (CanShootMain))
                        {
                            audioManager.Play("Shoot", Random.Range(.04f, .1f), Random.Range(.9f, 1f));
                            CanShootMain = false;
                            StartCoroutine(base.ShootMainWeapon(Vector2.up, 10, (int)Player + 1));
                        }

                        // Shoot Alt Weapon on B2 Press
                        if ((KeyboardControls.ButtonPress(Players.P1, Buttons.B2)) && (CanShootAlt))
                        {
                            audioManager.PlayFromTime("MissileShoot", .5f, .2f);
                            CanShootAlt = false;
                            StartCoroutine(base.ShootAltWeapon(Vector2.up, 10, (int)Player + 1));
                        }

                        // Use Special Move on B3 Press
                        if ((KeyboardControls.ButtonPress(Players.P1, Buttons.B3)) && (CanUseSpecialMove))
                        {
                            ExecuteSpecialMove();
                        }

                        // Shield - Protect from bolts
                        if ((KeyboardControls.ButtonPress(Players.P1, Buttons.B4)) && (CanChangeSheildType))
                        {
                            ActiveShieldType = ShieldTypes.Bolts;
                            PlayerStats.shieldSwitches++;
                        }

                        // Shield - Protect from misisles
                        if ((KeyboardControls.ButtonPress(Players.P1, Buttons.B5)) && (CanChangeSheildType))
                        {
                            ActiveShieldType = ShieldTypes.Missiles;
                            PlayerStats.shieldSwitches++;
                        }

                        // Shield - Regen Shields
                        if ((KeyboardControls.ButtonPress(Players.P1, Buttons.B6)) && (CanChangeSheildType))
                        {
                            ActiveShieldType = ShieldTypes.Regen;
                            PlayerStats.shieldSwitches++;
                        }
                    }
                    else
                    {
                        // Shoot Main Weapon on B1 Press
                        if ((ControllerControls.ButtonHeldDown(Players.P1, ControllerButtons.A)) && (CanShootMain))
                        {
                            audioManager.Play("Shoot", Random.Range(.04f, .1f), Random.Range(.9f, 1f));
                            CanShootMain = false;
                            StartCoroutine(base.ShootMainWeapon(Vector2.up, 10, (int)Player + 1));
                        }

                        // Shoot Alt Weapon on B2 Press
                        if ((ControllerControls.ButtonPress(Players.P1, ControllerButtons.B)) && (CanShootAlt))
                        {
                            audioManager.PlayFromTime("MissileShoot", .5f, .2f);
                            CanShootAlt = false;
                            StartCoroutine(base.ShootAltWeapon(Vector2.up, 10, (int)Player + 1));
                        }

                        // Use Special Move on B3 Press
                        if ((ControllerControls.ButtonPress(Players.P1, ControllerButtons.X)) && (CanUseSpecialMove))
                        {
                            ExecuteSpecialMove();
                        }

                        // Shield - Protect from bolts
                        if ((ControllerControls.ButtonPress(Players.P1, ControllerButtons.LB)) && (CanChangeSheildType))
                        {
                            ActiveShieldType = ShieldTypes.Bolts;
                            PlayerStats.shieldSwitches++;
                        }

                        // Shield - Protect from misisles
                        if ((ControllerControls.ButtonPress(Players.P1, ControllerButtons.RB)) && (CanChangeSheildType))
                        {
                            ActiveShieldType = ShieldTypes.Missiles;
                            PlayerStats.shieldSwitches++;
                        }

                        // Shield - Regen Shields
                        if ((ControllerControls.ButtonPress(Players.P1, ControllerButtons.Y)) && (CanChangeSheildType))
                        {
                            ActiveShieldType = ShieldTypes.Regen;
                            PlayerStats.shieldSwitches++;
                        }
                    }

                    break;

                case SupportedControllers.KeyboardP2ControllerP1:

                    if (ConvertToPlayers() == Players.P2)
                    {
                        // Shoot Main Weapon on B1 Press
                        if ((KeyboardControls.ButtonHeldDown(Players.P1, Buttons.B1)) && (CanShootMain))
                        {
                            audioManager.Play("Shoot", Random.Range(.04f, .1f), Random.Range(.9f, 1f));
                            CanShootMain = false;
                            StartCoroutine(base.ShootMainWeapon(Vector2.up, 10, (int)Player + 1));
                        }

                        // Shoot Alt Weapon on B2 Press
                        if ((KeyboardControls.ButtonPress(Players.P1, Buttons.B2)) && (CanShootAlt))
                        {
                            audioManager.PlayFromTime("MissileShoot", .5f, .2f);
                            CanShootAlt = false;
                            StartCoroutine(base.ShootAltWeapon(Vector2.up, 10, (int)Player + 1));
                        }

                        // Use Special Move on B3 Press
                        if ((KeyboardControls.ButtonPress(Players.P1, Buttons.B3)) && (CanUseSpecialMove))
                        {
                            ExecuteSpecialMove();
                        }

                        // Shield - Protect from bolts
                        if ((KeyboardControls.ButtonPress(Players.P1, Buttons.B4)) && (CanChangeSheildType))
                        {
                            ActiveShieldType = ShieldTypes.Bolts;
                            PlayerStats.shieldSwitches++;
                        }

                        // Shield - Protect from misisles
                        if ((KeyboardControls.ButtonPress(Players.P1, Buttons.B5)) && (CanChangeSheildType))
                        {
                            ActiveShieldType = ShieldTypes.Missiles;
                            PlayerStats.shieldSwitches++;
                        }

                        // Shield - Regen Shields
                        if ((KeyboardControls.ButtonPress(Players.P1, Buttons.B6)) && (CanChangeSheildType))
                        {
                            ActiveShieldType = ShieldTypes.Regen;
                            PlayerStats.shieldSwitches++;
                        }
                    }
                    else
                    {
                        // Shoot Main Weapon on B1 Press
                        if ((ControllerControls.ButtonHeldDown(Players.P1, ControllerButtons.A)) && (CanShootMain))
                        {
                            audioManager.Play("Shoot", Random.Range(.04f, .1f), Random.Range(.9f, 1f));
                            CanShootMain = false;
                            StartCoroutine(base.ShootMainWeapon(Vector2.up, 10, (int)Player + 1));
                        }

                        // Shoot Alt Weapon on B2 Press
                        if ((ControllerControls.ButtonPress(Players.P1, ControllerButtons.B)) && (CanShootAlt))
                        {
                            audioManager.PlayFromTime("MissileShoot", .5f, .2f);
                            CanShootAlt = false;
                            StartCoroutine(base.ShootAltWeapon(Vector2.up, 10, (int)Player + 1));
                        }

                        // Use Special Move on B3 Press
                        if ((ControllerControls.ButtonPress(Players.P1, ControllerButtons.X)) && (CanUseSpecialMove))
                        {
                            ExecuteSpecialMove();
                        }

                        // Shield - Protect from bolts
                        if ((ControllerControls.ButtonPress(Players.P1, ControllerButtons.LB)) && (CanChangeSheildType))
                        {
                            ActiveShieldType = ShieldTypes.Bolts;
                            PlayerStats.shieldSwitches++;
                        }

                        // Shield - Protect from misisles
                        if ((ControllerControls.ButtonPress(Players.P1, ControllerButtons.RB)) && (CanChangeSheildType))
                        {
                            ActiveShieldType = ShieldTypes.Missiles;
                            PlayerStats.shieldSwitches++;
                        }

                        // Shield - Regen Shields
                        if ((ControllerControls.ButtonPress(Players.P1, ControllerButtons.Y)) && (CanChangeSheildType))
                        {
                            ActiveShieldType = ShieldTypes.Regen;
                            PlayerStats.shieldSwitches++;
                        }
                    }

                    break;

                default:
                    break;
                }
            }

            // Runs the base update function on ship movement
            base.Update();


            // Clamp the players to the scene view (so they can't dodge off screen)
        }