Inheritance: MonoBehaviour
Exemple #1
11
        public static void Main(string[] args)
        {
            Console.WindowWidth = ConsoleWidth;
            Console.WindowHeight = ConsoleHeight;
            Console.BufferHeight = Console.WindowHeight;
            Console.BufferWidth = Console.WindowWidth;
            Console.CursorVisible = false;

            KeyboardControls keyboard = new KeyboardControls();
            keyboard.OnLeftPress += HandleOnLeftPress;
            keyboard.OnRightPress += HandleOnRightPress;
            keyboard.OnUpPress += HandleOnUpPress;
            keyboard.OnDownPress += HandleOnDownPress;
            keyboard.OnEscape += HandleOnEscape;

            bool placeFood = false;
            Food food = new Food(RandomNumber.Generate(0, ConsoleWidth), RandomNumber.Generate(0, ConsoleHeight), '+');

            while (runGame)
            {
                Console.Clear();
                keyboard.ProcessInput();
                snake.Draw();
                snake.Update();

                food.Draw();
                if (placeFood)
                {
                    food = new Food(RandomNumber.Generate(0, ConsoleWidth), RandomNumber.Generate(0, ConsoleHeight), '+');
                    placeFood = false;
                }

                if (food.Position.X == snake.Body[0].Position.X && food.Position.Y == snake.Body[0].Position.Y)
                {
                    Console.Beep();
                    snake.AddBodyPart();
                    placeFood = true;
                }

                if (snake.Body[0].Position.X < 0 ||
                    snake.Body[0].Position.X >= ConsoleWidth ||
                    snake.Body[0].Position.Y < 0 ||
                    snake.Body[0].Position.Y >= ConsoleHeight)
                {
                    runGame = false;
                }

                for (int i = 1; i < snake.Body.Count; i++)
                {
                    if (snake.Body[0].Position.X == snake.Body[i].Position.X && snake.Body[0].Position.Y == snake.Body[i].Position.Y)
                    {
                        runGame = false;
                        break;
                    }
                }

                Thread.Sleep(ThreadSpeed);
            }

            Console.WriteLine("Thanks for playing");
        }
Exemple #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            #region Load Textures
            MarioSpriteFactory.Instance.LoadAllTextures(Content);
            EnemySpriteFactory.Instance.LoadAllTextures(Content);
            ItemSpriteFactory.Instance.LoadAllTextures(Content);
            BlockSpriteFactory.Instance.LoadAllTextures(Content);
            FireballSpriteFactory.Instance.LoadAllTextures(Content);
            BackgroundSpriteFactory.Instance.LoadAllTextures(Content);
            PipeSpriteFactory.Instance.LoadAllTextures(Content);
            SoundManager.Instance.LoadAllSounds(Content);
            TextSpriteFactory.Instance.LoadAllTextures(Content);
            #endregion

            Vector2 location = new Vector2(50, 200);
            Mario         = new MarioObject(location);
            objectManager = new GameObjectManager(this, Mario);
            gamedata      = new GameData(objectManager);
            camera1       = new Camera();
            Camera.LimitationList.Add(3600);
            camera2         = new Camera2D(GraphicsDevice.Viewport);
            blackbackground = BackgroundSpriteFactory.Instance.CreateBlackBackgroundSprite();
            LevelLoader loader = new LevelLoader(objectManager, Mario);
            loader.Load();
            keyboard = new KeyboardControls(this, Mario);
            gamepad  = new GamePadControls(this, Mario);
        }
Exemple #3
0
        public void LevelReset()
        {
            Vector2 restartPoint = GameObjectManager.restartPoint;

            spriteBatch = new SpriteBatch(GraphicsDevice);

            #region Load Textures
            MarioSpriteFactory.Instance.LoadAllTextures(Content);
            EnemySpriteFactory.Instance.LoadAllTextures(Content);
            ItemSpriteFactory.Instance.LoadAllTextures(Content);
            BlockSpriteFactory.Instance.LoadAllTextures(Content);
            FireballSpriteFactory.Instance.LoadAllTextures(Content);
            BackgroundSpriteFactory.Instance.LoadAllTextures(Content);
            PipeSpriteFactory.Instance.LoadAllTextures(Content);
            SoundManager.Instance.LoadAllSounds(Content);
            TextSpriteFactory.Instance.LoadAllTextures(Content);
            #endregion

            Mario         = new MarioObject(restartPoint);
            objectManager = new GameObjectManager(this, Mario);
            gamedata      = new GameData(objectManager);
            camera1       = new Camera();
            Camera.LimitationList.Add(3600);
            camera2         = new Camera2D(GraphicsDevice.Viewport);
            blackbackground = BackgroundSpriteFactory.Instance.CreateBlackBackgroundSprite();
            LevelLoader loader = new LevelLoader(objectManager, Mario);
            loader.Load();
            keyboard = new KeyboardControls(this, Mario);
            gamepad  = new GamePadControls(this, Mario);
            Camera.SetCamera(new Vector2(restartPoint.X - 16 * 5, 0));
            MarioInfo.ClearTimer();
            MarioInfo.ResetTimer();
            MarioInfo.StartTimer();
        }
 public LocalPlayer(Game game, long sessionID, int id, string imageAssetPath, Vector2 position, float angle, PhysicsSimulator physicsSimulator, float speed, float mass, CollisionCategory collisionCategories, short index, KeyboardControls controls, ProjectileFactory projectileFactory) : base(game, sessionID, id, imageAssetPath, position, angle, physicsSimulator, speed, mass, collisionCategories, index)
 {
     Controls = controls;
     this.projectileFactory = projectileFactory;
     Projectiles = new List<ProjectileLocal>();
     Geometry.OnCollision += OnCollision;
     Body.LinearDragCoefficient = 100;
     Body.RotationalDragCoefficient = 6000;
 }
Exemple #5
0
        private void OnWalk(float axis)
        {
            KeyboardControls keyboard;
            PlayerControls   player;

            if (!KeyboardControls.TryGetInstance(out keyboard) || !PlayerControls.TryGetInstance(out player))
            {
                return;
            }
            Vector3 forward = SceneObjects.Instance.CameraControls.GetFlatForward();
            Vector3 right   = SceneObjects.Instance.CameraControls.GetFlatRight();

            WalkDirection  = Vector3.zero;
            WalkDirection += keyboard.CheckKey(player.Forward) ? forward : Vector3.zero;
            WalkDirection += keyboard.CheckKey(player.Back) ? -forward : Vector3.zero;
            WalkDirection += keyboard.CheckKey(player.Right) ? right : Vector3.zero;
            WalkDirection += keyboard.CheckKey(player.Left) ? -right : Vector3.zero;
            WalkDirection.Normalize();
        }
Exemple #6
0
        void Update()
        {
            if (KeyboardControls.ButtonPress((Players)ThisPlayer, Buttons.B3))
            {
                // if the script is not spawning a ball
                if (!IsSpawning)
                {
                    // run the ball spawning corutine
                    StartCoroutine(SpawnBall());
                }
            }

            if ((!IsSpawningAuto) && (CanSpawnAuto))
            {
                StartCoroutine(SpawnBallAuto());
            }


            switch (NumberSpawned)
            {
            case 1:
                AutoSpawnDelay = 7.5f;
                break;

            case 2:
                AutoSpawnDelay = 6f;
                break;

            case 4:
                AutoSpawnDelay = 5f;
                break;

            case 8:
                AutoSpawnDelay = 4f;
                break;

            default:
                break;
            }
        }
Exemple #7
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)
        }
Exemple #8
0
        public int GetLRDir()
        {
            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                if ((ArcadeControls.JoystickLeft(Joysticks.White)) && (!isCoR))
                {
                    return(-1);
                }
                if ((ArcadeControls.JoystickRight(Joysticks.White)) && (!isCoR))
                {
                    return(1);
                }
                else
                {
                    return(0);
                }

            case SupportedControllers.GamePadBoth:

                if ((ControllerControls.ControllerLeft(Players.P1)) && (!isCoR))
                {
                    return(-1);
                }
                if ((ControllerControls.ControllerRight(Players.P1)) && (!isCoR))
                {
                    return(1);
                }
                else
                {
                    return(0);
                }

            case SupportedControllers.KeyboardBoth:

                if ((KeyboardControls.KeyboardLeft(Players.P1)) && (!isCoR))
                {
                    return(-1);
                }
                if ((KeyboardControls.KeyboardRight(Players.P1)) && (!isCoR))
                {
                    return(1);
                }
                else
                {
                    return(0);
                }

            case SupportedControllers.KeyboardP1ControllerP2:

                if ((KeyboardControls.KeyboardLeft(Players.P1)) && (!isCoR))
                {
                    return(-1);
                }
                if ((KeyboardControls.KeyboardRight(Players.P1)) && (!isCoR))
                {
                    return(1);
                }
                else
                {
                    return(0);
                }

            case SupportedControllers.KeyboardP2ControllerP1:

                if ((ControllerControls.ControllerLeft(Players.P1)) && (!isCoR))
                {
                    return(-1);
                }
                if ((ControllerControls.ControllerRight(Players.P1)) && (!isCoR))
                {
                    return(1);
                }
                else
                {
                    return(0);
                }

            default:
                return(0);
            }
        }
