Exemplo n.º 1
0
        private async void Start()
        {
            Platform.ImportCurrentStage();
            await UniTask.Yield();

            foreach (var color in humanPlayerColors)
            {
                Gamepad.GetInstance(color).Add(gamepadListeners[color] = new GamepadListener(color));
            }


            // spawn enemy
            EnemyTank.lifes[EnemyTank.Type.Big] = 1;
            EnemyAgent.SpawnTank().Forget();



            // spawn player
            PlayerTank.lifes[Tank.Color.Yellow] = 1;            // Test
            PlayerTank.lifes[Tank.Color.Green]  = 1;            // Test

            if (aiPlayerColors.Length != 0)
            {
                "Player Agent".Instantiate(transform);
            }
            foreach (var color in humanPlayerColors)
            {
                PlayerTank.Spawn(color, false).Forget();
            }
            foreach (var color in aiPlayerColors)
            {
                PlayerTank.Spawn(color, false).Forget();
            }
        }
Exemplo n.º 2
0
        private void fireInputEnd(InputDeviceType inputType, GamePadState gpdState, KeyboardState keyState, MouseState mosState, Keys keyBtn, GamepadCode gpdBtn, MouseCode mosBtn)
        {
            InputObject input = new InputObject(inputType, gpdState, mosState, keyBtn, gpdBtn, mosBtn);

            //General
            for (int i = 0; i < generalListeners.Count; i++)
            {
                GeneralInputListener listener = generalListeners[i];
                listener.InputEnded(input);
                switch (inputType)
                {
                case (InputDeviceType.Gamepad):
                    listener.GamepadInputEnded(input);
                    break;

                case (InputDeviceType.Keyboard):
                    listener.KeyboardInputEnded(input);
                    break;

                case (InputDeviceType.Mouse):
                    listener.MouseInputEnded(input);
                    break;
                }
            }
            //Others
            switch (inputType)
            {
            case (InputDeviceType.Gamepad):
                for (int i = 0; i < gamepadListeners.Count; i++)
                {
                    GamepadListener listener = gamepadListeners[i];
                    listener.InputEnded(input);
                }
                break;

            case (InputDeviceType.Keyboard):
                for (int i = 0; i < keyboardListeners.Count; i++)
                {
                    KeyboardListener listener = keyboardListeners[i];
                    listener.InputEnded(input);
                }
                if (keyboardBinds.ContainsKey(keyBtn))
                {
                    keyboardBinds[keyBtn].Ended();
                }
                break;

            case (InputDeviceType.Mouse):
                for (int i = 0; i < mouseListeners.Count; i++)
                {
                    MouseListener listener = mouseListeners[i];
                    listener.InputEnded(input);
                }
                break;

            default:
                break;
            }
        }
Exemplo n.º 3
0
        public Ple_GameWindow(int width, int height, GraphicsMode mode, string title, GameWindowFlags options,
                              DisplayDevice device, int major, int minor, GraphicsContextFlags flags)
            : base(width, height, mode, title, options, device, major, minor, flags)
        {
            xConsole.WriteLine(new String('-', 20), ConsoleColor.Cyan);

            GamepadListener.Start(this);

            xConsole.WriteLine(new String('-', 20), ConsoleColor.Cyan);
            return;
        }
Exemplo n.º 4
0
        protected override void OnDestroy()
        {
            Actions.Player.Disable();
            Actions.Player.SetCallbacks(null);

            if (null != GamepadListener)
            {
                Destroy(GamepadListener.gameObject);
            }
            GamepadListener = null;

            base.OnDestroy();
        }
Exemplo n.º 5
0
        public override void Initialize()
        {
            base.Initialize();

            if (!Player.IsLocalActor)
            {
                return;
            }

            _controls.Player.SetCallbacks(this);
            _controls.Player.Enable();

            GamepadListener = gameObject.AddComponent <GamepadListener>();
        }
Exemplo n.º 6
0
        protected override void OnDestroy()
        {
            if (PartyParrotManager.HasInstance)
            {
                PartyParrotManager.Instance.PauseEvent -= PauseEventHandler;
            }

            _controls.Player.Disable();
            _controls.Player.SetCallbacks(null);

            Destroy(GamepadListener);
            GamepadListener = null;

            base.OnDestroy();
        }
