コード例 #1
0
ファイル: ComboHolder.cs プロジェクト: JonasLK/Thyme
    public void DirectionalInputCheck()
    {
        if (Input.GetAxis("Vertical") > 0.1)
        {
            directionalInput = DirectionalInput.forward;
        }

        else if (Input.GetAxis("Vertical") < -0.1)
        {
            directionalInput = DirectionalInput.back;
        }

        else if (Input.GetAxis("Horizontal") > 0.1)
        {
            directionalInput = DirectionalInput.right;
        }

        else if (Input.GetAxis("Horizontal") < -0.1)
        {
            directionalInput = DirectionalInput.left;
        }

        else
        {
            directionalInput = DirectionalInput.neutral;
        }
    }
コード例 #2
0
    /*!
     *      Activates if no special move has been activated. triggers an animation if a standard action is inputted (walking, crouching, standard attacks)
     */
    void PerformStandardAction(DirectionalInput _mostRecentInput)
    {
        if (_mostRecentInput.direction == Directions.LEFT || _mostRecentInput.direction == Directions.RIGHT)
        {
            ActivateAnimationParameter(WalkingParameter);
            DeactivateAnimationParameter(CrouchingParameter);
        }
        else if (_mostRecentInput.direction == Directions.LEFTDOWN || _mostRecentInput.direction == Directions.DOWN || _mostRecentInput.direction == Directions.RIGHTDOWN)
        {
            ActivateAnimationParameter(CrouchingParameter);
            DeactivateAnimationParameter(WalkingParameter);
        }
        else
        {
            DeactivateAnimationParameter(WalkingParameter);
            DeactivateAnimationParameter(CrouchingParameter);
        }

        if (_mostRecentInput.button != Buttons.NULL)
        {
            switch (_mostRecentInput.button)
            {
            case Buttons.LIGHTPUNCH:
            {
                ActivateAnimationParameter(LPunchParameter);
                break;
            }

            case Buttons.MEDIUMPUNCH:
            {
                ActivateAnimationParameter(MPunchParameter);
                break;
            }

            case Buttons.HEAVYPUNCH:
            {
                ActivateAnimationParameter(HPunchParameter);
                break;
            }

            case Buttons.LIGHTKICK:
            {
                ActivateAnimationParameter(LKickParameter);
                break;
            }

            case Buttons.MEDIUMKICK:
            {
                ActivateAnimationParameter(MKickParameter);
                break;
            }

            case Buttons.HEAVYKICK:
            {
                ActivateAnimationParameter(HKickParameter);
                break;
            }
            }
        }
    }