Exemple #9
0
        private new void Update()
        {
            if (currentScreen == Screens.Input)
            {
                if (P1Ready && P2Ready /*&& (!string.IsNullOrEmpty(keyboards[0].InputtedValue)) && (!string.IsNullOrEmpty(keyboards[1].InputtedValue))*/)
                {
                    if (Confirm())
                    {
                        loadedData          = SaveManager.LoadOperationStarshine();
                        changeToLeaderboard = true;
                    }
                }

                // Keyboard backlights and confirming
                switch (ControllerType)
                {
                case SupportedControllers.ArcadeBoard:

                    // Player 1
                    if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B8) && (!P1Ready))
                    {
                        P1Ready = true;
                        keyboards[0].enabled = false;
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B7) && (P1Ready))
                    {
                        P1Ready = false;
                        keyboards[0].enabled = true;
                        keyboards[0].ShowSelected();
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = P1PreviousCol;
                    }

                    // Player 2
                    if (ArcadeControls.ButtonPress(Joysticks.Black, Buttons.B8) && (!P2Ready))
                    {
                        P2Ready = true;
                        keyboards[1].enabled = false;
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (ArcadeControls.ButtonPress(Joysticks.Black, Buttons.B7) && (P2Ready))
                    {
                        P2Ready = false;
                        keyboards[1].enabled = true;
                        keyboards[1].ShowSelected();
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = P2PreviousCol;
                    }

                    break;

                case SupportedControllers.GamePadBoth:

                    // Player 1
                    if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.Confirm) && (!P1Ready))
                    {
                        P1Ready = true;
                        keyboards[0].enabled = false;
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.Return) && (P1Ready))
                    {
                        P1Ready = false;
                        keyboards[0].enabled = true;
                        keyboards[0].ShowSelected();
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = P1PreviousCol;
                    }

                    // Player 2
                    if (ControllerControls.ButtonPress(Players.P2, ControllerButtons.Confirm) && (!P2Ready))
                    {
                        P2Ready = true;
                        keyboards[1].enabled = false;
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (ControllerControls.ButtonPress(Players.P2, ControllerButtons.Return) && (P2Ready))
                    {
                        P2Ready = false;
                        keyboards[1].enabled = true;
                        keyboards[1].ShowSelected();
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = P2PreviousCol;
                    }

                    break;

                case SupportedControllers.KeyboardBoth:

                    // Player 1
                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8) && (!P1Ready))
                    {
                        P1Ready = true;
                        keyboards[0].enabled = false;
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7) && (P1Ready))
                    {
                        P1Ready = false;
                        keyboards[0].enabled = true;
                        keyboards[0].ShowSelected();
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = P1PreviousCol;
                    }

                    // Player 2
                    if (KeyboardControls.ButtonPress(Players.P2, Buttons.B8) && (!P2Ready))
                    {
                        P2Ready = true;
                        keyboards[1].enabled = false;
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (KeyboardControls.ButtonPress(Players.P2, Buttons.B7) && (P2Ready))
                    {
                        P2Ready = false;
                        keyboards[1].enabled = true;
                        keyboards[1].ShowSelected();
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = P2PreviousCol;
                    }

                    break;

                case SupportedControllers.KeyboardP1ControllerP2:

                    // Player 1
                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8) && (!P1Ready))
                    {
                        P1Ready = true;
                        keyboards[0].enabled = false;
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7) && (P1Ready))
                    {
                        P1Ready = false;
                        keyboards[0].enabled = true;
                        keyboards[0].ShowSelected();
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = P1PreviousCol;
                    }

                    // Player 2
                    if (ControllerControls.ButtonPress(Players.P2, ControllerButtons.Confirm) && (!P2Ready))
                    {
                        P2Ready = true;
                        keyboards[1].enabled = false;
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (ControllerControls.ButtonPress(Players.P2, ControllerButtons.Return) && (P2Ready))
                    {
                        P2Ready = false;
                        keyboards[1].enabled = true;
                        keyboards[1].ShowSelected();
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = P2PreviousCol;
                    }

                    break;

                case SupportedControllers.KeyboardP2ControllerP1:

                    // Player 1
                    if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.Confirm) && (!P1Ready))
                    {
                        P1Ready = true;
                        keyboards[0].enabled = false;
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.Return) && (P1Ready))
                    {
                        P1Ready = false;
                        keyboards[0].enabled = true;
                        keyboards[0].ShowSelected();
                        keyboards[0].GetComponentsInChildren <Image>()[0].color = P1PreviousCol;
                    }

                    // Player 2
                    if (KeyboardControls.ButtonPress(Players.P2, Buttons.B8) && (!P2Ready))
                    {
                        P2Ready = true;
                        keyboards[1].enabled = false;
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = confirmCol;
                    }

                    if (KeyboardControls.ButtonPress(Players.P2, Buttons.B7) && (P2Ready))
                    {
                        P2Ready = false;
                        keyboards[1].enabled = true;
                        keyboards[1].ShowSelected();
                        keyboards[1].GetComponentsInChildren <Image>()[0].color = P2PreviousCol;
                    }

                    break;

                default:
                    break;
                }

                // if move screen - do canvas grouip fades
                if ((changeToLeaderboard) && (canvasGroups[0].alpha != 0) && (canvasGroups[1].alpha != 1))
                {
                    canvasGroups[0].alpha -= 2 * Time.deltaTime;
                    canvasGroups[1].alpha += 2 * Time.deltaTime;

                    if (canvasGroups[0].alpha == 0 && canvasGroups[1].alpha == 1)
                    {
                        if (keyboards[0].GetFinalValue() != null)
                        {
                            leaderboardData.Player1Name = keyboards[0].GetFinalValue();
                        }
                        else
                        {
                            leaderboardData.Player1Name = "Unknown";
                        }

                        if (keyboards[1].GetFinalValue() != null)
                        {
                            leaderboardData.Player2Name = keyboards[1].GetFinalValue();
                        }
                        else
                        {
                            leaderboardData.Player2Name = "Unknown";
                        }

                        leaderboardData.Player1Score    = loadedData.Player1Score;
                        leaderboardData.Player2Score    = loadedData.Player2Score;
                        leaderboardData.Player1ShipName = ConvertToShipName(loadedData.LastPlayer1ShipSelection);
                        leaderboardData.Player2ShipName = ConvertToShipName(loadedData.LastPlayer2ShipSelection);

                        if (ControllerType == SupportedControllers.ArcadeBoard)
                        {
                            leaderboardData.Platform = "Arcade";
                        }
                        else
                        {
                            leaderboardData.Platform = "PC";
                        }

                        isLeaderboardScreen = true;
                        currentScreen       = Screens.Leaderboard;
                        sendScript.SendDataToBoard(leaderboardData);
                        UpdateStatsScreen();
                    }
                }
            }
            else
            {
                MoveUD();
                UpdateMenuOptions();
                UpdateStatsScreen();

                if (isLeaderboardScreen)
                {
                    UpdateLeaderboardRow();
                    isLeaderboardScreen = false;
                }

                if (Confirm())
                {
                    switch (pos)
                    {
                    case 0:
                        animator.SetBool("ChangeScene", true);
                        ChangeScene("Operation-Starshine-Level", 1.1f);
                        break;

                    case 1:
                        animator.SetBool("ChangeScene", true);
                        ChangeScene("Operation-Starshine-Menu", 1.1f);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Exemple #10
0
        /// <summary>
        /// Allow the player to move around in the scene
        /// </summary>
        void PlayerMovement()
        {
            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                if (ArcadeControls.JoystickLeft(Player))
                {
                    RB.velocity = Vector2.left * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.left);
                }

                if (ArcadeControls.JoystickRight(Player))
                {
                    RB.velocity = Vector2.right * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.right);
                }

                if (ArcadeControls.JoystickUp(Player))
                {
                    RB.velocity = Vector2.up * MoveSpd * Time.deltaTime;
                    //UpdateGunshipDirection(Vector2.up);
                }

                if (ArcadeControls.JoystickDown(Player))
                {
                    RB.velocity = Vector2.down * MoveSpd * Time.deltaTime;
                    //UpdateGunshipDirection(Vector2.down);
                }

                if (ArcadeControls.JoystickNorthEast(Player))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f));
                }

                if (ArcadeControls.JoystickNorthWest(Player))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f));
                }

                if (ArcadeControls.JoystickSouthEast(Player))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f));
                }

                if (ArcadeControls.JoystickSouthWest(Player))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f));
                }

                if (ArcadeControls.JoystickNone(Player))
                {
                    RB.velocity = Vector2.zero;
                }

                break;

            case SupportedControllers.GamePadBoth:

                if (ControllerControls.ControllerLeft(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.left * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.left);
                }

                if (ControllerControls.ControllerRight(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.right * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.right);
                }

                if (ControllerControls.ControllerUp(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.up * MoveSpd * Time.deltaTime;
                    //UpdateGunshipDirection(Vector2.up);
                }

                if (ControllerControls.ControllerDown(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.down * MoveSpd * Time.deltaTime;
                    //UpdateGunshipDirection(Vector2.down);
                }

                if (ControllerControls.ControllerLeftUp(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f));
                }

                if (ControllerControls.ControllerRightUp(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f));
                }

                if (ControllerControls.ControllerLeftDown(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f));
                }

                if (ControllerControls.ControllerRightDown(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f));
                }

                if (ControllerControls.ControllerNone(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.zero;
                }

                break;

            case SupportedControllers.KeyboardBoth:

                if (KeyboardControls.KeyboardLeft(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.left * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.left);
                }
                if (KeyboardControls.KeyboardRight(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.right * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.right);
                }
                if (KeyboardControls.KeyboardUp(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.up * MoveSpd * Time.deltaTime;
                    // UpdateGunshipDirection(Vector2.up);
                }
                if (KeyboardControls.KeyboardDown(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.down * MoveSpd * Time.deltaTime;
                    //UpdateGunshipDirection(Vector2.down);
                }
                if (KeyboardControls.KeyboardLeftUp(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f));
                }
                if (KeyboardControls.KeyboardRightUp(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f));
                }
                if (KeyboardControls.KeyboardLeftDown(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f));
                }
                if (KeyboardControls.KeyboardRightDown(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f));
                }
                if (KeyboardControls.KeyboardNone(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.zero;
                }

                break;

            case SupportedControllers.KeyboardP1ControllerP2:

                if (ConvertToPlayers() == Players.P1)
                {
                    if (KeyboardControls.KeyboardLeft(Players.P1))
                    {
                        RB.velocity = Vector2.left * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.left);
                    }
                    if (KeyboardControls.KeyboardRight(Players.P1))
                    {
                        RB.velocity = Vector2.right * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.right);
                    }
                    if (KeyboardControls.KeyboardUp(Players.P1))
                    {
                        RB.velocity = Vector2.up * MoveSpd * Time.deltaTime;
                        //UpdateGunshipDirection(Vector2.up);
                    }
                    if (KeyboardControls.KeyboardDown(Players.P1))
                    {
                        RB.velocity = Vector2.down * MoveSpd * Time.deltaTime;
                        //UpdateGunshipDirection(Vector2.down);
                    }
                    if (KeyboardControls.KeyboardLeftUp(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f));
                    }
                    if (KeyboardControls.KeyboardRightUp(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f));
                    }
                    if (KeyboardControls.KeyboardLeftDown(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f));
                    }
                    if (KeyboardControls.KeyboardRightDown(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f));
                    }
                    if (KeyboardControls.KeyboardNone(Players.P1))
                    {
                        RB.velocity = Vector2.zero;
                    }
                }
                else
                {
                    if (ControllerControls.ControllerLeft(Players.P1))
                    {
                        RB.velocity = Vector2.left * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.left);
                    }

                    if (ControllerControls.ControllerRight(Players.P1))
                    {
                        RB.velocity = Vector2.right * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.right);
                    }

                    if (ControllerControls.ControllerUp(Players.P1))
                    {
                        RB.velocity = Vector2.up * MoveSpd * Time.deltaTime;
                        //UpdateGunshipDirection(Vector2.up);
                    }

                    if (ControllerControls.ControllerDown(Players.P1))
                    {
                        RB.velocity = Vector2.down * MoveSpd * Time.deltaTime;
                        //UpdateGunshipDirection(Vector2.down);
                    }

                    if (ControllerControls.ControllerLeftUp(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f));
                    }

                    if (ControllerControls.ControllerRightUp(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f));
                    }

                    if (ControllerControls.ControllerLeftDown(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f));
                    }

                    if (ControllerControls.ControllerRightDown(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f));
                    }

                    if (ControllerControls.ControllerNone(Players.P1))
                    {
                        RB.velocity = Vector2.zero;
                    }
                }

                break;

            case SupportedControllers.KeyboardP2ControllerP1:

                if (ConvertToPlayers() == Players.P2)
                {
                    if (KeyboardControls.KeyboardLeft(Players.P1))
                    {
                        RB.velocity = Vector2.left * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.left);
                    }
                    if (KeyboardControls.KeyboardRight(Players.P1))
                    {
                        RB.velocity = Vector2.right * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.right);
                    }
                    if (KeyboardControls.KeyboardUp(Players.P1))
                    {
                        RB.velocity = Vector2.up * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.up);
                    }
                    if (KeyboardControls.KeyboardDown(Players.P1))
                    {
                        RB.velocity = Vector2.down * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.down);
                    }
                    if (KeyboardControls.KeyboardLeftUp(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f));
                    }
                    if (KeyboardControls.KeyboardRightUp(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f));
                    }
                    if (KeyboardControls.KeyboardLeftDown(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f));
                    }
                    if (KeyboardControls.KeyboardRightDown(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f));
                    }
                    if (KeyboardControls.KeyboardNone(Players.P1))
                    {
                        RB.velocity = Vector2.zero;
                    }
                }
                else
                {
                    if (ControllerControls.ControllerLeft(Players.P1))
                    {
                        RB.velocity = Vector2.left * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.left);
                    }

                    if (ControllerControls.ControllerRight(Players.P1))
                    {
                        RB.velocity = Vector2.right * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.right);
                    }

                    if (ControllerControls.ControllerUp(Players.P1))
                    {
                        RB.velocity = Vector2.up * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.up);
                    }

                    if (ControllerControls.ControllerDown(Players.P1))
                    {
                        RB.velocity = Vector2.down * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.down);
                    }

                    if (ControllerControls.ControllerLeftUp(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f));
                    }

                    if (ControllerControls.ControllerRightUp(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f));
                    }

                    if (ControllerControls.ControllerLeftDown(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f));
                    }

                    if (ControllerControls.ControllerRightDown(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f));
                    }

                    if (ControllerControls.ControllerNone(Players.P1))
                    {
                        RB.velocity = Vector2.zero;
                    }
                }

                break;

            default:
                break;
            }
        }
