コード例 #1
0
ファイル: EventHandler.cs プロジェクト: SimonUnge/FarmingGame
 //Movement Event Call For Publishers
 public static void CallMovementEvent(float inputX,
                                      float inputY,
                                      bool isWalking,
                                      bool isRunning,
                                      bool isIdle,
                                      bool isCarrying,
                                      ToolEffect toolEffect,
                                      bool isUsingToolRight,
                                      bool isUsingToolLeft,
                                      bool isUsingToolUp,
                                      bool isUsingToolDown,
                                      bool isLiftingToolRight,
                                      bool isLiftingToolLeft,
                                      bool isLiftingToolUp,
                                      bool isLiftingToolDown,
                                      bool isPickingRight,
                                      bool isPickingLeft,
                                      bool isPickingUp,
                                      bool isPickingDown,
                                      bool isSwingingToolRight,
                                      bool isSwingingToolLeft,
                                      bool isSwingingToolUp,
                                      bool isSwingingToolDown,
                                      bool idleUp,
                                      bool idleDown,
                                      bool idleLeft,
                                      bool idleRight)
 {
     if (MovementEvent != null)
     {
         MovementEvent(inputX,
                       inputY,
                       isWalking,
                       isRunning,
                       isIdle,
                       isCarrying,
                       toolEffect,
                       isUsingToolRight,
                       isUsingToolLeft,
                       isUsingToolUp,
                       isUsingToolDown,
                       isLiftingToolRight,
                       isLiftingToolLeft,
                       isLiftingToolUp,
                       isLiftingToolDown,
                       isPickingRight,
                       isPickingLeft,
                       isPickingUp,
                       isPickingDown,
                       isSwingingToolRight,
                       isSwingingToolLeft,
                       isSwingingToolUp,
                       isSwingingToolDown,
                       idleUp,
                       idleDown,
                       idleLeft,
                       idleRight);
     }
 }
コード例 #2
0
 private void ToggleRotationDirection(GameObject tool)
 {
     if (toolEffect == ToolEffect.losen)
     {
         toolEffect = ToolEffect.tighten;
     }
     else
     {
         toolEffect = ToolEffect.losen;
     }
 }
コード例 #3
0
 //MovementEvent call for publisher
 public static void callMovementEvent(float xInput, float yInput, bool isWalking, bool isRunning, bool isIdle,
                                      bool isCarrying, ToolEffect toolEffect,
                                      bool isUsingToolLeft, bool isUsingToolRight, bool isUsingToolDown, bool isUsingToolUp,
                                      bool isLiftingToolDown, bool isLiftingToolLeft, bool isLiftingToolRight, bool isLiftingToolUp,
                                      bool isPickingLeft, bool isPickingRight, bool isPickingUp, bool isPickingDown,
                                      bool isSwingingToolLeft, bool isSwingingToolRight, bool isSwingingToolUp, bool isSwingingToolDown,
                                      bool IdleLeft, bool IdleRight, bool IdleUP, bool IdleDown)
 {
     if (MovementEvent != null)
     {
         MovementEvent(xInput, yInput, isWalking, isRunning, isCarrying, isIdle, toolEffect, isUsingToolLeft, isUsingToolDown, isUsingToolRight, isUsingToolUp,
                       isLiftingToolDown, isLiftingToolLeft, isLiftingToolRight, isLiftingToolUp, isPickingLeft, isPickingRight, isPickingUp, isPickingDown,
                       isSwingingToolLeft, isSwingingToolRight, isSwingingToolUp, isSwingingToolDown,
                       IdleLeft, IdleRight, IdleUP, IdleDown);
     }
 }
