Ejemplo n.º 1
0
	void Start()
	{
#if UNITY_STANDALONE_WIN
		manager = new XGamepadManager (xGamepadLayout);
#else
		manager = new UnGamepadManager (unGamepadConfigs);
#endif
	
		manager.OnGamepadAdded += GamepadAdded;
		manager.OnGamepadRemoved += GamepadRemoved;
		
		manager.Init ();
	}
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance != this)
        {
            Destroy(gameObject);
        }

        if (dontDestroyOnLoad)
        {
            DontDestroyOnLoad(gameObject);
        }

        InitDictionnaries();
        InitPanels();

        _eventSystem           = EventSystem.current;
        _standaloneInputModule = _eventSystem.gameObject.GetComponent <StandaloneInputModule>();

        switch (startState)
        {
        case GamepadManagerState.WaitForFirstJoystick:
            WaitForFirstJoystick();
            break;

        case GamepadManagerState.CheckForOneJoystick:
            CheckForOnePlayer(true);
            break;

        case GamepadManagerState.CheckForTwoJoystick:
            CheckForTwoPlayer(true);
            break;

        case GamepadManagerState.CheckForThreeJoystick:
            CheckForThreePlayer(true);
            break;

        case GamepadManagerState.CheckForFourJoystick:
            CheckForOnePlayer(true);
            break;

        case GamepadManagerState.DoNothing:
            DoNothing();
            break;
        }
    }