Exemple #11
0
        void MenuInput_MultiOption()
        {
            switch (InputDir)
            {
            case Directions.Hoz:

                switch (ControllerType)
                {
                case SupportedControllers.ArcadeBoard:

                    if (ArcadeControls.JoystickLeft(Joysticks.White))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (ArcadeControls.JoystickRight(Joysticks.White))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                case SupportedControllers.GamePadBoth:

                    if (ControllerControls.ControllerLeft(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (ControllerControls.ControllerRight(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                case SupportedControllers.KeyboardBoth:

                    if (KeyboardControls.KeyboardLeft(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (KeyboardControls.KeyboardRight(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                case SupportedControllers.KeyboardP1ControllerP2:

                    if (KeyboardControls.KeyboardLeft(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (KeyboardControls.KeyboardRight(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                case SupportedControllers.KeyboardP2ControllerP1:

                    if (ControllerControls.ControllerLeft(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (ControllerControls.ControllerRight(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                default:
                    break;
                }

                break;

            case Directions.Ver:

                switch (ControllerType)
                {
                case SupportedControllers.ArcadeBoard:

                    if (ArcadeControls.JoystickUp(Joysticks.White))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (ArcadeControls.JoystickDown(Joysticks.White))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                case SupportedControllers.GamePadBoth:

                    if (ControllerControls.ControllerUp(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (ControllerControls.ControllerDown(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                case SupportedControllers.KeyboardBoth:

                    if (KeyboardControls.KeyboardUp(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (KeyboardControls.KeyboardDown(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                case SupportedControllers.KeyboardP1ControllerP2:

                    if (KeyboardControls.KeyboardUp(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (KeyboardControls.KeyboardDown(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                case SupportedControllers.KeyboardP2ControllerP1:

                    if (ControllerControls.ControllerUp(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (ControllerControls.ControllerDown(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                default:
                    break;
                }

                break;
            }

            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B8))
                {
                    RunEvent();
                }

                break;

            case SupportedControllers.GamePadBoth:

                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.Confirm))
                {
                    RunEvent();
                }

                break;

            case SupportedControllers.KeyboardBoth:

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                {
                    RunEvent();
                }

                break;

            case SupportedControllers.KeyboardP1ControllerP2:

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                {
                    RunEvent();
                }

                break;

            case SupportedControllers.KeyboardP2ControllerP1:

                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.Confirm))
                {
                    RunEvent();
                }

                break;

            default:
                break;
            }
        }
Exemple #12
0
        protected override void Update()
        {
            base.Update();

            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B8))
                {
                    ConfirmEvent.Invoke();
                }
                if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B7))
                {
                    ReturnEvent.Invoke();
                }

                break;

            case SupportedControllers.GamePadBoth:

                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.A))
                {
                    ConfirmEvent.Invoke();
                }
                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.B))
                {
                    ReturnEvent.Invoke();
                }

                break;

            case SupportedControllers.KeyboardBoth:

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                {
                    ConfirmEvent.Invoke(); Debug.Log("I'm being pressed");
                }
                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7))
                {
                    ReturnEvent.Invoke();
                }

                break;

            case SupportedControllers.KeyboardP1ControllerP2:

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                {
                    ConfirmEvent.Invoke(); Debug.Log("I'm being pressed");
                }
                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7))
                {
                    ReturnEvent.Invoke();
                }

                break;

            case SupportedControllers.KeyboardP2ControllerP1:

                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.A))
                {
                    ConfirmEvent.Invoke();
                }
                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.B))
                {
                    ReturnEvent.Invoke();
                }

                break;

            default:
                break;
            }
        }
        void UndoConfirmOption(Joysticks PlayerInput)
        {
            switch (PlayerInput)
            {
            case Joysticks.White:

                switch (ControllerType)
                {
                case SupportedControllers.ArcadeBoard:

                    if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B7))
                    {
                        Player1Selected = false;
                    }

                    break;

                case SupportedControllers.GamePadBoth:

                    if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.B))
                    {
                        Player1Selected = false;
                    }

                    break;

                case SupportedControllers.KeyboardBoth:

                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7))
                    {
                        Player1Selected = false;
                    }

                    break;

                case SupportedControllers.KeyboardP1ControllerP2:

                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7))
                    {
                        Player1Selected = false;
                    }

                    break;

                case SupportedControllers.KeyboardP2ControllerP1:

                    if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.B))
                    {
                        Player1Selected = false;
                    }

                    break;

                default:
                    break;
                }

                Player1Confirmed.enabled = false;

                break;

            case Joysticks.Black:

                switch (ControllerType)
                {
                case SupportedControllers.ArcadeBoard:

                    if (ArcadeControls.ButtonPress(Joysticks.Black, Buttons.B7))
                    {
                        Player2Selected = false;
                    }

                    break;

                case SupportedControllers.GamePadBoth:

                    if (ControllerControls.ButtonPress(Players.P2, ControllerButtons.B))
                    {
                        Player2Selected = false;
                    }

                    break;

                case SupportedControllers.KeyboardBoth:

                    if (KeyboardControls.ButtonPress(Players.P2, Buttons.B7))
                    {
                        Player2Selected = false;
                    }

                    break;

                case SupportedControllers.KeyboardP1ControllerP2:

                    if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.B))
                    {
                        Player2Selected = false;
                    }

                    break;

                case SupportedControllers.KeyboardP2ControllerP1:

                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7))
                    {
                        Player2Selected = false;
                    }

                    break;

                default:
                    break;
                }

                Player2Confirmed.enabled = false;

                break;
            }
        }
