コード例 #1
0
 public static void CombatInputEvent(INPUTACTION_2 action)
 {
     if (onCombatInputEvent != null)
     {
         onCombatInputEvent(action);
     }
 }
コード例 #2
0
 //input actions
 void InputEventAction(INPUTACTION_2 action)
 {
     //jump
     if (MovementStates.Contains(playerState.currentState) && !isDead)
     {
         if (action == INPUTACTION_2.JUMP)
         {
             if (playerState.currentState != UNITSTATE.JUMPING && IsGrounded())
             {
                 StopAllCoroutines();
                 StartCoroutine(doJump());
             }
         }
     }
 }
コード例 #3
0
 private void doAttack(DamageObject d, UNITSTATE state, INPUTACTION_2 inputAction)
 {
     animator.SetAnimatorTrigger(d.animTrigger);
     playerState.SetState(state);
     lastAttack           = d;
     lastAttack.inflictor = gameObject;
     lastAttackTime       = Time.time;
     lastAttackInput      = inputAction;
     lastAttackDirection  = currentDirection;
     TurnToDir(currentDirection);
     SetVelocity(Vector3.zero);
     if (state == UNITSTATE.JUMPKICK)
     {
         return;
     }
     if (state == UNITSTATE.JUMPPUNCH)
     {
         return;                               //LETHAL FORCES - adding Jump Punch
     }
     Invoke("Ready", d.duration);
 }
コード例 #4
0
    //use the currently equipped weapon
    void useCurrentWeapon()
    {
        playerState.SetState(UNITSTATE.USEWEAPON);
        TurnToDir(currentDirection);
        SetVelocity(Vector3.zero);

        lastAttackInput      = INPUTACTION_2.WEAPONATTACK;
        lastAttackTime       = Time.time;
        lastAttack           = currentWeapon.damageObject;
        lastAttack.inflictor = gameObject;
        lastAttackDirection  = currentDirection;

        if (!string.IsNullOrEmpty(currentWeapon.damageObject.animTrigger))
        {
            animator.SetAnimatorTrigger(currentWeapon.damageObject.animTrigger);
        }
        if (!string.IsNullOrEmpty(currentWeapon.useSound))
        {
            GlobalAudioPlayer.PlaySFX(currentWeapon.useSound);
        }
        Invoke("Ready", currentWeapon.damageObject.duration);
        if (currentWeapon.degenerateType == DEGENERATETYPE.DEGENERATEONUSE)
        {
            currentWeapon.useWeapon();
        }

        //on last use
        if (currentWeapon.degenerateType == DEGENERATETYPE.DEGENERATEONUSE && currentWeapon.timesToUse == 0)
        {
            StartCoroutine(destroyCurrentWeapon(currentWeapon.damageObject.duration));
        }
        if (currentWeapon.degenerateType == DEGENERATETYPE.DEGENERATEONHIT && currentWeapon.timesToUse == 1)
        {
            StartCoroutine(destroyCurrentWeapon(currentWeapon.damageObject.duration));
        }
    }
コード例 #5
0
    //combat input event
    private void CombatInputEvent(INPUTACTION_2 action)
    {
        if (AttackStates.Contains(playerState.currentState) && !isDead)
        {
            //pick up an item
            if (action == INPUTACTION_2.PUNCH && itemInRange != null && isGrounded && currentWeapon == null)
            {
                interactWithItem();
                return;
            }

            //use an weapon
            if (action == INPUTACTION_2.PUNCH && isGrounded && currentWeapon != null)
            {
                useCurrentWeapon();
                return;
            }

            //ground punch
            if (action == INPUTACTION_2.PUNCH && (playerState.currentState != UNITSTATE.PUNCH && NearbyEnemyDown()) && isGrounded)
            {
                if (GroundPunchData.animTrigger.Length > 0)
                {
                    doAttack(GroundPunchData, UNITSTATE.GROUNDPUNCH, INPUTACTION_2.PUNCH);
                }
                return;
            }

            //reset combo when switching to another combo chain (user setting)
            if (resetComboChainOnChangeCombo && (action != lastAttackInput))
            {
                attackNum = -1;
            }

            //default punch
            if (action == INPUTACTION_2.PUNCH && playerState.currentState != UNITSTATE.PUNCH && playerState.currentState != UNITSTATE.KICK && isGrounded)
            {
                //continue to the next attack if the time is inside the combo window
                bool insideComboWindow = (lastAttack != null && (Time.time < (lastAttackTime + lastAttack.duration + lastAttack.comboResetTime)));
                if (insideComboWindow && !continuePunchCombo && (attackNum < PunchCombo.Length - 1))
                {
                    attackNum += 1;
                }
                else
                {
                    attackNum = 0;
                }

                if (PunchCombo[attackNum] != null && PunchCombo[attackNum].animTrigger.Length > 0)
                {
                    doAttack(PunchCombo[attackNum], UNITSTATE.PUNCH, INPUTACTION_2.PUNCH);
                }
                return;
            }

            //advance the punch combo if "punch" was pressed during a punch attack
            if (action == INPUTACTION_2.PUNCH && (playerState.currentState == UNITSTATE.PUNCH) && !continuePunchCombo && isGrounded)
            {
                if (attackNum < PunchCombo.Length - 1)
                {
                    continuePunchCombo = true;
                    continueKickCombo  = false;
                    return;
                }
            }

            //jump punch - LETHAL FORCES
            if (action == INPUTACTION_2.PUNCH && !isGrounded)
            {
                if (JumpPunchData.animTrigger.Length > 0)
                {
                    doAttack(JumpPunchData, UNITSTATE.JUMPPUNCH, INPUTACTION_2.PUNCH);
                    StartCoroutine(JumpPunchInProgress());
                }
                return;
            }

            //jump kick
            if (action == INPUTACTION_2.KICK && !isGrounded)
            {
                if (JumpKickData.animTrigger.Length > 0)
                {
                    doAttack(JumpKickData, UNITSTATE.JUMPKICK, INPUTACTION_2.KICK);
                    StartCoroutine(JumpKickInProgress());
                }
                return;
            }

            //ground kick
            if (action == INPUTACTION_2.KICK && (playerState.currentState != UNITSTATE.KICK && NearbyEnemyDown()) && isGrounded)
            {
                if (GroundKickData.animTrigger.Length > 0)
                {
                    doAttack(GroundKickData, UNITSTATE.GROUNDKICK, INPUTACTION_2.KICK);
                }
                return;
            }

            //default kick
            if (action == INPUTACTION_2.KICK && playerState.currentState != UNITSTATE.KICK && playerState.currentState != UNITSTATE.PUNCH && isGrounded)
            {
                //continue to the next attack if the time is inside the combo window
                bool insideComboWindow = (lastAttack != null && (Time.time < (lastAttackTime + lastAttack.duration + lastAttack.comboResetTime)));
                if (insideComboWindow && !continueKickCombo && (attackNum < KickCombo.Length - 1))
                {
                    attackNum += 1;
                }
                else
                {
                    attackNum = 0;
                }

                doAttack(KickCombo[attackNum], UNITSTATE.KICK, INPUTACTION_2.KICK);
                return;
            }

            //advance the kick combo if "kick" was pressed during a kick attack
            if (action == INPUTACTION_2.KICK && (playerState.currentState == UNITSTATE.KICK) && !continueKickCombo && isGrounded)
            {
                if (attackNum < KickCombo.Length - 1)
                {
                    continueKickCombo  = true;
                    continuePunchCombo = false;
                    return;
                }
            }
        }
    }