Ejemplo n.º 3
0
        // ------------------
        private bool JustPressedSubmitButton()
        {
            if (UnityEngine.Input.GetKeyDown(KeyCode.Return))
            {
                return(true);
            }

            GamepadManager g = GamepadManager.activeManager;

            if ((g != null) && (g.GetCombinedGamepad().GetKeyDown(this.submitGamepadButton) || g.GetCombinedGamepad().GetKeyDown(this.submitGamepadButtonAlt)))
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 4
0
        // ------------------
        private bool JustPressedCancelButton()
        {
            if (ControlFreak2.CF2Input.GetKeyDown(KeyCode.Escape))
            {
                return(true);
            }

            GamepadManager g = GamepadManager.activeManager;

            if ((g != null) && (g.GetCombinedGamepad().GetKeyDown(this.cancelGamepadButton) || g.GetCombinedGamepad().GetKeyDown(this.cancelGamepadButtonAlt)))
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 5
0
        public MenuWorld()
        {
            allImages   = LoadAllPlayers();
            takenImages = new List <string>();

            controllerMenus = new Dictionary <int, ControllerSelect>();
            pool            = new Stack <int>();

            for (int i = 0; i < 4; i++)
            {
                if (GamepadManager.GetSlot(i).IsConnected)
                {
                    AddController(i);
                }
            }
        }
Ejemplo n.º 6
0
        // -------------------
        static private InputAxisList GetControlFreakAxes()
        {
            InputAxisList axes = new InputAxisList(5 + (GamepadManager.MAX_JOYSTICKS * GamepadManager.MAX_INTERNAL_AXES));

            // Add mouse definit
            axes.Add(new InputAxis()
            {
                name = InputRig.CF_EMPTY_AXIS, sensitivity = 1f, type = AxisType.KeyOrMouseButton
            });
            axes.Add(new InputAxis()
            {
                name = InputRig.CF_MOUSE_DELTA_X_AXIS, sensitivity = 1f, type = AxisType.MouseMovement, axis = 1
            });
            axes.Add(new InputAxis()
            {
                name = InputRig.CF_MOUSE_DELTA_Y_AXIS, sensitivity = 1f, type = AxisType.MouseMovement, axis = 2
            });
            axes.Add(new InputAxis()
            {
                name = InputRig.CF_SCROLL_WHEEL_X_AXIS, sensitivity = 1f, type = AxisType.MouseMovement, axis = 3
            });
            axes.Add(new InputAxis()
            {
                name = InputRig.CF_SCROLL_WHEEL_Y_AXIS, sensitivity = 1f, type = AxisType.MouseMovement, axis = 4
            });


            // Add gamepad definitions...

            for (int i = 0; i < GamepadManager.MAX_JOYSTICKS; i++)
            {
                for (int j = 0; j < GamepadManager.MAX_INTERNAL_AXES; j++)
                {
                    axes.Add(new InputAxis()
                    {
                        name        = GamepadManager.GetJoyAxisName(i, j),
                        dead        = 0.2f,
                        sensitivity = 1f,
                        type        = AxisType.JoystickAxis,
                        axis        = (j + 1),
                        joyNum      = (i + 1)
                    });
                }
            }

            return(axes);
        }
Ejemplo n.º 7
0
        // ----------------------
        static public ControlFreak2.GamepadManager CreateGamepadManager(
            bool withNotifier,
            CreationMode creationMode,
            string undoLabel = null)
        {
            int gmPresence = IsThereGamepadManagerInTheScene();

            if ((gmPresence != 0) && (creationMode == CreationMode.OnlyIfNotPresent))
            {
                return(null);
            }

            if ((gmPresence != 0) && (creationMode == CreationMode.AskIfPresent))
            {
                string msg = null;
                msg = "There's a CF2 Gamepad Manager in the scene already. Do you want to create a new one anyway?";
                if (!EditorUtility.DisplayDialog("Control Freak 2 - Create Gamepad Manager", msg, "Yes", "No"))
                {
                    return(null);
                }
            }

            GamepadManager gm = null;

            gm = (GamepadManager)TouchControlWizardUtils.CreateObjectWithComponent("CF2-Gamepad-Manager", typeof(ControlFreak2.GamepadManager));
            if (gm == null)
            {
                return(null);
            }

            if (withNotifier)
            {
                ControlFreak2.GamepadNotifier gn = CreateGamepadNotifer("CF2-Gamepad-Notifier", null);
                if (gn != null)
                {
                    gn.transform.SetParent(gm.transform, false);
                }
            }

            if (undoLabel != null)
            {
                Undo.RegisterCreatedObjectUndo(gm.gameObject, undoLabel);
            }

            return(gm);
        }
Ejemplo n.º 8
0
        public void SetSlider(int controllerId, string sliderId, byte value)
        {
            Xbox360Slider slider;

            if (sliderId == "lt")
            {
                slider = Xbox360Slider.LeftTrigger;
            }
            else if (sliderId == "rt")
            {
                slider = Xbox360Slider.RightTrigger;
            }
            else
            {
                throw new ArgumentException(sliderId);
            }
            GamepadManager.SetSlider(controllerId, slider, value);
        }
Ejemplo n.º 9
0
    //------------------------------------------------------------------------------------------
    // Start
    //------------------------------------------------------------------------------------------
    void Start()
    {
        rig             = GetComponent <Rigidbody2D>();
        isGround        = false;
        checkController = false;
        dir             = Integer.ZERO;
        lastDir         = Integer.ZERO;
        dirCount        = Integer.ZERO;
        jumpForce       = defaultJumpForce;
        jumpCount       = Integer.ZERO;
        jumpStopFlag    = false;
        jumpTiming      = false;
        playerSpeed     = accelForce;

        gamaepadManager = gamepadManagerObject.GetComponent <GamepadManager>();
        bubbleGenerator = bubbleG.GetComponent <BubbleGenerator>();
        bulletGenerator = bulletG.GetComponent <BulletGenerator>();
    }
Ejemplo n.º 10
0
        // Update is called once per frame
        void Update()
        {
            timeSinceLastCrash += Time.deltaTime;

            // Fail Check
            if (FailCheck())
            {
                return;
            }

            // Check Pause Button
            if (QuadcopterControls.Pause())
            {
                TogglePause();
            }

            if (!_Paused)
            {
                // Update State
                _States.UpdateStates(ref _Settings);
            }

            if (QuadcopterControls.ResetOrientation())
            {
                transform.eulerAngles = Vector3.zero;
            }

            if (QuadcopterControls.ResetLevel())
            {
                transform.position    = _SpawnPosition;
                transform.eulerAngles = Vector3.zero;

                if (cameraOverride != null)
                {
                    cameraOverride.setHealth(0.0f);
                }

                _Settings._Broken = false;
            }

            // Udate Controls
            GamepadManager.Update();
        }
Ejemplo n.º 11
0
        public override void Update(GameTime gameTime)
        {
            time += (float)gameTime.ElapsedGameTime.TotalSeconds;
            if (KeyboardManager.KeyPressedUp(Keys.Space) || GamepadManager.ProceedButtonPressedUp())
            {
                if (fadephase < 2)
                {
                    time = 8f;
                }
            }

            switch (fadephase)
            {
            case (0):
                currentColor = Color.Lerp(Color.Black, Color.White, time / 3f);
                if (currentColor == Color.White)
                {
                    fadephase = 1;
                }
                break;

            case (1):
                if (time > 8f)
                {
                    fadephase = 2;
                }
                break;

            case (2):
                currentColor = Color.Lerp(Color.White, Color.Black, (time - 8f) / 3f);
                if (currentColor == Color.Black)
                {
                    FadeComplete();
                }
                break;

            default:
                break;
            }
        }
Ejemplo n.º 12
0
        void InitController()
        {
            var slot = GamepadManager.GetSlot(ControllerId);

            if (!slot.IsConnected)
            {
                return;
            }

            if (SnesController.IsMatch(slot))
            {
                var snes = new SnesController(slot);
                Jump            = snes.B;
                Attack          = snes.Y;
                Dodge           = snes.R;
                ActivateUpgrade = snes.X;
                Guard           = snes.L;
                Start           = snes.Start;

                Direction = snes.Dpad;
            }
            else if (Xbox360Controller.IsMatch(slot))
            {
                var xbox = new Xbox360Controller(slot);

                Jump            = xbox.A;
                Attack          = xbox.X;
                Dodge           = xbox.RB;
                ActivateUpgrade = xbox.Y;
                Guard           = xbox.LB;
                Start           = xbox.Start;

                Direction = xbox.LeftStick;
            }
            else
            {
                throw new Exception("invalid controller woh");
            }
        }
    /*
     * private void Awake()
     * {
     *
     * }
     */
    void Awake()
    {
        if (_instance == null)
        {
            DontDestroyOnLoad(gameObject);
            _instance = this;
        }
        else
        {
            Destroy(gameObject);
        }
#if UNITY_STANDALONE_WIN
        manager = new XGamepadManager(xGamepadLayout);
#else
        manager = new UnGamepadManager(unGamepadConfigs);
#endif

        manager.OnGamepadAdded   += GamepadAdded;
        manager.OnGamepadRemoved += GamepadRemoved;

        manager.Init();
    }
Ejemplo n.º 14
0
    // Update is called once per frame
    void Update()
    {
        if (numControllers < 4)
        {
            // Try to get defender gamepad
            Gamepad defender_gp = GamepadManager.getPlayerController(1);
            if (defender_gp != null && defender_mov.controller == null)
            {
                numControllers++;
                defender_mov.controller = defender_gp;
            }

            // Try to get attacker1 gamepad
            Gamepad attacker1_gp = GamepadManager.getPlayerController(2);
            if (attacker1_gp != null && attacker1_mov.controller == null)
            {
                numControllers++;
                attacker1_mov.controller = attacker1_gp;
            }

            // Try to get attacker1 gamepad
            Gamepad attacker2_gp = GamepadManager.getPlayerController(3);
            if (attacker2_gp != null && attacker2_mov.controller == null)
            {
                numControllers++;
                attacker2_mov.controller = attacker2_gp;
            }

            // Try to get attacker1 gamepad
            Gamepad attacker3_gp = GamepadManager.getPlayerController(4);
            if (attacker3_gp != null && attacker3_mov.controller == null)
            {
                numControllers++;
                attacker3_mov.controller = attacker3_gp;
            }
        }
    }
Ejemplo n.º 15
0
 private void ListenGamepad()
 {
     pad = GamepadManager.GetCurrentPad();
     if (null != pad && !pad.isUse)
     {
         if (currentPlayer < 2)
         {
             pad.isUse = true;
             CreaeteShooterPlayer(pad);
         }
         else if (currentPlayer < 3)
         {
             pad.isUse = true;
             CreateDefenderPlayer(pad);
         }
         else
         {
             pad.isUse = true;
             CreateRunnerPlayer(pad);
             GameStateManager.SetCurrentState(PlayingState.Instance);
         }
         currentPlayer++;
     }
 }
Ejemplo n.º 16
0
        static public void MenuCreateEventSystemAndGamepadManager()
        {
            string undoLabel = "Create CF2 Event System and Gamepad Manager";

            UnityEngine.EventSystems.EventSystem
                sys = CreateEventSystem("CF2-Event-System", CreationMode.OnlyIfNotPresent, null);

            GamepadManager
                gm = CreateGamepadManager(true, CreationMode.OnlyIfNotPresent, null);

            if (sys != null)
            {
                Undo.RegisterCreatedObjectUndo(sys.gameObject, undoLabel);
            }
            if (gm != null)
            {
                Undo.RegisterCreatedObjectUndo(gm.gameObject, undoLabel);
            }

            if ((gm != null) || (sys != null))
            {
                Selection.activeObject = ((gm != null) ? (Object)gm : (Object)sys);
            }
        }
Ejemplo n.º 17
0
        public override void Update(GameTime gameTime)
        {
            time += (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (cheatTextCurrentColor != Color.Transparent)
            {
                cheatTextCurrentColor = Color.Lerp(Color.Gold, Color.Transparent, ((float)gameTime.TotalGameTime.TotalSeconds - cheatInputTime) / 4f);
            }

            if (fadephase < 2 && (KeyboardManager.KeyPressedUp(Keys.Space) || KeyboardManager.KeyPressedUp(Keys.Enter) || KeyboardManager.KeyPressedUp(Keys.Escape) || GamepadManager.ProceedButtonPressedUp()))
            {
                backgroundCurrentColor = Color.White;
                text1CurrentColor      = Color.White;
                text2CurrentColor      = Color.White;
                startTextColor         = Color.White;
                startTextNextChange    = time + .8f;
                fadephase = 2;
            }
            else if (fadephase == 2)
            // Process input on the main screen...
            {
                if (KeyboardManager.KeyDown(Keys.LeftShift) || GamepadManager.AnyShoulderButtonDown())
                {
                    // Get the input to add to the cheat string.
                    if (KeyboardManager.KeyPressedUp(Keys.Up) || GamepadManager.UpButtonPressedUp())
                    {
                        cheatInputText = String.Concat(cheatInputText, "U");
                    }
                    if (KeyboardManager.KeyPressedUp(Keys.Down) || GamepadManager.DownButtonPressedUp())
                    {
                        cheatInputText = String.Concat(cheatInputText, "D");
                    }
                    if (KeyboardManager.KeyPressedUp(Keys.Left) || GamepadManager.LeftButtonPressedUp())
                    {
                        cheatInputText = String.Concat(cheatInputText, "L");
                    }
                    if (KeyboardManager.KeyPressedUp(Keys.Right) || GamepadManager.RightButtonPressedUp())
                    {
                        cheatInputText = String.Concat(cheatInputText, "R");
                    }

                    CheckCheats(gameTime);
                }
                else
                {
                    cheatInputText = "";
                }


                if ((KeyboardManager.KeyPressedDown(Keys.Enter) || GamepadManager.ProceedButtonPressedUp()) && !HelpShown && !CreditsShown)
                {
                    // Begin the game...
                    fadephase = 3;
                    music.Stop();
                    time                = 0f;
                    startTextColor      = Color.White;
                    startTextNextChange = 0.05f;
                    GameStartSound.Play();
                }
                else
                {
                    if (KeyboardManager.KeyDown(Keys.C))
                    {
                        CreditsShown = true;
                    }
                    else
                    {
                        CreditsShown = false;
                    }

                    if (KeyboardManager.KeyDown(Keys.H))
                    {
                        HelpShown = true;
                    }
                    else
                    {
                        HelpShown = false;
                    }
                }
            }

            switch (fadephase)
            {
            case (0):
                backgroundCurrentColor = Color.Lerp(Color.Black, Color.White, time / 3f);
                if (backgroundCurrentColor == Color.White)
                {
                    fadephase = 1;
                }
                break;

            case (1):
                if (time > 3.5f)
                {
                    text1CurrentColor = Color.Lerp(Color.Transparent, Color.White, (time - 3.5f) / 1.8f);
                    text2CurrentColor = Color.Lerp(Color.Transparent, Color.White, (time - 5f) / 3f);
                }
                if (time > 8f)
                {
                    startTextColor      = Color.White;
                    startTextNextChange = 8.8f;
                    fadephase           = 2;
                }
                break;

            case (2):
            {
                if (time > startTextNextChange)
                {
                    if (startTextColor == Color.White)
                    {
                        startTextColor = Color.Transparent;
                    }
                    else
                    {
                        startTextColor = Color.White;
                    }

                    startTextNextChange += .8f;
                }
            }
            break;

            case (3):
                if (time > startTextNextChange)
                {
                    if (startTextColor == Color.White)
                    {
                        startTextColor = Color.Yellow;
                    }
                    else
                    {
                        startTextColor = Color.White;
                    }

                    startTextNextChange += .05f;
                }
                if (time > 1.5f)
                {
                    startTextColor = Color.Transparent;
                    fadephase      = 4;
                    time           = 0;
                }
                break;

            case (4):
                backgroundCurrentColor = Color.Lerp(Color.White, Color.Black, time / 1.5f);
                text1CurrentColor      = Color.Lerp(Color.White, Color.Black, time / 1.5f);
                text2CurrentColor      = Color.Lerp(Color.White, Color.Black, time / 1.5f);
                //startTextColor = Color.Lerp(Color.White, Color.Black, time / 1.5f);

                if (time > 1.8f)
                {
                    Game.ChangeScene(new GameScene(Game));
                }
                break;

            default:
                break;
            }
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Create a new engine with the given managers.
 /// </summary>
 /// <param name="renderer">The render manager.</param>
 /// <param name="audioPlayer">The audio manager.</param>
 /// <param name="mouse">The mouse manager.</param>
 /// <param name="keyboard">The keyboard manager.</param>
 public Engine(Renderer renderer, AudioPlayer audioPlayer, Mouse mouse, Keyboard keyboard, GamepadManager gamepadManager)
 {
     this.renderer       = renderer;
     this.audioPlayer    = audioPlayer;
     this.mouse          = mouse;
     this.keyboard       = keyboard;
     this.gamepadManager = gamepadManager;
 }
Ejemplo n.º 19
0
        static public void MenuCreateGamepadManagerWithNotifier()
        {
            GamepadManager gm = CreateGamepadManager(true, CreationMode.AskIfPresent, "Create CF2 Gamepad Manager with Notifier");

            Selection.activeObject = gm;
        }
Ejemplo n.º 20
0
        public async Task NewGamepad()
        {
            int controllerId = await GamepadManager.ConnectGamepad();

            await Clients.Caller.SendAsync("GamepadConnected", controllerId);
        }
Ejemplo n.º 21
0
 private void Awake()
 {
     _instance = this;
 }
Ejemplo n.º 22
0
        public override void Update(GameTime gameTime)
        {
            currentGameTime = (float)gameTime.TotalGameTime.TotalSeconds;

            Vector2 movement = new Vector2();
            // Update controls
            float moveSpeed;

            if (KeyboardManager.KeyDown(Keys.LeftShift) || GamepadManager.AButtonDown() || GamepadManager.AnyShoulderButtonDown())
            {
                moveSpeed = speed / 2.5f;
            }
            else
            {
                moveSpeed = speed;
            }


            if (KeyboardManager.KeyDown(Keys.Left) || GamepadManager.LeftButtonDown())
            {
                movement.X = -1 * (moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds);
            }
            if (KeyboardManager.KeyDown(Keys.Right) || GamepadManager.RightButtonDown())
            {
                movement.X = (moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds);
            }
            if (KeyboardManager.KeyDown(Keys.Up) || GamepadManager.UpButtonDown())
            {
                movement.Y = -1 * (moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds);
            }
            if (KeyboardManager.KeyDown(Keys.Down) || GamepadManager.DownButtonDown())
            {
                movement.Y = (moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds);
            }

            if ((KeyboardManager.KeyDown(Keys.Space) || GamepadManager.XButtonDown()) && gameTime.TotalGameTime.TotalSeconds > nextFireTime && CanFire)
            {
                // Fire!
                AudioManager.PlaySoundEffect(GameScene.Shot3Sound, .2f);
                Bullet newBullet = mainEmitter.FireBullet(((float)Math.PI / 2) * 3, 500f, Color.GreenYellow, BulletType.Diamond, true);
                newBullet.SetCollisionLayer(2);
                newBullet.DrawLayer = .1f;

                nextFireTime = (float)gameTime.TotalGameTime.TotalSeconds + .1f;
            }

            // Calculate the movement from the sticks if they exist
            movement.X += (moveSpeed * GamepadManager.LeftStickX() * (float)gameTime.ElapsedGameTime.TotalSeconds);
            movement.Y -= (moveSpeed * GamepadManager.LeftStickY() * (float)gameTime.ElapsedGameTime.TotalSeconds);

            Position += movement;

            // Now clamp the position...

            if (Center.X - Origin.X < thisScene.ScreenArea.X)
            {
                Center = new Vector2(thisScene.ScreenArea.X + Origin.X, Center.Y);
            }
            else if (Center.X + Origin.X > thisScene.ScreenArea.X + thisScene.ScreenArea.Width)
            {
                Center = new Vector2(thisScene.ScreenArea.X + thisScene.ScreenArea.Width - Origin.X, Center.Y);
            }

            if (Center.Y - Origin.Y < thisScene.ScreenArea.Y)
            {
                Center = new Vector2(Center.X, thisScene.ScreenArea.Y + Origin.Y);
            }
            else if (Center.Y + Origin.Y > thisScene.ScreenArea.Y + thisScene.ScreenArea.Height)
            {
                Center = new Vector2(Center.X, thisScene.ScreenArea.Y + thisScene.ScreenArea.Height - Origin.Y);
            }

            //Test a hoolio
            base.Update(gameTime);
        }
Ejemplo n.º 23
0
 // Use this for initialization
 void Start()
 {
     manager = GamepadManager.Instance;
     //  gamepad = manager.GetGamepad();
     gamepad = manager.GetGamepad(papa);
 }
Ejemplo n.º 24
0
        public ControllerSelect(MenuWorld parent, int playerSlot, int joyId)
        {
            var font = Library.GetFont("fonts/Laffayette_Comic_Pro.ttf");

            changing = false;

            this.parent = parent;
            Height      = FP.Height - 20;
            Width       = 250;

            this.JoyId      = joyId;
            this.PlayerSlot = playerSlot;

            Image            = new Image(Library.GetTexture("menu.png"));
            Image.Color      = new Color(Color = colors[PlayerSlot]);
            pressStart       = new Text("PRESS START");
            pressStart.Font  = font;
            pressStart.X    -= 80;
            pressStart.Y     = Height - 100;
            pressStart.Size  = 20;
            pressStart.Color = new Color(0);

            check = new Image(Library.GetTexture("ready.png"));
            check.CenterOO();
            check.Y      = Height * 0.75f;
            check.ScaleY = 0;

            OriginX       = Width / 2;
            Image.OriginX = Image.Width / 2;

            var slot = GamepadManager.GetSlot(joyId);

            if (SnesController.IsMatch(slot))
            {
                var snes = new SnesController(slot);
                confirm = new Image(Library.GetTexture("Snes_1.png"));
                Cursor  = snes.Dpad;
                Start   = snes.Start;
                Back    = snes.A;
                Confirm = snes.B;
            }
            else if (Xbox360Controller.IsMatch(slot))
            {
                var xbox = new Xbox360Controller(slot);
                confirm = new Image(Library.GetTexture("Xbox_1.png"));
                Cursor  = xbox.LeftStick;
                Start   = xbox.Start;
                Confirm = xbox.A;
                Back    = xbox.B;
            }
            else
            {
                throw new Exception("Invalid gamepad type, sorry D:");
            }

            AddComponent(Image);
            AddComponent(pressStart);
            if (wins.ContainsKey(JoyId))
            {
                var score = new Text(wins[joyId].ToString("Wins: 0"));
                score.Font  = font;
                score.Color = new Color(0);
                score.Size  = 20;
                score.X     = pressStart.X + 32;
                score.Y     = pressStart.Y + score.Size;
                AddComponent(score);
            }
        }
Ejemplo n.º 25
0
 public void Disconnect(int controllerId)
 {
     GamepadManager.Disconnect(controllerId);
 }
Ejemplo n.º 26
0
 void Start()
 {
     rb      = GetComponent <Rigidbody> ();
     manager = GamepadManager.Instance;
     gamepad = manager.GetGamepad(player);
 }
Ejemplo n.º 27
0
 public void AlivePing(int controllerId)
 {
     GamepadManager.MarkAsAlive(controllerId);
 }
Ejemplo n.º 28
0
 public MainWindow()
 {
     InitializeComponent();
     CurrentGamepadManager = new GamepadManager();
     CurrentGamepadManager.ErrorOccuredEvent += CurrentGamepadManager_ErrorOccuredEvent;
 }
Ejemplo n.º 29
0
    // Update is called once per frame
    void Update()
    {
#if (UNITY_EDITOR)
        // Modify Time Scale
        if (GamepadManager.GetControllerKeyReleased(playersWithAccess[0], GamepadManager.ButtonCode.Y))
        {
            Time.timeScale++;
        }
        else if (GamepadManager.GetControllerKeyReleased(playersWithAccess[0], GamepadManager.ButtonCode.X))
        {
            Time.timeScale--;
        }

        // Other stuff
        if (GamepadManager.GetControllerKeyReleased(playersWithAccess[0], GamepadManager.ButtonCode.Shldr_LEFT))
        {
            LevelController.respawnTiles = !LevelController.respawnTiles;
        }
        if (GamepadManager.GetControllerKeyReleased(playersWithAccess[0], GamepadManager.ButtonCode.Shldr_RIGHT))
        {
            LevelController.timedFall = !LevelController.timedFall;
        }

        currentButtonName = currentButton.gameObject.name;
#endif

        if (!currentButton.GetComponent <Button>().interactable&& !lockToStartButton)
        {
            try { currentButton = currentButton.GetComponent <ButtonLinker>().getRight(); }
            catch
            {
                try { currentButton = currentButton.GetComponent <ButtonLinker>().getDown(); }
                catch { Debug.Log("Controller cursor locked on inactive button!"); }
            };
        }

        for (int k = 0; k < playersWithAccess.Length; k++)
        {
            // Press A
            if (GamepadManager.GetControllerKeyReleased(playersWithAccess[k], GamepadManager.ButtonCode.A) || keyboardNavigation(Jump))
            {
                ExecuteEvents.Execute(currentButton, buttonInteract, ExecuteEvents.pointerClickHandler);
                if (currentButton.GetComponent <ButtonLinker>().transitionButton)
                {
                    ExecuteEvents.Execute(currentButton, buttonInteract, ExecuteEvents.pointerExitHandler);
                    currentButton = currentButton.GetComponent <ButtonLinker>().target;
                    ExecuteEvents.Execute(currentButton, buttonInteract, ExecuteEvents.pointerEnterHandler);
                }
                currentThumbstickTime = thumbstickTime;
            }

            // Press B
            if (GamepadManager.GetControllerKeyReleased(playersWithAccess[k], GamepadManager.ButtonCode.B) || Input.GetKeyDown(KeyCode.Escape))
            {
                if (currentButton.GetComponent <ButtonLinker>().backButton != null)
                {
                    ExecuteEvents.Execute(currentButton.GetComponent <ButtonLinker>().backButton, buttonInteract, ExecuteEvents.pointerClickHandler);
                    ExecuteEvents.Execute(currentButton, buttonInteract, ExecuteEvents.pointerExitHandler);
                    currentButton = currentButton.GetComponent <ButtonLinker>().backButton.GetComponent <ButtonLinker>().target;
                    ExecuteEvents.Execute(currentButton, buttonInteract, ExecuteEvents.pointerEnterHandler);
                }
                currentThumbstickTime = thumbstickTime;
            }

            if (currentThumbstickTime <= 0f)
            {
                // Press UP
                if (controllerMenuNavigation(playersWithAccess[k], Up) || keyboardNavigation(Up))
                {
                    ExecuteEvents.Execute(currentButton, buttonInteract, ExecuteEvents.pointerExitHandler);
                    try
                    {
                        currentButton = currentButton.GetComponent <ButtonLinker>().getUp();
                    }
                    catch { Debug.Log("UP Direction is NULL"); };

                    cursor.transform.position = currentButton.transform.position;
                    currentThumbstickTime     = thumbstickTime;
                    ExecuteEvents.Execute(currentButton, buttonInteract, ExecuteEvents.pointerEnterHandler);
                }

                // Press Down
                else if (controllerMenuNavigation(playersWithAccess[k], Down) || keyboardNavigation(Down))
                {
                    ExecuteEvents.Execute(currentButton, buttonInteract, ExecuteEvents.pointerExitHandler);
                    try
                    {
                        currentButton = currentButton.GetComponent <ButtonLinker>().getDown();
                    }
                    catch { Debug.Log("DOWN Direction is NULL"); };

                    cursor.transform.position = currentButton.transform.position;
                    currentThumbstickTime     = thumbstickTime;
                    ExecuteEvents.Execute(currentButton, buttonInteract, ExecuteEvents.pointerEnterHandler);
                }

                // Press Left
                else if (controllerMenuNavigation(playersWithAccess[k], Left) || keyboardNavigation(Left))
                {
                    ExecuteEvents.Execute(currentButton, buttonInteract, ExecuteEvents.pointerExitHandler);
                    try
                    {
                        currentButton = currentButton.GetComponent <ButtonLinker>().getLeft();
                    }
                    catch { Debug.Log("LEFT Direction is NULL"); };
                    cursor.transform.position = currentButton.transform.position;
                    currentThumbstickTime     = thumbstickTime;
                    ExecuteEvents.Execute(currentButton, buttonInteract, ExecuteEvents.pointerEnterHandler);
                }

                // Press Right
                else if (controllerMenuNavigation(playersWithAccess[k], Right) || keyboardNavigation(Right))
                {
                    ExecuteEvents.Execute(currentButton, buttonInteract, ExecuteEvents.pointerExitHandler);
                    try
                    {
                        currentButton = currentButton.GetComponent <ButtonLinker>().getRight();
                    }
                    catch { Debug.Log("RIGHT Direction is NULL"); };
                    cursor.transform.position = currentButton.transform.position;
                    currentThumbstickTime     = thumbstickTime;
                    ExecuteEvents.Execute(currentButton, buttonInteract, ExecuteEvents.pointerEnterHandler);
                }
            }
        }

        currentThumbstickTime -= Time.fixedDeltaTime; //Time.deltaTime;
    }
Ejemplo n.º 30
0
    // Initialize on Awake
    void Awake()
    {
        // Found a duplicate instance of this class, destroy it
        if (singleton != null && singleton != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            // Create singleton instance
            singleton = this;
            DontDestroyOnLoad(this.gameObject);

            // Lock gamepad count to supported range
            GamepadCount = Mathf.Clamp(GamepadCount, 1, 4);

            gamepads = new List<x360_Gamepad>();

            // Create specified number of gamepad instances
            for (int i = 0; i < GamepadCount; ++i)
                gamepads.Add(new x360_Gamepad(i + 1));
        }
    }
Ejemplo n.º 31
0
        public void SetButton(int controllerId, string btnId, bool pressed)
        {
            Xbox360Button button;

            switch (btnId)
            {
            case "a":
                button = Xbox360Button.A;
                break;

            case "b":
                button = Xbox360Button.B;
                break;

            case "x":
                button = Xbox360Button.X;
                break;

            case "y":
                button = Xbox360Button.Y;
                break;

            case "back":
                button = Xbox360Button.Back;
                break;

            case "start":
                button = Xbox360Button.Start;
                break;

            case "rb":
                button = Xbox360Button.RightShoulder;
                break;

            case "lb":
                button = Xbox360Button.LeftShoulder;
                break;

            case "left":
                button = Xbox360Button.Left;
                break;

            case "right":
                button = Xbox360Button.Right;
                break;

            case "up":
                button = Xbox360Button.Up;
                break;

            case "down":
                button = Xbox360Button.Down;
                break;

            case "leftThumb":
                button = Xbox360Button.LeftThumb;
                break;

            case "rightThumb":
                button = Xbox360Button.RightThumb;
                break;

            case "guide":
                button = Xbox360Button.Guide;
                break;

            default:
                throw new ArgumentException(btnId);
            }
            GamepadManager.SetButton(controllerId, button, pressed);
        }
Ejemplo n.º 32
0
        public override void Update(GameTime gameTime)
        {
            titleTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
            scriptManager.Update(gameTime);

            // Check for input to skip the screen
            if (KeyboardManager.KeyPressedUp(Keys.Space) || KeyboardManager.KeyPressedUp(Keys.Enter) || GamepadManager.ProceedButtonPressedUp())
            {
                Game.ChangeScene(new TitleScene(Game));
            }
        }
Ejemplo n.º 33
0
 public static void Init()
 {
     instance = new GamepadManager();
 }