コード例 #4
0
    private void SetAnimationParameters(float xInput, float yInput, bool isWalking, bool isRunning, bool isIdle, bool isCarrying, ToolEffect toolEffect,
                                        bool isUsingToolRight, bool isUsingToolLeft, bool isUsingToolUp, bool isUsingToolDown,
                                        bool isLiftingToolRight, bool isLiftingToolLeft, bool isLiftingToolUp, bool isLiftingToolDown,
                                        bool isPickingRight, bool isPickingLeft, bool isPickingUp, bool isPickingDown,
                                        bool isSwingingToolRight, bool isSwingingToolLeft, bool isSwingingToolUp, bool isSwingingToolDown,
                                        bool idleUp, bool idleDown, bool idleLeft, bool idleRight)
    {
        animator.SetFloat(Settings.xInput, xInput);
        animator.SetFloat(Settings.yInput, yInput);
        animator.SetBool(Settings.isWalking, isWalking);
        animator.SetBool(Settings.isRunning, isRunning);

        animator.SetInteger(Settings.toolEffect, (int)toolEffect);

        if (isUsingToolRight)
        {
            animator.SetTrigger(Settings.isUsingToolRight);
        }
        if (isUsingToolLeft)
        {
            animator.SetTrigger(Settings.isUsingToolLeft);
        }
        if (isUsingToolUp)
        {
            animator.SetTrigger(Settings.isUsingToolUp);
        }
        if (isUsingToolDown)
        {
            animator.SetTrigger(Settings.isUsingToolDown);
        }

        if (isLiftingToolRight)
        {
            animator.SetTrigger(Settings.isLiftingToolRight);
        }
        if (isLiftingToolLeft)
        {
            animator.SetTrigger(Settings.isLiftingToolLeft);
        }
        if (isLiftingToolUp)
        {
            animator.SetTrigger(Settings.isLiftingToolUp);
        }
        if (isLiftingToolDown)
        {
            animator.SetTrigger(Settings.isLiftingToolDown);
        }

        if (isSwingingToolRight)
        {
            animator.SetTrigger(Settings.isSwingingToolRight);
        }
        if (isSwingingToolLeft)
        {
            animator.SetTrigger(Settings.isSwingingToolLeft);
        }
        if (isSwingingToolUp)
        {
            animator.SetTrigger(Settings.isSwingingToolUp);
        }
        if (isSwingingToolDown)
        {
            animator.SetTrigger(Settings.isSwingingToolDown);
        }

        if (isPickingRight)
        {
            animator.SetTrigger(Settings.isPickingRight);
        }
        if (isPickingLeft)
        {
            animator.SetTrigger(Settings.isPickingLeft);
        }
        if (isPickingUp)
        {
            animator.SetTrigger(Settings.isPickingUp);
        }
        if (isPickingDown)
        {
            animator.SetTrigger(Settings.isPickingDown);
        }

        if (idleUp)
        {
            animator.SetTrigger(Settings.idleUp);
        }
        if (idleDown)
        {
            animator.SetTrigger(Settings.idleDown);
        }
        if (idleLeft)
        {
            animator.SetTrigger(Settings.idleLeft);
        }
        if (idleRight)
        {
            animator.SetTrigger(Settings.idleRight);
        }
    }
コード例 #5
0
    private void SetAnimationParameters(float inputX, float inputY, bool isWalking, bool isRunning, bool isIdle, bool isCarrying,
                                        ToolEffect toolEffect,
                                        bool isUsingToolRight, bool isUsingToolLeft, bool isUsingToolUp, bool isUsingToolDown,
                                        bool isLiftingToolRight, bool isLiftingToolLeft, bool isLiftingToolUp, bool isLiftingToolDown,
                                        bool isPickingRight, bool isPickingLeft, bool isPickingUp, bool isPickingDown,
                                        bool isSwingingToolRight, bool isSwingingToolLeft, bool isSwingingToolUp, bool isSwingingToolDown,
                                        bool idleRight, bool idleLeft, bool idleUp, bool idleDown)
    {
        // receiving values from movement event, then setting corresponding animator parameter using hash values
        animator.SetFloat(Settings.xInput, inputX);
        animator.SetFloat(Settings.yInput, inputY);
        animator.SetBool(Settings.isWalking, isWalking);
        animator.SetBool(Settings.isRunning, isRunning);

        animator.SetInteger(Settings.toolEffect, (int)toolEffect);

        if (isUsingToolRight)
        {
            animator.SetTrigger(Settings.isUsingToolRight);
        }
        if (isUsingToolLeft)
        {
            animator.SetTrigger(Settings.isUsingToolLeft);
        }
        if (isUsingToolUp)
        {
            animator.SetTrigger(Settings.isUsingToolUp);
        }
        if (isUsingToolDown)
        {
            animator.SetTrigger(Settings.isUsingToolDown);
        }

        if (isLiftingToolRight)
        {
            animator.SetTrigger(Settings.isLiftingToolRight);
        }
        if (isLiftingToolLeft)
        {
            animator.SetTrigger(Settings.isLiftingToolLeft);
        }
        if (isLiftingToolUp)
        {
            animator.SetTrigger(Settings.isLiftingToolUp);
        }
        if (isLiftingToolDown)
        {
            animator.SetTrigger(Settings.isLiftingToolDown);
        }

        if (isSwingingToolRight)
        {
            animator.SetTrigger(Settings.isSwingingToolRight);
        }
        if (isSwingingToolLeft)
        {
            animator.SetTrigger(Settings.isSwingingToolLeft);
        }
        if (isSwingingToolUp)
        {
            animator.SetTrigger(Settings.isSwingingToolUp);
        }
        if (isSwingingToolDown)
        {
            animator.SetTrigger(Settings.isSwingingToolDown);
        }

        if (isPickingRight)
        {
            animator.SetTrigger(Settings.isPickingRight);
        }
        if (isPickingLeft)
        {
            animator.SetTrigger(Settings.isPickingLeft);
        }
        if (isPickingUp)
        {
            animator.SetTrigger(Settings.isPickingUp);
        }
        if (isPickingDown)
        {
            animator.SetTrigger(Settings.isPickingDown);
        }

        if (idleUp)
        {
            animator.SetTrigger(Settings.idleUp);
        }
        if (idleDown)
        {
            animator.SetTrigger(Settings.idleDown);
        }
        if (idleLeft)
        {
            animator.SetTrigger(Settings.idleLeft);
        }
        if (idleRight)
        {
            animator.SetTrigger(Settings.idleRight);
        }
    }