コード例 #3
0
    public void DirectionalInputCheck()
    {
        if (Input.GetAxis("Vertical") > 0)
        {
            directionalInput = DirectionalInput.forward;
        }

        if (Input.GetAxis("Vertical") < 0)
        {
            directionalInput = DirectionalInput.back;
        }

        if (Input.GetAxis("Horizontal") > 0)
        {
            directionalInput = DirectionalInput.right;
        }

        if (Input.GetAxis("Horizontal") < 0)
        {
            directionalInput = DirectionalInput.left;
        }

        if (Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") == 0)
        {
            directionalInput = DirectionalInput.neutral;
        }
    }
コード例 #4
0
 /*!
  * Checks the controller to see if any new inputs have occured. If they have they are added to the recent inputs list, if there is a new input, the joystickmoved event is called.
  */
 void Update()
 {
     DetermineButton();
     if (PlayerControllerNumber == PlayerNumber.P1)
     {
         DirectionalInput di = new DirectionalInput(DetermineDirection("HorizontalP1", "VerticalP1"), DetermineButton());
         if (IsNewDirection(di))
         {
             RecentInputs.Insert(0, di);
             if (RecentInputs.Count > 30)
             {
                 RecentInputs.RemoveAt(29);
             }
             JoystickMoved();
         }
     }
     else if (PlayerControllerNumber == PlayerNumber.P2)
     {
         DirectionalInput di = new DirectionalInput(DetermineDirection("HorizontalP2", "VerticalP2"), DetermineButton());
         if (IsNewDirection(di))
         {
             RecentInputs.Insert(0, di);
             if (RecentInputs.Count > 30)
             {
                 RecentInputs.RemoveAt(29);
             }
             JoystickMoved();
         }
     }
 }
コード例 #5
0
    /*!
     *  Determines if the inputted direction is a new one, and therefore if it should be added to the recent inputs list. Checks the new input against the last to see if anything has changed. Called in the update function
     *  \param _DirectionToCheck the new inpur from the controller.
     */
    bool IsNewDirection(DirectionalInput _DirectionToCheck)
    {
        if (PlayerControllerNumber == PlayerNumber.P1)
        {
            if (_DirectionToCheck.direction == Directions.NULL)
            {
                return(false);
            }

            if (RecentInputs.Count < 1)
            {
                return(true);
            }

            if (_DirectionToCheck.button != RecentInputs [0].button)
            {
                return(true);
            }

            if (_DirectionToCheck.direction != RecentInputs [0].direction)
            {
                return(true);
            }

            return(false);
        }

        else
        {
            if (_DirectionToCheck.direction == Directions.NULL)
            {
                return(false);
            }

            if (RecentInputs.Count < 1)
            {
                return(true);
            }

            if (_DirectionToCheck.button != RecentInputs [0].button)
            {
                return(true);
            }

            if (_DirectionToCheck.direction != RecentInputs [0].direction)
            {
                return(true);
            }

            return(false);
        }
    }
コード例 #6
0
ファイル: ComboHolder.cs プロジェクト: JonasLK/Thyme
    public void NewAttack(Slash slash, AttackInput attackInput, DirectionalInput directionalInput, bool aerial)
    {
        if (slash != null)
        {
            for (int i = 0; i < slash.combos.Count; i++)
            {
                if (attackInput == slash.combos[i].attackInput && directionalInput == slash.combos[i].directionalInput && slash.combos[i].aerialAttack == playerMovement.inAir)
                {
                    curSlash = slash.combos[i];

                    if (slash.combos[i].launchAttack)
                    {
                        nextSlash = slash.combos[i];
                    }
                    else
                    {
                        slash.combos[i].NewAttack(this, slash.combos[i]);
                    }
                    return;
                }
            }

            for (int o = 0; o < slash.combos.Count; o++)
            {
                if (attackInput == slash.combos[o].attackInput && slash.combos[o].directionalInput == DirectionalInput.none && slash.combos[o].aerialAttack == playerMovement.inAir)
                {
                    curSlash = slash.combos[o];

                    if (slash.combos[o].launchAttack)
                    {
                        nextSlash = slash.combos[o];
                    }
                    else
                    {
                        slash.combos[o].NewAttack(this, slash.combos[o]);
                    }
                    return;
                }
            }

            NewAttack(baseSlash, attackInput, directionalInput, inAir);
        }
    }
コード例 #7
0
    public void Initialize()
    {
        // Store Default Speed
        this.BaseSpeed = MoveSpeed;
        CanAttackAgain = true;
        PreventDamage  = false;

        // Instantiate New Objects
        if (this.GamePlayer == null)
        {
            GamePlayer = DataManager.LoadData(); this.transform.position = GamePlayer.SavedLocation;
        }
        Controls = new DirectionalInput();

        this.ThisAnimator = this.GetComponent <Animator>();
        this.Weapon       = GameObject.FindGameObjectWithTag("PlayerWeapon");

        // Try to get Rigidbody (2D/3D)
        RB2D = this.GetComponent <Rigidbody2D>();
        RB3D = this.GetComponent <Rigidbody>();
    }
コード例 #8
0
            public void Update(Vector2 newInput)
            {
                LastRawInput    = CurrentRawInput;
                CurrentRawInput = newInput;

                SmashFramesRemaining = Mathf.Max(0, SmashFramesRemaining - 1);

                var lastInput    = InputUtil.EnforceDeadZone(LastRawInput);
                var currentInput = InputUtil.EnforceDeadZone(CurrentRawInput);

                if (InputUtil.OutsideDeadZone(lastInput))
                {
                    SmashValue = Vector2.zero;
                    return;
                }

                var diff = currentInput - lastInput;

                diff = InputUtil.EnforceDeadZone(diff, InputConfig.SmashThreshold);
                diff = InputUtil.MaxComponent(diff);

                if (SmashFramesRemaining > 0)
                {
                    // Has recently smashed, needs to be in a different direction to change
                    var currentDirection = DirectionalInput.GetDirection(SmashValue);
                    var newDirection     = DirectionalInput.GetDirection(diff);
                    if (currentDirection != newDirection)
                    {
                        RefreshSmashValue(diff);
                    }
                }
                else if (!InputUtil.OutsideDeadZone(diff, InputConfig.SmashThreshold))
                {
                    SmashValue = Vector2.zero;
                }
                else
                {
                    RefreshSmashValue(diff);
                }
            }
コード例 #9
0
ファイル: PlayerInput.cs プロジェクト: micktu/ld40
 public void Init()
 {
     _playerCursor = new DirectionalInput();
 }
コード例 #10
0
 public virtual void ContinueAttack(ComboHolder combo, AttackInput attack, DirectionalInput dirInput, bool aerial)
 {
     combo.NewAttack(combo.curSlash, attack, dirInput, aerial);
 }
コード例 #11
0
    public virtual void ContinueAttack(ComboHolder combo, Slash slash, AttackInput attack, DirectionalInput directionalInput)
    {
        for (int i = 0; i < combos.Count; i++)
        {
            if (attack == combos[i].attackInput && directionalInput == combos[i].directionalInput)
            {
                NewAttack(combo, combos[i]);
                return;
            }
        }

        for (int o = 0; o < combos.Count; o++)
        {
            if (attack == combos[o].attackInput && combos[o].directionalInput == DirectionalInput.none)
            {
                NewAttack(combo, combos[o]);
                return;
            }
        }

        NewAttack(combo, slash);
    }