Exemple #1
0
    public override void DoFixedUpdate()
    {
        base.DoFixedUpdate();

        AbstractInputController p1InputController = UFE.GetPlayer1Controller();
        AbstractInputController p2InputController = UFE.GetPlayer2Controller();

        // Retrieve the values of the horizontal and vertical axis
        bool p1AxisDown =
            p1InputController.GetButtonDown(p1InputController.horizontalAxis) ||
            p1InputController.GetButtonDown(p1InputController.verticalAxis);

        bool p2AxisDown =
            p2InputController.GetButtonDown(p2InputController.horizontalAxis) ||
            p2InputController.GetButtonDown(p2InputController.verticalAxis);

        // Process the player input...
        if (UFE.gameMode != GameMode.StoryMode && !UFE.GetCPU(2))
        {
            // If we are in "Story Mode" or in "Player vs Player (versus mode)", the controller assigned to
            // the first player will be used always for selecting the character assigned to that player. If
            // that player has already selected a character, he can't move the cursor unless he deselects
            // the character first.
            if (p1AxisDown)
            {
                this.MoveCursor(p1InputController, 1);
            }

            if (p1InputController.GetButtonDown(UFE.config.inputOptions.confirmButton))
            {
                this.TrySelectCharacter(this.p1HoverIndex, 1);
            }
            else if (p1InputController.GetButtonDown(UFE.config.inputOptions.cancelButton))
            {
                this.TryDeselectCharacter(1);
            }

            // The controller assigned to the second player only can be used for selecting the character assigned to
            // the second player in "Player vs Player (versus mode)". In other game modes, the character assigned to
            // the second player will be chosen randomly (Story Mode) or will be selected by Player 1 (Player vs CPU).
            if (p2AxisDown)
            {
                this.MoveCursor(p2InputController, 2);
            }

            if (p2InputController.GetButtonDown(UFE.config.inputOptions.confirmButton))
            {
                this.TrySelectCharacter(this.p2HoverIndex, 2);
            }
            else if (p2InputController.GetButtonDown(UFE.config.inputOptions.cancelButton))
            {
                this.TryDeselectCharacter(2);
            }
        }
        else
        {
            // However, the character assigned to the second player will be chosen by the first player in other
            // game modes (for example: Player vs CPU).
            if (p1AxisDown)
            {
                this.MoveCursor(p1InputController);
            }

            if (p1InputController.GetButtonDown(UFE.config.inputOptions.confirmButton))
            {
                this.TrySelectCharacter();
            }
            else if (p1InputController.GetButtonDown(UFE.config.inputOptions.cancelButton))
            {
                this.TryDeselectCharacter();
            }
        }
    }
Exemple #2
0
    public override void DoFixedUpdate()
    {
        base.DoFixedUpdate();

        if (UFE.gameMode != GameMode.StoryMode && !UFE.GetCPU(2))
        {
            // If both characters will be controlled by human players...
            this.SpecialNavigationSystem(
                1
                ,
                new UFEScreenExtensions.MoveCursorCallback(
                    delegate(
                        float horizontalAxis,
                        float verticalAxis,
                        bool horizontalAxisDown,
                        bool verticalAxisDown,
                        bool confirmButtonDown,
                        bool cancelButtonDown,
                        AudioClip sound
                        ){
                this.MoveCursor(
                    1,
                    horizontalAxis,
                    verticalAxis,
                    horizontalAxisDown,
                    verticalAxisDown,
                    confirmButtonDown,
                    cancelButtonDown,
                    sound
                    );
            })
                ,
                new UFEScreenExtensions.ActionCallback(delegate(AudioClip sound){
                this.TrySelectCharacter(this.p1HoverIndex, 1);
            })
                ,
                new UFEScreenExtensions.ActionCallback(delegate(AudioClip sound){
                this.TryDeselectCharacter(1);
            })
                );

            this.SpecialNavigationSystem(
                2
                ,
                new UFEScreenExtensions.MoveCursorCallback(
                    delegate(
                        float horizontalAxis,
                        float verticalAxis,
                        bool horizontalAxisDown,
                        bool verticalAxisDown,
                        bool confirmButtonDown,
                        bool cancelButtonDown,
                        AudioClip sound
                        ){
                this.MoveCursor(
                    2,
                    horizontalAxis,
                    verticalAxis,
                    horizontalAxisDown,
                    verticalAxisDown,
                    confirmButtonDown,
                    cancelButtonDown,
                    sound
                    );
            })
                ,
                new UFEScreenExtensions.ActionCallback(delegate(AudioClip sound){
                this.TrySelectCharacter(this.p2HoverIndex, 2);
            })
                ,
                new UFEScreenExtensions.ActionCallback(delegate(AudioClip sound){
                this.TryDeselectCharacter(2);
            })
                );
        }
        else
        {
            // If at least one characters will be controlled by the CPU...
            this.SpecialNavigationSystem(
                1
                ,
                new UFEScreenExtensions.MoveCursorCallback(delegate(
                                                               float horizontalAxis,
                                                               float verticalAxis,
                                                               bool horizontalAxisDown,
                                                               bool verticalAxisDown,
                                                               bool confirmButtonDown,
                                                               bool cancelButtonDown,
                                                               AudioClip sound
                                                               ){
                this.MoveCursor(
                    UFE.config.player1Character == null ? 1 : 2,
                    horizontalAxis,
                    verticalAxis,
                    horizontalAxisDown,
                    verticalAxisDown,
                    confirmButtonDown,
                    cancelButtonDown,
                    sound
                    );
            })
                ,
                new UFEScreenExtensions.ActionCallback(this.TrySelectCharacter),
                new UFEScreenExtensions.ActionCallback(this.TryDeselectCharacter)
                );
        }
    }
 public void TryDeselectCharacter()
 {
     if (!UFE.isConnected)
     {
         // If it's a local game, update the corresponding character immediately...
         if (UFE.config.player2Character != null && UFE.gameMode != GameMode.StoryMode && !UFE.GetCPU(2))
         {
             this.TryDeselectCharacter(2);
         }
         else
         {
             this.TryDeselectCharacter(1);
         }
     }
     else
     {
         // If it's an online game, find out if the local player is Player1 or Player2
         // and update the selection only for the local player...
         this.TryDeselectCharacter(UFE.GetLocalPlayer());
     }
 }