Exemple #14
0
        protected override void Update()
        {
            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                // Player 1
                if ((ArcadeControls.JoystickLeft(Joysticks.White) && (!IsCoR_P1) && (!ReadyP1)))
                {
                    StartCoroutine(ToggleSelP1(1));
                }
                if ((ArcadeControls.JoystickRight(Joysticks.White) && (!IsCoR_P1) && (!ReadyP1)))
                {
                    StartCoroutine(ToggleSelP1(-1));
                }

                if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B8))
                {
                    am.Play("Menu_Select", .75f);
                    ReadyP1          = !ReadyP1;
                    Ready[0].enabled = ReadyP1;
                }

                if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B7))
                {
                    am.Play("Confirm", .25f);
                    SC.MoveToDucks  = false;
                    SC.MoveToRounds = true;
                    RSC.enabled     = true;
                    this.enabled    = false;
                }

                // Player 2
                if ((ArcadeControls.JoystickLeft(Joysticks.Black) && (!IsCoR_P2) && (!ReadyP2)))
                {
                    StartCoroutine(ToggleSelP2(1));
                }
                if ((ArcadeControls.JoystickRight(Joysticks.Black) && (!IsCoR_P2) && (!ReadyP2)))
                {
                    StartCoroutine(ToggleSelP2(-1));
                }

                if (ArcadeControls.ButtonPress(Joysticks.Black, Buttons.B8))
                {
                    am.Play("Menu_Select", .75f);
                    ReadyP2          = !ReadyP2;
                    Ready[1].enabled = ReadyP2;
                }

                break;

            case SupportedControllers.GamePadBoth:

                // Player 1
                if ((ControllerControls.ControllerLeft(Players.P1) && (!IsCoR_P1) && (!ReadyP1)))
                {
                    StartCoroutine(ToggleSelP1(1));
                }
                if ((ControllerControls.ControllerRight(Players.P1) && (!IsCoR_P1) && (!ReadyP1)))
                {
                    StartCoroutine(ToggleSelP1(-1));
                }

                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.Confirm))
                {
                    am.Play("Menu_Select", .75f);
                    ReadyP1          = !ReadyP1;
                    Ready[0].enabled = ReadyP1;
                }

                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.B))
                {
                    am.Play("Confirm", .25f);
                    SC.MoveToDucks  = false;
                    SC.MoveToRounds = true;
                    RSC.enabled     = true;
                    this.enabled    = false;
                }

                // Player 2
                if ((ControllerControls.ControllerLeft(Players.P2) && (!IsCoR_P2) && (!ReadyP2)))
                {
                    StartCoroutine(ToggleSelP2(1));
                }
                if ((ControllerControls.ControllerRight(Players.P2) && (!IsCoR_P2) && (!ReadyP2)))
                {
                    StartCoroutine(ToggleSelP2(-1));
                }

                if (ControllerControls.ButtonPress(Players.P2, ControllerButtons.Confirm))
                {
                    am.Play("Menu_Select", .75f);
                    ReadyP2          = !ReadyP2;
                    Ready[1].enabled = ReadyP2;
                }

                break;

            case SupportedControllers.KeyboardBoth:

                if ((KeyboardControls.KeyboardLeft(Players.P1) && (!IsCoR_P1) && (!ReadyP1)))
                {
                    StartCoroutine(ToggleSelP1(1));
                }
                if ((KeyboardControls.KeyboardRight(Players.P1) && (!IsCoR_P1) && (!ReadyP1)))
                {
                    StartCoroutine(ToggleSelP1(-1));
                }

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                {
                    am.Play("Menu_Select", .75f);
                    ReadyP1          = !ReadyP1;
                    Ready[0].enabled = ReadyP1;
                }

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7))
                {
                    am.Play("Confirm", .25f);
                    SC.MoveToDucks  = false;
                    SC.MoveToRounds = true;
                    RSC.enabled     = true;
                    this.enabled    = false;
                }

                // Player 2
                if ((KeyboardControls.KeyboardLeft(Players.P2) && (!IsCoR_P2) && (!ReadyP2)))
                {
                    StartCoroutine(ToggleSelP2(1));
                }
                if ((KeyboardControls.KeyboardRight(Players.P2) && (!IsCoR_P2) && (!ReadyP2)))
                {
                    StartCoroutine(ToggleSelP2(-1));
                }

                if (KeyboardControls.ButtonPress(Players.P2, Buttons.B8))
                {
                    am.Play("Menu_Select", .75f);
                    ReadyP2          = !ReadyP2;
                    Ready[1].enabled = ReadyP2;
                }

                break;

            case SupportedControllers.KeyboardP1ControllerP2:

                if ((KeyboardControls.KeyboardLeft(Players.P1) && (!IsCoR_P1) && (!ReadyP1)))
                {
                    StartCoroutine(ToggleSelP1(1));
                }
                if ((KeyboardControls.KeyboardRight(Players.P1) && (!IsCoR_P1) && (!ReadyP1)))
                {
                    StartCoroutine(ToggleSelP1(-1));
                }

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                {
                    am.Play("Menu_Select", .75f);
                    ReadyP1          = !ReadyP1;
                    Ready[0].enabled = ReadyP1;
                }

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7))
                {
                    am.Play("Confirm", .25f);
                    SC.MoveToDucks  = false;
                    SC.MoveToRounds = true;
                    RSC.enabled     = true;
                    this.enabled    = false;
                }

                if ((ControllerControls.ControllerLeft(Players.P1) && (!IsCoR_P2) && (!ReadyP2)))
                {
                    StartCoroutine(ToggleSelP2(1));
                }
                if ((ControllerControls.ControllerRight(Players.P1) && (!IsCoR_P2) && (!ReadyP2)))
                {
                    StartCoroutine(ToggleSelP2(-1));
                }

                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.A))
                {
                    am.Play("Menu_Select", .75f);
                    ReadyP2          = !ReadyP2;
                    Ready[1].enabled = ReadyP2;
                }

                break;

            case SupportedControllers.KeyboardP2ControllerP1:

                if ((ControllerControls.ControllerLeft(Players.P1) && (!IsCoR_P1) && (!ReadyP1)))
                {
                    StartCoroutine(ToggleSelP1(1));
                }
                if ((ControllerControls.ControllerRight(Players.P1) && (!IsCoR_P1) && (!ReadyP1)))
                {
                    StartCoroutine(ToggleSelP1(-1));
                }

                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.A))
                {
                    am.Play("Menu_Select", .75f);
                    ReadyP1          = !ReadyP1;
                    Ready[0].enabled = ReadyP1;
                }

                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.B))
                {
                    am.Play("Confirm", .25f);
                    SC.MoveToDucks  = false;
                    SC.MoveToRounds = true;
                    RSC.enabled     = true;
                    this.enabled    = false;
                }

                if ((KeyboardControls.KeyboardLeft(Players.P1) && (!IsCoR_P2) && (!ReadyP2)))
                {
                    StartCoroutine(ToggleSelP2(1));
                }
                if ((KeyboardControls.KeyboardRight(Players.P1) && (!IsCoR_P2) && (!ReadyP2)))
                {
                    StartCoroutine(ToggleSelP2(-1));
                }

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                {
                    am.Play("Menu_Select", .75f);
                    ReadyP2          = !ReadyP2;
                    Ready[1].enabled = ReadyP2;
                }

                break;

            default:
                break;
            }

            if (ReadyP1 && ReadyP2)
            {
                QuackingTimeData _data = new QuackingTimeData(Duck1Pos, Duck2Pos);
                SaveManager.SaveQuackingTime(_data);
                ChangeScene.ChangeToLevel();
            }
        }
        protected override void Update()
        {
            // The base update
            base.Update();

            JumpSmoothing();

            if (!JumpCoolRunning)
            {
                if (Physics.Linecast(transform.position, transform.position + new Vector3(0, -1.5f, 0), 1 << LayerMask.NameToLayer("Quacking:Ground")))
                {
                    CanDuckJump = true;
                }
                else
                {
                    CanDuckJump = false;
                }
            }

            switch (Power)
            {
            case Powerups.Explodie:
                MoveSpd = 8;
                PowerupLock.SetActive(false);
                PowerupSpd.SetActive(false);
                LockHex = false;
                break;

            case Powerups.Speedie:
                MoveSpd = 12;
                PowerupLock.SetActive(false);
                PowerupSpd.SetActive(true);
                LockHex = false;

                if (!IsSpeedie)
                {
                    StartCoroutine(SpdDuration());
                }

                mapController.SetControlledHexagonsToUnlocked(Ducks);

                break;

            case Powerups.Lockie:
                MoveSpd = 8;
                LockHex = true;
                PowerupLock.SetActive(true);
                PowerupSpd.SetActive(false);
                break;

            case Powerups.None:
                MoveSpd = 8;
                LockHex = false;
                PowerupLock.SetActive(false);
                PowerupSpd.SetActive(false);
                break;

            default:
                break;
            }

            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                switch (Ducks)
                {
                case DuckPlayers.P1:

                    if (ArcadeControls.JoystickUp(Joysticks.White))
                    {
                        GoFoward();
                    }
                    else if (ArcadeControls.JoystickDown(Joysticks.White))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((ArcadeControls.ButtonPress(Joysticks.White, Buttons.B1)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;

                case DuckPlayers.P2:

                    if (ArcadeControls.JoystickUp(Joysticks.Black))
                    {
                        GoFoward();
                    }
                    else if (ArcadeControls.JoystickDown(Joysticks.Black))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((ArcadeControls.ButtonPress(Joysticks.Black, Buttons.B1)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;
                }

                break;

            case SupportedControllers.GamePadBoth:

                switch (Ducks)
                {
                case DuckPlayers.P1:

                    if (ControllerControls.ControllerUp(Players.P1))
                    {
                        GoFoward();
                    }
                    else if (ControllerControls.ControllerDown(Players.P1))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((ControllerControls.ButtonPress(Players.P1, ControllerButtons.A)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;

                case DuckPlayers.P2:

                    if (ControllerControls.ControllerUp(Players.P2))
                    {
                        GoFoward();
                    }
                    else if (ControllerControls.ControllerDown(Players.P2))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((ControllerControls.ButtonPress(Players.P2, ControllerButtons.A)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;
                }

                break;

            case SupportedControllers.KeyboardBoth:

                switch (Ducks)
                {
                case DuckPlayers.P1:

                    if (KeyboardControls.KeyboardUp(Players.P1))
                    {
                        GoFoward();
                    }
                    else if (KeyboardControls.KeyboardDown(Players.P1))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((KeyboardControls.ButtonPress(Players.P1, Buttons.B1)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;

                case DuckPlayers.P2:

                    if (KeyboardControls.KeyboardUp(Players.P2))
                    {
                        GoFoward();
                    }
                    else if (KeyboardControls.KeyboardDown(Players.P2))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((KeyboardControls.ButtonPress(Players.P2, Buttons.B1)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;
                }

                break;

            case SupportedControllers.KeyboardP1ControllerP2:

                switch (Ducks)
                {
                case DuckPlayers.P1:

                    if (KeyboardControls.KeyboardUp(Players.P1))
                    {
                        GoFoward();
                    }
                    else if (KeyboardControls.KeyboardDown(Players.P1))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((KeyboardControls.ButtonPress(Players.P1, Buttons.B1)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;

                case DuckPlayers.P2:

                    if (ControllerControls.ControllerUp(Players.P1))
                    {
                        GoFoward();
                    }
                    else if (ControllerControls.ControllerDown(Players.P1))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((ControllerControls.ButtonPress(Players.P1, ControllerButtons.A)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;
                }

                break;

            case SupportedControllers.KeyboardP2ControllerP1:

                switch (Ducks)
                {
                case DuckPlayers.P2:

                    if (KeyboardControls.KeyboardUp(Players.P1))
                    {
                        GoFoward();
                    }
                    else if (KeyboardControls.KeyboardDown(Players.P1))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((KeyboardControls.ButtonPress(Players.P1, Buttons.B1)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;

                case DuckPlayers.P1:

                    if (ControllerControls.ControllerUp(Players.P1))
                    {
                        GoFoward();
                    }
                    else if (ControllerControls.ControllerDown(Players.P1))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((ControllerControls.ButtonPress(Players.P1, ControllerButtons.A)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;
                }

                break;

            default:
                break;
            }

            RotatePlayer();
        }
Exemple #16
0
        private void FixedUpdate()
        {
            // Switches the flippers between left and right
            switch (ThisFlipper)
            {
            case FlipperSides.Left:

                switch (ControllerType)
                {
                case SupportedControllers.ArcadeBoard:

                    if (ArcadeControls.JoystickLeft(Input))
                    {
                        FlipLeftFlipper();
                    }
                    else if (ArcadeControls.JoystickNone(Input))
                    {
                        ResetLeftFlipper();
                    }

                    break;

                case SupportedControllers.GamePadBoth:

                    if (ControllerControls.ControllerLeft(ConvertToPlayers()))
                    {
                        FlipLeftFlipper();
                    }
                    else if (ControllerControls.ControllerNone(ConvertToPlayers()))
                    {
                        ResetLeftFlipper();
                    }

                    break;

                case SupportedControllers.KeyboardBoth:

                    if (KeyboardControls.KeyboardLeft(ConvertToPlayers()))
                    {
                        FlipLeftFlipper();
                    }
                    else if (KeyboardControls.KeyboardNone(ConvertToPlayers()))
                    {
                        ResetLeftFlipper();
                    }

                    break;

                case SupportedControllers.KeyboardP1ControllerP2:

                    if (ConvertToPlayers() == Players.P1)
                    {
                        if (KeyboardControls.KeyboardLeft(Players.P1))
                        {
                            FlipLeftFlipper();
                        }
                        else if (KeyboardControls.KeyboardNone(Players.P1))
                        {
                            ResetLeftFlipper();
                        }
                    }
                    else
                    {
                        if (ControllerControls.ControllerLeft(Players.P1))
                        {
                            FlipLeftFlipper();
                        }
                        else if (ControllerControls.ControllerNone(Players.P1))
                        {
                            ResetLeftFlipper();
                        }
                    }

                    break;

                case SupportedControllers.KeyboardP2ControllerP1:

                    if (ConvertToPlayers() == Players.P2)
                    {
                        if (KeyboardControls.KeyboardLeft(Players.P1))
                        {
                            FlipLeftFlipper();
                        }
                        else if (KeyboardControls.KeyboardNone(Players.P1))
                        {
                            ResetLeftFlipper();
                        }
                    }
                    else
                    {
                        if (ControllerControls.ControllerLeft(Players.P1))
                        {
                            FlipLeftFlipper();
                        }
                        else if (ControllerControls.ControllerNone(Players.P1))
                        {
                            ResetLeftFlipper();
                        }
                    }

                    break;

                default:
                    break;
                }


                break;

            case FlipperSides.Right:

                switch (ControllerType)
                {
                case SupportedControllers.ArcadeBoard:

                    if (ArcadeControls.JoystickRight(Input))
                    {
                        FlipRightFlipper();
                    }
                    else if (ArcadeControls.JoystickNone(Input))
                    {
                        ResetRightFlipper();
                    }

                    break;

                case SupportedControllers.GamePadBoth:

                    if (ControllerControls.ControllerRight(ConvertToPlayers()))
                    {
                        FlipRightFlipper();
                    }
                    else if (ControllerControls.ControllerNone(ConvertToPlayers()))
                    {
                        ResetRightFlipper();
                    }

                    break;

                case SupportedControllers.KeyboardBoth:

                    if (KeyboardControls.KeyboardRight(ConvertToPlayers()))
                    {
                        FlipRightFlipper();
                    }
                    else if (KeyboardControls.KeyboardNone(ConvertToPlayers()))
                    {
                        ResetRightFlipper();
                    }

                    break;

                case SupportedControllers.KeyboardP1ControllerP2:

                    if (ConvertToPlayers() == Players.P1)
                    {
                        if (KeyboardControls.KeyboardRight(Players.P1))
                        {
                            FlipRightFlipper();
                        }
                        else if (KeyboardControls.KeyboardNone(Players.P1))
                        {
                            ResetRightFlipper();
                        }
                    }
                    else
                    {
                        if (ControllerControls.ControllerRight(Players.P1))
                        {
                            FlipRightFlipper();
                        }
                        else if (ControllerControls.ControllerNone(Players.P1))
                        {
                            ResetRightFlipper();
                        }
                    }

                    break;

                case SupportedControllers.KeyboardP2ControllerP1:

                    if (ConvertToPlayers() == Players.P2)
                    {
                        if (KeyboardControls.KeyboardRight(Players.P1))
                        {
                            FlipRightFlipper();
                        }
                        else if (KeyboardControls.KeyboardNone(Players.P1))
                        {
                            ResetRightFlipper();
                        }
                    }
                    else
                    {
                        if (ControllerControls.ControllerRight(Players.P1))
                        {
                            FlipRightFlipper();
                        }
                        else if (ControllerControls.ControllerNone(Players.P1))
                        {
                            ResetRightFlipper();
                        }
                    }

                    break;

                default:
                    break;
                }


                break;

            default:
                break;
            }
        }
Exemple #17
0
        protected override void Update()
        {
            base.Update();

            UpdateDisplay();

            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B8))
                {
                    SetNumberofRounds(Selection);
                    am.Play("Menu-Confirm", .25f);
                    OpenCustomMenu();
                }

                if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B7))
                {
                    am.Play("Confirm", .25f);
                    BackToRootMenu();
                }

                if (ArcadeControls.JoystickLeft(Joysticks.White) && !IsCoR)
                {
                    StartCoroutine(RoundsSelect(-1));
                }
                if (ArcadeControls.JoystickRight(Joysticks.White) && !IsCoR)
                {
                    StartCoroutine(RoundsSelect(1));
                }

                break;

            case SupportedControllers.GamePadBoth:

                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.A))
                {
                    SetNumberofRounds(Selection);
                    am.Play("Menu-Confirm", .25f);
                    OpenCustomMenu();
                }

                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.B))
                {
                    am.Play("Confirm", .25f);
                    BackToRootMenu();
                }

                if (ControllerControls.ControllerLeft(Players.P1) && !IsCoR)
                {
                    StartCoroutine(RoundsSelect(-1));
                }
                if (ControllerControls.ControllerRight(Players.P1) && !IsCoR)
                {
                    StartCoroutine(RoundsSelect(1));
                }

                break;

            case SupportedControllers.KeyboardBoth:

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                {
                    SetNumberofRounds(Selection);
                    am.Play("Menu-Confirm", .25f);
                    OpenCustomMenu();
                }

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7))
                {
                    am.Play("Confirm", .25f);
                    BackToRootMenu();
                }

                if (KeyboardControls.KeyboardLeft(Players.P1) && !IsCoR)
                {
                    StartCoroutine(RoundsSelect(-1));
                }
                if (KeyboardControls.KeyboardRight(Players.P1) && !IsCoR)
                {
                    StartCoroutine(RoundsSelect(1));
                }

                break;

            case SupportedControllers.KeyboardP1ControllerP2:

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                {
                    SetNumberofRounds(Selection);
                    am.Play("Menu-Confirm", .25f);
                    OpenCustomMenu();
                }

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7))
                {
                    am.Play("Confirm", .25f);
                    BackToRootMenu();
                }

                if (KeyboardControls.KeyboardLeft(Players.P1) && !IsCoR)
                {
                    StartCoroutine(RoundsSelect(-1));
                }
                if (KeyboardControls.KeyboardRight(Players.P1) && !IsCoR)
                {
                    StartCoroutine(RoundsSelect(1));
                }

                break;

            case SupportedControllers.KeyboardP2ControllerP1:

                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.A))
                {
                    SetNumberofRounds(Selection);
                    am.Play("Menu-Confirm", .25f);
                    OpenCustomMenu();
                }

                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.B))
                {
                    am.Play("Confirm", .25f);
                    BackToRootMenu();
                }

                if (ControllerControls.ControllerLeft(Players.P1) && !IsCoR)
                {
                    StartCoroutine(RoundsSelect(-1));
                }
                if (ControllerControls.ControllerRight(Players.P1) && !IsCoR)
                {
                    StartCoroutine(RoundsSelect(1));
                }

                break;

            default:
                break;
            }
        }
Exemple #18
0
        public void MoveLR()
        {
            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                if ((ArcadeControls.JoystickLeft(Joysticks.White)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(-1));
                }
                if ((ArcadeControls.JoystickRight(Joysticks.White)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(1));
                }

                break;

            case SupportedControllers.GamePadBoth:

                if ((ControllerControls.ControllerLeft(Players.P1)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(-1));
                }
                if ((ControllerControls.ControllerRight(Players.P1)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(1));
                }

                break;

            case SupportedControllers.KeyboardBoth:

                if ((KeyboardControls.KeyboardLeft(Players.P1)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(-1));
                }
                if ((KeyboardControls.KeyboardRight(Players.P1)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(1));
                }

                break;

            case SupportedControllers.KeyboardP1ControllerP2:

                if ((KeyboardControls.KeyboardLeft(Players.P1)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(-1));
                }
                if ((KeyboardControls.KeyboardRight(Players.P1)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(1));
                }

                break;

            case SupportedControllers.KeyboardP2ControllerP1:

                if ((ControllerControls.ControllerLeft(Players.P1)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(-1));
                }
                if ((ControllerControls.ControllerRight(Players.P1)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(1));
                }

                break;

            default:
                break;
            }
        }
Exemple #19
0
        public bool Confirm()
        {
            if (inputReady)
            {
                switch (ControllerType)
                {
                case SupportedControllers.ArcadeBoard:

                    if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B8))
                    {
                        StartCoroutine(InputLag()); return(true);
                    }
                    else
                    {
                        return(false);
                    }

                case SupportedControllers.GamePadBoth:

                    if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.A))
                    {
                        StartCoroutine(InputLag()); return(true);
                    }
                    else
                    {
                        return(false);
                    }

                case SupportedControllers.KeyboardBoth:

                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                    {
                        StartCoroutine(InputLag()); Debug.Log(">> Confirm Pressed <<");  return(true);
                    }
                    else
                    {
                        return(false);
                    }

                case SupportedControllers.KeyboardP1ControllerP2:

                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                    {
                        StartCoroutine(InputLag()); return(true);
                    }
                    else
                    {
                        return(false);
                    }

                case SupportedControllers.KeyboardP2ControllerP1:

                    if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.A))
                    {
                        StartCoroutine(InputLag()); return(true);
                    }
                    else
                    {
                        return(false);
                    }

                default:
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Exemple #20
0
        public bool Return(ControllerButtons DesiredButton)
        {
            if (inputReady)
            {
                switch (ControllerType)
                {
                case SupportedControllers.ArcadeBoard:

                    if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B7))
                    {
                        StartCoroutine(InputLag()); return(true);
                    }
                    else
                    {
                        return(false);
                    }

                case SupportedControllers.GamePadBoth:

                    if (ControllerControls.ButtonPress(Players.P1, DesiredButton))
                    {
                        StartCoroutine(InputLag()); return(true);
                    }
                    else
                    {
                        return(false);
                    }

                case SupportedControllers.KeyboardBoth:

                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7))
                    {
                        StartCoroutine(InputLag()); return(true);
                    }
                    else
                    {
                        return(false);
                    }

                case SupportedControllers.KeyboardP1ControllerP2:

                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7))
                    {
                        StartCoroutine(InputLag()); return(true);
                    }
                    else
                    {
                        return(false);
                    }

                case SupportedControllers.KeyboardP2ControllerP1:

                    if (ControllerControls.ButtonPress(Players.P1, DesiredButton))
                    {
                        StartCoroutine(InputLag()); return(true);
                    }
                    else
                    {
                        return(false);
                    }

                default:
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Exemple #21
0
        protected override void Update()
        {
            base.Update();

            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B8))
                {
                    ConfirmP1();
                }
                if (ArcadeControls.ButtonPress(Joysticks.Black, Buttons.B8))
                {
                    ConfirmP2();
                }

                if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B7))
                {
                    ReturnP1();
                }
                if (ArcadeControls.ButtonPress(Joysticks.Black, Buttons.B7))
                {
                    ReturnP2();
                }

                break;

            case SupportedControllers.GamePadBoth:

                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.Confirm))
                {
                    ConfirmP1();
                }
                if (ControllerControls.ButtonPress(Players.P2, ControllerButtons.Confirm))
                {
                    ConfirmP2();
                }

                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.Return))
                {
                    ReturnP1();
                }
                if (ControllerControls.ButtonPress(Players.P2, ControllerButtons.Return))
                {
                    ReturnP2();
                }

                break;

            case SupportedControllers.KeyboardBoth:

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                {
                    ConfirmP1();
                }
                if (KeyboardControls.ButtonPress(Players.P2, Buttons.B8))
                {
                    ConfirmP2();
                }

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7))
                {
                    ReturnP1();
                }
                if (KeyboardControls.ButtonPress(Players.P2, Buttons.B7))
                {
                    ReturnP2();
                }

                break;

            case SupportedControllers.KeyboardP1ControllerP2:

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                {
                    ConfirmP1();
                }
                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.Confirm))
                {
                    ConfirmP2();
                }

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7))
                {
                    ReturnP1();
                }
                if (ControllerControls.ButtonPress(Players.P2, ControllerButtons.Return))
                {
                    ReturnP2();
                }

                break;

            case SupportedControllers.KeyboardP2ControllerP1:

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                {
                    ConfirmP2();
                }
                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.Confirm))
                {
                    ConfirmP1();
                }

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7))
                {
                    ReturnP2();
                }
                if (ControllerControls.ButtonPress(Players.P2, ControllerButtons.Return))
                {
                    ReturnP1();
                }

                break;

            default:
                break;
            }


            if ((Player1Ready) && (Player2Ready))
            {
                SendDataToBoard(Player1_LB_Data, 0);
                SendDataToBoard(Player2_LB_Data, 1);

                // change after sent
                GetComponentInParent <CanvasGroup>().alpha -= Time.deltaTime * 2;

                StartCoroutine(WaitAndEnableMenuCtrl());
            }
        }
        private void RotatePlayer()
        {
            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                switch (Ducks)
                {
                case DuckPlayers.P1:

                    if (ArcadeControls.JoystickLeft(Joysticks.White))
                    {
                        transform.localEulerAngles += new Vector3(0, -1 * RotSpd, 0);
                    }
                    else if (ArcadeControls.JoystickRight(Joysticks.White))
                    {
                        transform.localEulerAngles += new Vector3(0, 1 * RotSpd, 0);
                    }

                    break;

                case DuckPlayers.P2:

                    if (ArcadeControls.JoystickLeft(Joysticks.Black))
                    {
                        transform.localEulerAngles += new Vector3(0, -1 * RotSpd, 0);
                    }
                    else if (ArcadeControls.JoystickRight(Joysticks.Black))
                    {
                        transform.localEulerAngles += new Vector3(0, 1 * RotSpd, 0);
                    }

                    break;
                }

                break;

            case SupportedControllers.GamePadBoth:

                switch (Ducks)
                {
                case DuckPlayers.P1:

                    if (ControllerControls.ControllerLeft(Players.P1))
                    {
                        transform.localEulerAngles += new Vector3(0, -1 * RotSpd, 0);
                    }
                    else if (ControllerControls.ControllerRight(Players.P1))
                    {
                        transform.localEulerAngles += new Vector3(0, 1 * RotSpd, 0);
                    }

                    break;

                case DuckPlayers.P2:

                    if (ControllerControls.ControllerLeft(Players.P2))
                    {
                        transform.localEulerAngles += new Vector3(0, -1 * RotSpd, 0);
                    }
                    else if (ControllerControls.ControllerRight(Players.P2))
                    {
                        transform.localEulerAngles += new Vector3(0, 1 * RotSpd, 0);
                    }

                    break;
                }

                break;

            case SupportedControllers.KeyboardBoth:

                switch (Ducks)
                {
                case DuckPlayers.P1:

                    if (KeyboardControls.KeyboardLeft(Players.P1))
                    {
                        transform.localEulerAngles += new Vector3(0, -1 * RotSpd, 0);
                    }
                    else if (KeyboardControls.KeyboardRight(Players.P1))
                    {
                        transform.localEulerAngles += new Vector3(0, 1 * RotSpd, 0);
                    }

                    break;

                case DuckPlayers.P2:

                    if (KeyboardControls.KeyboardLeft(Players.P2))
                    {
                        transform.localEulerAngles += new Vector3(0, -1 * RotSpd, 0);
                    }
                    else if (KeyboardControls.KeyboardRight(Players.P2))
                    {
                        transform.localEulerAngles += new Vector3(0, 1 * RotSpd, 0);
                    }

                    break;
                }

                break;

            case SupportedControllers.KeyboardP1ControllerP2:

                switch (Ducks)
                {
                case DuckPlayers.P1:

                    if (KeyboardControls.KeyboardLeft(Players.P1))
                    {
                        transform.localEulerAngles += new Vector3(0, -1 * RotSpd, 0);
                    }
                    else if (KeyboardControls.KeyboardRight(Players.P1))
                    {
                        transform.localEulerAngles += new Vector3(0, 1 * RotSpd, 0);
                    }

                    break;

                case DuckPlayers.P2:

                    if (ControllerControls.ControllerLeft(Players.P1))
                    {
                        transform.localEulerAngles += new Vector3(0, -1 * RotSpd, 0);
                    }
                    else if (ControllerControls.ControllerRight(Players.P1))
                    {
                        transform.localEulerAngles += new Vector3(0, 1 * RotSpd, 0);
                    }

                    break;
                }

                break;

            case SupportedControllers.KeyboardP2ControllerP1:

                switch (Ducks)
                {
                case DuckPlayers.P2:

                    if (KeyboardControls.KeyboardLeft(Players.P1))
                    {
                        transform.localEulerAngles += new Vector3(0, -1 * RotSpd, 0);
                    }
                    else if (KeyboardControls.KeyboardRight(Players.P1))
                    {
                        transform.localEulerAngles += new Vector3(0, 1 * RotSpd, 0);
                    }

                    break;

                case DuckPlayers.P1:

                    if (ControllerControls.ControllerLeft(Players.P1))
                    {
                        transform.localEulerAngles += new Vector3(0, -1 * 3, 0);
                    }
                    else if (ControllerControls.ControllerRight(Players.P1))
                    {
                        transform.localEulerAngles += new Vector3(0, 1 * 3, 0);
                    }

                    break;
                }

                break;

            default:
                break;
            }
        }