Exemplo n.º 7
0
        public void Initialize()
        {
            if (!Player.IsLocalActor)
            {
                return;
            }

            _gamepadListener = gameObject.AddComponent <GamepadListener>();

            InputManager.Instance.Controls.game.pause.performed += OnPause;

            InputManager.Instance.Controls.game.move.started   += OnMove;
            InputManager.Instance.Controls.game.move.performed += OnMove;
            InputManager.Instance.Controls.game.move.canceled  += OnMoveStop;

            InputManager.Instance.Controls.game.moveforward.started    += OnMoveForward;
            InputManager.Instance.Controls.game.moveforward.performed  += OnMoveForwardStop;
            InputManager.Instance.Controls.game.movebackward.started   += OnMoveBackward;
            InputManager.Instance.Controls.game.movebackward.performed += OnMoveBackwardStop;
            InputManager.Instance.Controls.game.moveleft.started       += OnMoveLeft;
            InputManager.Instance.Controls.game.moveleft.performed     += OnMoveLeftStop;
            InputManager.Instance.Controls.game.moveright.started      += OnMoveRight;
            InputManager.Instance.Controls.game.moveright.performed    += OnMoveRightStop;

            InputManager.Instance.Controls.game.look.started   += OnLook;
            InputManager.Instance.Controls.game.look.performed += OnLook;
            InputManager.Instance.Controls.game.look.canceled  += OnLookStop;

            InputManager.Instance.Controls.game.jump.started   += OnJumpStart;
            InputManager.Instance.Controls.game.jump.performed += OnJump;

            InputManager.Instance.Controls.game.hover.started   += OnHoverStart;
            InputManager.Instance.Controls.game.hover.performed += OnHover;

            InputManager.Instance.Controls.game.grab.performed += OnGrab;
            InputManager.Instance.Controls.game.drop.performed += OnDrop;

            InputManager.Instance.Controls.game.aim.started   += OnAimStart;
            InputManager.Instance.Controls.game.aim.performed += OnAim;

            InputManager.Instance.Controls.game.throwmail.started   += OnThrowMailStart;
            InputManager.Instance.Controls.game.throwmail.performed += OnThrowMail;

            InputManager.Instance.Controls.game.throwsnowball.started   += OnThrowSnowballStart;
            InputManager.Instance.Controls.game.throwsnowball.performed += OnThrowSnowball;

            InitDebugMenu();
        }
Exemplo n.º 8
0
        private void OnDestroy()
        {
            Destroy(_gamepadListener);
            _gamepadListener = null;

            DestroyDebugMenu();

            if (InputManager.HasInstance)
            {
                InputManager.Instance.Controls.game.pause.performed -= OnPause;

                InputManager.Instance.Controls.game.move.started   -= OnMove;
                InputManager.Instance.Controls.game.move.performed -= OnMove;
                InputManager.Instance.Controls.game.move.canceled  -= OnMoveStop;

                InputManager.Instance.Controls.game.moveforward.started    -= OnMoveForward;
                InputManager.Instance.Controls.game.moveforward.performed  -= OnMoveForwardStop;
                InputManager.Instance.Controls.game.movebackward.started   -= OnMoveBackward;
                InputManager.Instance.Controls.game.movebackward.performed -= OnMoveBackwardStop;
                InputManager.Instance.Controls.game.moveleft.started       -= OnMoveLeft;
                InputManager.Instance.Controls.game.moveleft.performed     -= OnMoveLeftStop;
                InputManager.Instance.Controls.game.moveright.started      -= OnMoveRight;
                InputManager.Instance.Controls.game.moveright.performed    -= OnMoveRightStop;

                InputManager.Instance.Controls.game.look.started   -= OnLook;
                InputManager.Instance.Controls.game.look.performed -= OnLook;
                InputManager.Instance.Controls.game.look.canceled  -= OnLookStop;

                InputManager.Instance.Controls.game.jump.started   -= OnJumpStart;
                InputManager.Instance.Controls.game.jump.performed -= OnJump;

                InputManager.Instance.Controls.game.hover.started   -= OnHoverStart;
                InputManager.Instance.Controls.game.hover.performed -= OnHover;

                InputManager.Instance.Controls.game.grab.performed -= OnGrab;
                InputManager.Instance.Controls.game.drop.performed -= OnDrop;

                InputManager.Instance.Controls.game.aim.started   -= OnAimStart;
                InputManager.Instance.Controls.game.aim.performed -= OnAim;

                InputManager.Instance.Controls.game.throwmail.started   -= OnThrowMailStart;
                InputManager.Instance.Controls.game.throwmail.performed -= OnThrowMail;

                InputManager.Instance.Controls.game.throwsnowball.started   -= OnThrowSnowballStart;
                InputManager.Instance.Controls.game.throwsnowball.performed -= OnThrowSnowball;
            }
        }
Exemplo n.º 9
0
 /// <summary>
 ///     Removes a Gamepad input handler only to this manager
 /// </summary>
 /// <param name="listener">The gamepad listener class</param>
 public void removeGamepadListener(GamepadListener listener)
 {
     gamepadListeners.Remove(listener);
 }
Exemplo n.º 10
0
 /// <summary>
 ///     Adds a Gamepad input handler only to this manager
 /// </summary>
 /// <param name="listener">The gamepad listener class</param>
 public void addGamepadListener(GamepadListener listener)
 {
     gamepadListeners.Add(listener);
 }
Exemplo n.º 11
0
 void Start()
 {
     gin = GetComponent <GamepadListener>();
 }