コード例 #6
0
    // Because SetAnimationParameters is subscribed to the EventHandler.MovementEvent delegate, this method will get triggered everytime the
    // MovementEvent is triggered, and each of the below parameters will be set within the animator.
    private void SetAnimationParameters(float xInput, float yInput, bool isWalking, bool isRunning, bool isIdle, bool isCarrying, ToolEffect toolEffect,
                                        bool isUsingToolRight, bool isUsingToolLeft, bool isUsingToolUp, bool isUsingToolDown,
                                        bool isLiftingToolRight, bool isLiftingToolLeft, bool isLiftingToolUp, bool isLiftingToolDown,
                                        bool isPickingLeft, bool isPickingRight, bool isPickingUp, bool isPickingDown,
                                        bool isSwingingToolRight, bool isSwingingToolLeft, bool isSwingingToolUp, bool isSwingingToolDown,
                                        bool idleUp, bool idleDown, bool idleLeft, bool idleRight)
    {
        // Set all of the floats, bools, integers, and triggers within the animator based on the parameters received from the MovementEvent delegate
        animator.SetFloat(Settings.xInput, xInput);
        animator.SetFloat(Settings.yInput, yInput);
        animator.SetBool(Settings.isWalking, isWalking);
        animator.SetBool(Settings.isRunning, isRunning);

        animator.SetInteger(Settings.toolEffect, (int)toolEffect);

        if (isUsingToolRight)
        {
            animator.SetTrigger(Settings.isUsingToolRight);
        }
        if (isUsingToolLeft)
        {
            animator.SetTrigger(Settings.isUsingToolLeft);
        }
        if (isUsingToolUp)
        {
            animator.SetTrigger(Settings.isUsingToolUp);
        }
        if (isUsingToolDown)
        {
            animator.SetTrigger(Settings.isUsingToolDown);
        }

        if (isLiftingToolRight)
        {
            animator.SetTrigger(Settings.isLiftingToolRight);
        }
        if (isLiftingToolLeft)
        {
            animator.SetTrigger(Settings.isLiftingToolLeft);
        }
        if (isLiftingToolUp)
        {
            animator.SetTrigger(Settings.isLiftingToolUp);
        }
        if (isLiftingToolDown)
        {
            animator.SetTrigger(Settings.isLiftingToolDown);
        }

        if (isSwingingToolRight)
        {
            animator.SetTrigger(Settings.isSwingingToolRight);
        }
        if (isSwingingToolLeft)
        {
            animator.SetTrigger(Settings.isSwingingToolLeft);
        }
        if (isSwingingToolUp)
        {
            animator.SetTrigger(Settings.isSwingingToolUp);
        }
        if (isSwingingToolDown)
        {
            animator.SetTrigger(Settings.isSwingingToolDown);
        }

        if (isPickingRight)
        {
            animator.SetTrigger(Settings.isPickingRight);
        }
        if (isPickingLeft)
        {
            animator.SetTrigger(Settings.isPickingLeft);
        }
        if (isPickingUp)
        {
            animator.SetTrigger(Settings.isPickingUp);
        }
        if (isPickingDown)
        {
            animator.SetTrigger(Settings.isPickingDown);
        }

        if (idleRight)
        {
            animator.SetTrigger(Settings.idleRight);
        }
        if (idleLeft)
        {
            animator.SetTrigger(Settings.idleLeft);
        }
        if (idleUp)
        {
            animator.SetTrigger(Settings.idleUp);
        }
        if (idleDown)
        {
            animator.SetTrigger(Settings.idleDown);
        }
    }