Exemple #23
0
        protected override void Update()
        {
            base.Update();

            // If the joystick is pressed down
            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                if (ArcadeControls.JoystickDown(ThisPlayer))
                {
                    FlipBoth();
                }

                break;

            case SupportedControllers.GamePadBoth:

                if (ControllerControls.ControllerDown(ConvertToPlayers()))
                {
                    FlipBoth();
                }

                break;

            case SupportedControllers.KeyboardBoth:

                if (KeyboardControls.KeyboardDown(ConvertToPlayers()))
                {
                    FlipBoth();
                }

                break;

            case SupportedControllers.KeyboardP1ControllerP2:

                if (ConvertToPlayers() == Players.P1)
                {
                    if (KeyboardControls.KeyboardDown(Players.P1))
                    {
                        FlipBoth();
                    }
                }
                else
                {
                    if (ControllerControls.ControllerDown(Players.P1))
                    {
                        FlipBoth();
                    }
                }

                break;

            case SupportedControllers.KeyboardP2ControllerP1:

                if (ConvertToPlayers() == Players.P2)
                {
                    if (KeyboardControls.KeyboardDown(Players.P1))
                    {
                        FlipBoth();
                    }
                }
                else
                {
                    if (ControllerControls.ControllerDown(Players.P1))
                    {
                        FlipBoth();
                    }
                }

                break;

            default:
                break;
            }
        }
 // Use this for initialization
 void Start()
 {
     charScript = character.GetComponent <Character>();
     keyboard   = controls.GetComponent <KeyboardControls>();
 }
 public LocalPlayer NewPlayer(long sessionID, int id, short index, Vector2 position, float angle, KeyboardControls controls)
 {
     return new LocalPlayer(game, sessionID, id, textureFolder + textureNames[index], position, angle, physicsSimulator, speed, mass, CollisionCategory.Cat1, index, controls, projectileFactory);
 }
        void ConfirmOption(Joysticks PlayerInput)
        {
            switch (PlayerInput)
            {
            case Joysticks.White:

                switch (ControllerType)
                {
                case SupportedControllers.ArcadeBoard:

                    if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B8))
                    {
                        MenuAM.Play("Menu_Select");
                        Player1Selected = true;
                    }

                    break;

                case SupportedControllers.GamePadBoth:

                    if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.A))
                    {
                        MenuAM.Play("Menu_Select");
                        Player1Selected = true;
                    }

                    break;

                case SupportedControllers.KeyboardBoth:

                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                    {
                        MenuAM.Play("Menu_Select");
                        Player1Selected = true;
                    }

                    break;

                case SupportedControllers.KeyboardP1ControllerP2:

                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                    {
                        MenuAM.Play("Menu_Select");
                        Player1Selected = true;
                    }

                    break;

                case SupportedControllers.KeyboardP2ControllerP1:

                    if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.A))
                    {
                        MenuAM.Play("Menu_Select");
                        Player1Selected = true;
                    }

                    break;

                default:
                    break;
                }

                break;

            case Joysticks.Black:

                switch (ControllerType)
                {
                case SupportedControllers.ArcadeBoard:

                    if (ArcadeControls.ButtonPress(Joysticks.Black, Buttons.B8))
                    {
                        MenuAM.Play("Menu_Select");
                        Player2Selected = true;
                    }

                    break;

                case SupportedControllers.GamePadBoth:

                    if (ControllerControls.ButtonPress(Players.P2, ControllerButtons.A))
                    {
                        MenuAM.Play("Menu_Select");
                        Player2Selected = true;
                    }

                    break;

                case SupportedControllers.KeyboardBoth:

                    if (KeyboardControls.ButtonPress(Players.P2, Buttons.B8))
                    {
                        MenuAM.Play("Menu_Select");
                        Player2Selected = true;
                    }

                    break;

                case SupportedControllers.KeyboardP1ControllerP2:

                    if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.A))
                    {
                        MenuAM.Play("Menu_Select");
                        Player2Selected = true;
                    }

                    break;

                case SupportedControllers.KeyboardP2ControllerP1:

                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                    {
                        MenuAM.Play("Menu_Select");
                        Player2Selected = true;
                    }

                    break;

                default:
                    break;
                }

                break;
            }
        }
Exemple #27
0
        protected override void Update()
        {
            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                if (ArcadeControls.JoystickUp(Joysticks.White))
                {
                    scrollRect.verticalNormalizedPosition += 1f * Time.deltaTime;
                }
                else if (ArcadeControls.JoystickDown(Joysticks.White))
                {
                    scrollRect.verticalNormalizedPosition -= 1f * Time.deltaTime;
                }

                break;

            case SupportedControllers.GamePadBoth:

                if (ControllerControls.ControllerUp(Players.P1))
                {
                    scrollRect.verticalNormalizedPosition += 1f * Time.deltaTime;
                }
                else if (ControllerControls.ControllerDown(Players.P1))
                {
                    scrollRect.verticalNormalizedPosition -= 1f * Time.deltaTime;
                }

                break;

            case SupportedControllers.KeyboardBoth:

                if (KeyboardControls.KeyboardUp(Players.P1))
                {
                    scrollRect.verticalNormalizedPosition += 1f * Time.deltaTime;
                }
                else if (KeyboardControls.KeyboardDown(Players.P1))
                {
                    scrollRect.verticalNormalizedPosition -= 1f * Time.deltaTime;
                }

                break;

            case SupportedControllers.KeyboardP1ControllerP2:

                if (KeyboardControls.KeyboardUp(Players.P1))
                {
                    scrollRect.verticalNormalizedPosition += 1f * Time.deltaTime;
                }
                else if (KeyboardControls.KeyboardDown(Players.P1))
                {
                    scrollRect.verticalNormalizedPosition -= 1f * Time.deltaTime;
                }

                break;

            case SupportedControllers.KeyboardP2ControllerP1:

                if (ControllerControls.ControllerUp(Players.P1))
                {
                    scrollRect.verticalNormalizedPosition += 1f * Time.deltaTime;
                }
                else if (ControllerControls.ControllerDown(Players.P1))
                {
                    scrollRect.verticalNormalizedPosition -= 1f * Time.deltaTime;
                }

                break;

            default:
                break;
            }


            base.Update();
        }
        void PlayerSelectionMovement(Joysticks PlayerInput)
        {
            switch (PlayerInput)
            {
            case Joysticks.White:

                switch (ControllerType)
                {
                case SupportedControllers.ArcadeBoard:

                    if ((ArcadeControls.JoystickLeft(PlayerInput)) && (!Player1Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        --Player1Pos;
                        if (Player1Pos < 0)
                        {
                            Player1Pos = Player1MaxPos - 1;
                        }
                        StartCoroutine(InputLagP1(.2f));
                    }
                    else if ((ArcadeControls.JoystickRight(PlayerInput)) && (!Player1Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        ++Player1Pos;
                        if (Player1Pos > Player1MaxPos - 1)
                        {
                            Player1Pos = 0;
                        }
                        StartCoroutine(InputLagP1(.2f));
                    }

                    break;

                case SupportedControllers.GamePadBoth:

                    if ((ControllerControls.ControllerLeft(Players.P1)) && (!Player1Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        --Player1Pos;
                        if (Player1Pos < 0)
                        {
                            Player1Pos = Player1MaxPos - 1;
                        }
                        StartCoroutine(InputLagP1(.2f));
                    }
                    else if ((ControllerControls.ControllerRight(Players.P1)) && (!Player1Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        ++Player1Pos;
                        if (Player1Pos > Player1MaxPos - 1)
                        {
                            Player1Pos = 0;
                        }
                        StartCoroutine(InputLagP1(.2f));
                    }

                    break;

                case SupportedControllers.KeyboardBoth:

                    if ((KeyboardControls.KeyboardLeft(Players.P1)) && (!Player1Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        --Player1Pos;
                        if (Player1Pos < 0)
                        {
                            Player1Pos = Player1MaxPos - 1;
                        }
                        StartCoroutine(InputLagP1(.2f));
                    }
                    else if ((KeyboardControls.KeyboardRight(Players.P1)) && (!Player1Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        ++Player1Pos;
                        if (Player1Pos > Player1MaxPos - 1)
                        {
                            Player1Pos = 0;
                        }
                        StartCoroutine(InputLagP1(.2f));
                    }

                    break;

                case SupportedControllers.KeyboardP1ControllerP2:

                    if ((KeyboardControls.KeyboardLeft(Players.P1)) && (!Player1Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        --Player1Pos;
                        if (Player1Pos < 0)
                        {
                            Player1Pos = Player1MaxPos - 1;
                        }
                        StartCoroutine(InputLagP1(.2f));
                    }
                    else if ((KeyboardControls.KeyboardRight(Players.P1)) && (!Player1Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        ++Player1Pos;
                        if (Player1Pos > Player1MaxPos - 1)
                        {
                            Player1Pos = 0;
                        }
                        StartCoroutine(InputLagP1(.2f));
                    }

                    break;

                case SupportedControllers.KeyboardP2ControllerP1:

                    if ((ControllerControls.ControllerLeft(Players.P1)) && (!Player1Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        --Player1Pos;
                        if (Player1Pos < 0)
                        {
                            Player1Pos = Player1MaxPos - 1;
                        }
                        StartCoroutine(InputLagP1(.2f));
                    }
                    else if ((ControllerControls.ControllerRight(Players.P1)) && (!Player1Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        ++Player1Pos;
                        if (Player1Pos > Player1MaxPos - 1)
                        {
                            Player1Pos = 0;
                        }
                        StartCoroutine(InputLagP1(.2f));
                    }

                    break;

                default:
                    break;
                }

                break;

            case Joysticks.Black:

                switch (ControllerType)
                {
                case SupportedControllers.ArcadeBoard:

                    if ((ArcadeControls.JoystickLeft(PlayerInput)) && (!Player2Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        --Player2Pos;
                        if (Player2Pos < 0)
                        {
                            Player2Pos = Player2MaxPos - 1;
                        }
                        StartCoroutine(InputLagP2(.2f));
                    }
                    else if ((ArcadeControls.JoystickRight(PlayerInput)) && (!Player2Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        ++Player2Pos;
                        if (Player2Pos > Player2MaxPos - 1)
                        {
                            Player2Pos = 0;
                        }
                        StartCoroutine(InputLagP2(.2f));
                    }

                    break;

                case SupportedControllers.GamePadBoth:

                    if ((ControllerControls.ControllerLeft(Players.P2)) && (!Player2Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        --Player2Pos;
                        if (Player2Pos < 0)
                        {
                            Player2Pos = Player2MaxPos - 1;
                        }
                        StartCoroutine(InputLagP2(.2f));
                    }
                    else if ((ControllerControls.ControllerRight(Players.P2)) && (!Player2Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        ++Player2Pos;
                        if (Player2Pos > Player2MaxPos - 1)
                        {
                            Player2Pos = 0;
                        }
                        StartCoroutine(InputLagP2(.2f));
                    }

                    break;

                case SupportedControllers.KeyboardBoth:

                    if ((KeyboardControls.KeyboardLeft(Players.P2)) && (!Player2Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        --Player2Pos;
                        if (Player2Pos < 0)
                        {
                            Player2Pos = Player2MaxPos - 1;
                        }
                        StartCoroutine(InputLagP2(.2f));
                    }
                    else if ((KeyboardControls.KeyboardRight(Players.P2)) && (!Player2Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        ++Player2Pos;
                        if (Player2Pos > Player2MaxPos - 1)
                        {
                            Player2Pos = 0;
                        }
                        StartCoroutine(InputLagP2(.2f));
                    }

                    break;

                case SupportedControllers.KeyboardP1ControllerP2:

                    if ((ControllerControls.ControllerLeft(Players.P1)) && (!Player2Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        --Player2Pos;
                        if (Player2Pos < 0)
                        {
                            Player2Pos = Player2MaxPos - 1;
                        }
                        StartCoroutine(InputLagP2(.2f));
                    }
                    else if ((ControllerControls.ControllerRight(Players.P1)) && (!Player2Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        ++Player2Pos;
                        if (Player2Pos > Player2MaxPos - 1)
                        {
                            Player2Pos = 0;
                        }
                        StartCoroutine(InputLagP2(.2f));
                    }

                    break;

                case SupportedControllers.KeyboardP2ControllerP1:

                    if ((KeyboardControls.KeyboardLeft(Players.P1)) && (!Player2Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        --Player2Pos;
                        if (Player2Pos < 0)
                        {
                            Player2Pos = Player2MaxPos - 1;
                        }
                        StartCoroutine(InputLagP2(.2f));
                    }
                    else if ((KeyboardControls.KeyboardRight(Players.P1)) && (!Player2Inputted))
                    {
                        MenuAM.Play("Menu_Click", .4f);
                        ++Player2Pos;
                        if (Player2Pos > Player2MaxPos - 1)
                        {
                            Player2Pos = 0;
                        }
                        StartCoroutine(InputLagP2(.2f));
                    }

                    break;

                default:
                    break;
                }

                break;
            }
        }
Exemple #29
0
        protected override void Update()
        {
            base.Update();

            if (ScriptEnabled)
            {
                // Root Menu With Buttons
                if (!IsReplay)
                {
                    Debug.Log("hi>");

                    if (Confirm())
                    {
                        switch (pos)
                        {
                        case 0:
                            Rematch();
                            break;

                        case 1:
                            ReplaySelected();
                            break;

                        case 2:
                            ReturnToMenu();
                            break;

                        default:
                            break;
                        }
                    }

                    if (ValueChanged())
                    {
                        UpdateDisplay();
                    }

                    MoveLR();
                }
                else if ((IsReplay) && (!ReplayOptionSelected))
                {
                    MoveUD();

                    if (ValueChanged())
                    {
                        UpdateReplayDisplay();
                    }
                    Debug.Log("hi>>");

                    if (Confirm() && !IsCoR)
                    {
                        switch (pos)
                        {
                        case 0:
                            SelectedGamemode = Gamemodes.Lives;
                            IncrementAmount  = 1;
                            Value            = 5;
                            minValue         = Value;
                            UpdateTextValue();
                            break;

                        case 1:
                            SelectedGamemode = Gamemodes.Timer;
                            IncrementAmount  = 15;
                            Value            = 60;
                            minValue         = Value;
                            UpdateTextValue();
                            break;

                        case 2:
                            SelectedGamemode = Gamemodes.SetScore;
                            IncrementAmount  = 1000;
                            Value            = 1000;
                            minValue         = Value;
                            UpdateTextValue();
                            break;

                        default:
                            break;
                        }

                        ReplayOptionSelected = true;
                    }
                    else if (Return() && !IsCoR)
                    {
                        pos      = 1;
                        IsReplay = false;
                        StartCoroutine(InputDelay());
                    }
                }
                else if ((IsReplay) && (ReplayOptionSelected))
                {
                    Debug.Log("hi>>>");
                    if (Confirm() && !IsCoR)
                    {
                        SaveManager.SaveUltimatePinballGamemode((int)SelectedGamemode, IncrementAmount, Value);
                        StartCoroutine(LoadReplay());
                    }
                    else if (Return() && !IsCoR)
                    {
                        ReplayOptionSelected = false;
                        StartCoroutine(InputDelay());
                    }
                }
                else
                {
                    Debug.Log("hi");
                }
            }



            if (IsReplay && ReplayCanvas.alpha != 1)
            {
                ReplayCanvas.alpha += Time.deltaTime * 2;
            }
            else if (!IsReplay && ReplayCanvas.alpha != 0)
            {
                ReplayCanvas.alpha -= Time.deltaTime * 2;
            }

            // Updates the amount needed text and revials it
            if (IsReplay && ReplayOptionSelected && SelectedGamemode != Gamemodes.None)
            {
                if (ReplayValueCanvas.alpha != 1)
                {
                    ReplayValueCanvas.alpha += Time.deltaTime * 2;
                }

                switch (ControllerType)
                {
                case SupportedControllers.ArcadeBoard:

                    if ((ArcadeControls.JoystickLeft(Joysticks.White) && (!IsCoR)))
                    {
                        if (Value != minValue)
                        {
                            Value -= IncrementAmount;
                        }
                        StartCoroutine(InputDelay());
                        UpdateTextValue();
                    }
                    if ((ArcadeControls.JoystickRight(Joysticks.White) && (!IsCoR)))
                    {
                        Value += IncrementAmount;
                        StartCoroutine(InputDelay());
                        UpdateTextValue();
                    }

                    break;

                case SupportedControllers.GamePadBoth:

                    if ((ControllerControls.ControllerLeft(Players.P1) && (!IsCoR)))
                    {
                        if (Value != minValue)
                        {
                            Value -= IncrementAmount;
                        }
                        StartCoroutine(InputDelay());
                        UpdateTextValue();
                    }
                    if ((ControllerControls.ControllerRight(Players.P1) && (!IsCoR)))
                    {
                        Value += IncrementAmount;
                        StartCoroutine(InputDelay());
                        UpdateTextValue();
                    }

                    break;

                case SupportedControllers.KeyboardBoth:

                    if ((KeyboardControls.KeyboardLeft(Players.P1) && (!IsCoR)))
                    {
                        if (Value != minValue)
                        {
                            Value -= IncrementAmount;
                        }
                        StartCoroutine(InputDelay());
                        UpdateTextValue();
                    }
                    if ((KeyboardControls.KeyboardRight(Players.P1) && (!IsCoR)))
                    {
                        Value += IncrementAmount;
                        StartCoroutine(InputDelay());
                        UpdateTextValue();
                    }

                    break;

                case SupportedControllers.KeyboardP1ControllerP2:

                    if ((KeyboardControls.KeyboardLeft(Players.P1) && (!IsCoR)))
                    {
                        if (Value != minValue)
                        {
                            Value -= IncrementAmount;
                        }
                        StartCoroutine(InputDelay());
                        UpdateTextValue();
                    }
                    if ((KeyboardControls.KeyboardRight(Players.P1) && (!IsCoR)))
                    {
                        Value += IncrementAmount;
                        StartCoroutine(InputDelay());
                        UpdateTextValue();
                    }

                    break;

                case SupportedControllers.KeyboardP2ControllerP1:

                    if ((ControllerControls.ControllerLeft(Players.P1) && (!IsCoR)))
                    {
                        if (Value != minValue)
                        {
                            Value -= IncrementAmount;
                        }
                        StartCoroutine(InputDelay());
                        UpdateTextValue();
                    }
                    if ((ControllerControls.ControllerRight(Players.P1) && (!IsCoR)))
                    {
                        Value += IncrementAmount;
                        StartCoroutine(InputDelay());
                        UpdateTextValue();
                    }

                    break;

                default:
                    break;
                }
            }
            else if (IsReplay && !ReplayOptionSelected && ReplayValueCanvas.alpha != 0)
            {
                ReplayValueCanvas.alpha -= Time.deltaTime * 2;
            }
        }
        protected override void Update()
        {
            base.Update();

            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                if (ArcadeControls.ButtonPress(Player, Buttons.B1))
                {
                    DeflectPowerup();
                }

                break;

            case SupportedControllers.GamePadBoth:

                if (ControllerControls.ButtonPress(ConvertToPlayers(), ControllerButtons.A))
                {
                    DeflectPowerup();
                }

                break;

            case SupportedControllers.KeyboardBoth:

                if (KeyboardControls.ButtonPress(ConvertToPlayers(), Buttons.B1))
                {
                    DeflectPowerup();
                }

                break;

            case SupportedControllers.KeyboardP1ControllerP2:

                if (ConvertToPlayers() == Players.P1)
                {
                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B1))
                    {
                        DeflectPowerup();
                    }
                }
                else
                {
                    if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.A))
                    {
                        DeflectPowerup();
                    }
                }

                break;

            case SupportedControllers.KeyboardP2ControllerP1:

                if (ConvertToPlayers() == Players.P2)
                {
                    if (KeyboardControls.ButtonPress(Players.P1, Buttons.B1))
                    {
                        DeflectPowerup();
                    }
                }
                else
                {
                    if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.A))
                    {
                        DeflectPowerup();
                    }
                }

                break;

            default:
                break;
            }
        }
Exemple #31
0
        protected override void Update()
        {
            base.Update();

            if (Script_Active)
            {
                // Is a Multi Option
                if (Multi_Option)
                {
                    // Input
                    if (CanInput)
                    {
                        MenuInput_MultiOption();
                    }

                    // Update Selected Visual - ( if needed )
                    if (UpdateSelectedNeeded())
                    {
                        UpdateSelectedVisuals();
                    }
                }
                else
                {
                    switch (ControllerType)
                    {
                    case SupportedControllers.ArcadeBoard:

                        if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B7) && (Use_Return_Event))
                        {
                            ReturnEvent.Invoke();
                        }
                        if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B8))
                        {
                            ScreenEvents[0].Invoke();
                        }

                        break;

                    case SupportedControllers.GamePadBoth:

                        if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.B) && (Use_Return_Event))
                        {
                            ReturnEvent.Invoke();
                        }
                        if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.A))
                        {
                            ScreenEvents[0].Invoke();
                        }

                        break;

                    case SupportedControllers.KeyboardBoth:

                        if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7) && (Use_Return_Event))
                        {
                            ReturnEvent.Invoke();
                        }
                        if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                        {
                            ScreenEvents[0].Invoke();
                        }

                        break;

                    case SupportedControllers.KeyboardP1ControllerP2:

                        if (KeyboardControls.ButtonPress(Players.P1, Buttons.B7) && (Use_Return_Event))
                        {
                            ReturnEvent.Invoke();
                        }
                        if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                        {
                            ScreenEvents[0].Invoke();
                        }

                        break;

                    case SupportedControllers.KeyboardP2ControllerP1:

                        if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.B) && (Use_Return_Event))
                        {
                            ReturnEvent.Invoke();
                        }
                        if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.A))
                        {
                            ScreenEvents[0].Invoke();
                        }

                        break;

                    default:
                        break;
                    }
                }

                FadeInCanvasGroup_and_FadeOutThisCanvasGroup();
            }
        }