//input event private void InputEvent(INPUTACTION action) { if (action == INPUTACTION.PUNCH || action == INPUTACTION.KICK) { RestartLevel(); } }
public static void CombatInputEvent(INPUTACTION action) { if (onCombatInputEvent != null) { onCombatInputEvent(action); } }
private void InputEvent2(INPUTACTION action) { if (action == INPUTACTION.DEFEND) { ResumeGame(); } }
//input event private void InputEvent(INPUTACTION action) { if (action == INPUTACTION.JUMP) { LoadMainMenu(); } }
private void DoAttack(DamageObject d, UNITSTATE state, INPUTACTION inputAction, bool returnIdle) { animator.SetAnimatorTrigger(d.animTrigger); playerState.SetState(state); lastAttack = d; lastAttack.inflictor = gameObject; lastAttackTime = Time.time; lastAttackDirection = currentDirection; TurnToDir(currentDirection); }
public IEnumerator DumpsterDash(INPUTACTION givenKey) { if (dashCounter == 0) { Debug.Log("Dumpster Dash - 0"); dashCounter = 1; dashKey = givenKey; yield return(new WaitForSeconds(.2f)); if (dashCounter == 1) //after a breif period if key isn't pressed again it resets { dashCounter = 0; } } else if (dashCounter == 1) { Debug.Log("Dumpster Dash - 1"); if (givenKey == dashKey) { //-------------Dash-----------------// dashCounter = 2; Debug.Log("Dumpster Dash - 2"); gameObject.GetComponent <EightWayMovement>().enabled = false; // I know we dont wanna do stuff like this, just felt like for this instance it was more appropriate doing this than creating a gamestate...? ObjectPool.Instance.GetPooledObject("effect_enemyLand", new Vector2(gameObject.transform.position.x, gameObject.transform.position.y - 1)); if (dashKey == INPUTACTION.MOVELEFT) { gameObject.GetComponent <Rigidbody2D>().AddForce(new Vector2(-30f, 0f), ForceMode2D.Impulse); } else if (dashKey == INPUTACTION.MOVERIGHT) { gameObject.GetComponent <Rigidbody2D>().AddForce(new Vector2(30f, 0f), ForceMode2D.Impulse); } else if (dashKey == INPUTACTION.MOVEDOWN) { gameObject.GetComponent <Rigidbody2D>().AddForce(new Vector2(0f, -30f), ForceMode2D.Impulse); } else if (dashKey == INPUTACTION.MOVEUP) { gameObject.GetComponent <Rigidbody2D>().AddForce(new Vector2(0f, 30f), ForceMode2D.Impulse); } SoundManager.instance.PlaySingle(SFXBANK.DUMPSTERDASH); yield return(new WaitForSeconds(.1f)); dashCounter = 0; gameObject.GetComponent <Rigidbody2D>().velocity = Vector2.zero; gameObject.GetComponent <EightWayMovement>().enabled = true; } else { dashCounter = 0; //reset if press different direction } } }
/// <summary> /// 战斗输入事件 /// </summary> /// <param name="action"></param> private void CombatInputEvent(INPUTACTION action) { animator.ResetTrigger(); //if(lastAttack!=null) //{ // if(Time.time < (lastAttackTime + lastAttack.duration)) // return; //} if (action == INPUTACTION.SKILL1 && isGrounded) { DoAttack(skill1Data, UNITSTATE.SKILL1, INPUTACTION.SKILL1); } if (action == INPUTACTION.SKILL2 && isGrounded) { DoAttack(skill2Data, UNITSTATE.SKILL2, INPUTACTION.SKILL2); } if (action == INPUTACTION.CHARGE_START && isGrounded) { DoAttack(chargeStartData, UNITSTATE.CHARGE_START, INPUTACTION.CHARGE_START, false); } if (action == INPUTACTION.CHARGE_RELEASE && isGrounded) { DoAttack(chargeReleaseData, UNITSTATE.CHARGE_RELEASE, INPUTACTION.CHARGE_RELEASE); } //普攻 if (action == INPUTACTION.GENERALATTACK && playerState.currentState != UNITSTATE.GENERALATTACK && 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 && !continueGeneralAttackCombo && attackNum < generalAttackCombo.Length - 1) { attackNum += 1; } else { attackNum = 0; } if (generalAttackCombo[attackNum] != null && generalAttackCombo[attackNum].animTrigger.Length > 0) { DoAttack(generalAttackCombo[attackNum], UNITSTATE.GENERALATTACK, INPUTACTION.GENERALATTACK); } return; } //如果在一次普攻动作进行中又按下了普攻键,则进行普攻连击 if (action == INPUTACTION.GENERALATTACK && (playerState.currentState == UNITSTATE.GENERALATTACK) && Time.time > (lastAttackTime + lastAttack.duration - 0.1f) && !continueGeneralAttackCombo && isGrounded) { if (attackNum < generalAttackCombo.Length - 1) { continueGeneralAttackCombo = true; return; } } }
//input actions void InputEventAction(INPUTACTION action) { //ignore input when we are dead or when this state is not active if (!MovementStates.Contains(playerState.currentState) || isDead) { return; } //start a jump if (action == INPUTACTION.JUMP && IsGrounded() && playerState.currentState != UNITSTATE.JUMPING) { JumpNextFixedUpdate = true; } }
/// <summary> /// 战斗的输入事件 /// </summary> /// <param name="combatAction">输入的战斗状态</param> private void CombatInputEvent(INPUTACTION combatAction) { if (MovementStates.Contains(playerState.currentState) && !isDead) { if (combatAction == INPUTACTION.JUMP) { if (playerState.currentState != PLAYERSTATE.JUMPING && IsGrounded()) { StopAllCoroutines(); StartCoroutine(DoJump()); } } } }
private void InputEventAction(INPUTACTION action) { if (MovementStates.Contains(playerState.currentState)) { if (action == INPUTACTION.JUMP) { if (playerState.currentState != UNITSTATE.JUMPING && IsGrounded()) { StopAllCoroutines(); StartCoroutine(DoJump()); } } } }
public IEnumerator SpinAttack(INPUTACTION givenKey) //called at Swing() in 'MeleeAttack.cs' { gameObject.GetComponent <Rigidbody2D>().velocity = Vector2.zero; heldKey = givenKey; chargingSpin = true; yield return(new WaitForSeconds(.3f)); spinAttack.SetActive(true); chargingSpin = false; yield return(new WaitForSeconds(.5f)); gameObject.GetComponent <MeleeAttack>().cantAttack = false; gameObject.GetComponent <MeleeAttack>().ReturnFromSwing(); spinAttack.SetActive(false); }
private void DoAttack(DamageObject damage, PLAYERSTATE state, INPUTACTION inputAction) { playerAnimator.SetAnimatorTrigger(damage.animTrigger); playerState.SetState(state); lastAttack = damage; lastAttack.inflictor = gameObject; lastAttackTime = Time.time; lastAttackInput = inputAction; lastAttackDirection = currentDirection; TurnToDir(currentDirection); SetVelocity(Vector3.zero); if (state == PLAYERSTATE.JUMPKICK) { return; } Invoke("Ready", damage.duration); }
private void doAttack(DamageObject d, UNITSTATE state, INPUTACTION inputAction) { animator.SetAnimatorTrigger(d.animTrigger); playerState.SetState(state); lastAttack = d; lastAttack.inflictor = gameObject; lastAttackTime = Time.time; lastAttackInput = inputAction; lastAttackDirection = currentDirection; TurnToDir(currentDirection); if (isGrounded) { SetVelocity(Vector3.zero); } if (state == UNITSTATE.JUMPKICK) { return; } Invoke("Ready", d.duration); }
//use the currently equipped weapon void useCurrentWeapon() { playerState.SetState(UNITSTATE.USEWEAPON); TurnToDir(currentDirection); SetVelocity(Vector3.zero); lastAttackInput = INPUTACTION.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)); } }
// Functions for retrieving button states. public bool GetKey(INPUTACTION action) { return(currentInputs[action].isPressed); }
public float GetAxis(INPUTACTION action) { return(currentInputs[action].rawAxis); }
//combat input event private void CombatInputEvent(INPUTACTION action) { if (AttackStates.Contains(playerState.currentState) && !isDead) { //pick up an item if (action == INPUTACTION.PUNCH && itemInRange != null && isGrounded && currentWeapon == null) { interactWithItem(); return; } //use an weapon if (action == INPUTACTION.PUNCH && isGrounded && currentWeapon != null) { useCurrentWeapon(); return; } //ground punch if (action == INPUTACTION.PUNCH && (playerState.currentState != UNITSTATE.PUNCH && NearbyEnemyDown()) && isGrounded) { if (GroundPunchData.animTrigger.Length > 0) { doAttack(GroundPunchData, UNITSTATE.GROUNDPUNCH, INPUTACTION.PUNCH); } return; } //reset combo when switching to another combo chain (user setting) if (resetComboChainOnChangeCombo && (action != lastAttackInput)) { attackNum = -1; } //default punch if (action == INPUTACTION.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.PUNCH); } return; } //advance the punch combo if "punch" was pressed during a punch attack if (action == INPUTACTION.PUNCH && (playerState.currentState == UNITSTATE.PUNCH) && !continuePunchCombo && isGrounded) { if (attackNum < PunchCombo.Length - 1) { continuePunchCombo = true; continueKickCombo = false; return; } } //jump punch if (action == INPUTACTION.PUNCH && !isGrounded) { if (JumpKickData.animTrigger.Length > 0) { doAttack(JumpKickData, UNITSTATE.JUMPKICK, INPUTACTION.KICK); StartCoroutine(JumpKickInProgress()); } return; } //jump kick if (action == INPUTACTION.KICK && !isGrounded) { if (JumpKickData.animTrigger.Length > 0) { doAttack(JumpKickData, UNITSTATE.JUMPKICK, INPUTACTION.KICK); StartCoroutine(JumpKickInProgress()); } return; } //ground kick if (action == INPUTACTION.KICK && (playerState.currentState != UNITSTATE.KICK && NearbyEnemyDown()) && isGrounded) { if (GroundKickData.animTrigger.Length > 0) { doAttack(GroundKickData, UNITSTATE.GROUNDKICK, INPUTACTION.KICK); } return; } //default kick if (action == INPUTACTION.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.KICK); return; } //advance the kick combo if "kick" was pressed during a kick attack if (action == INPUTACTION.KICK && (playerState.currentState == UNITSTATE.KICK) && !continueKickCombo && isGrounded) { if (attackNum < KickCombo.Length - 1) { continueKickCombo = true; continuePunchCombo = false; return; } } } }
public bool GetKeyDown(INPUTACTION action) { return(currentInputs[action].isPressed && !previousInputs[action].isPressed); }
public bool GetKeyUp(INPUTACTION action) { return(!currentInputs[action].isPressed && previousInputs[action].isPressed); }
private void CombatInputEvent(INPUTACTION action) { OnContinueButtonClick(); }
/// <summary> /// 攻击事件 /// </summary> /// <param name="action"></param> private void CombatInputEvent(INPUTACTION action) { if (AttackStates.Contains(playerState.currentState) && !isDead) { //默认拳击 if (action == INPUTACTION.PUNCH && playerState.currentState != PLAYERSTATE.PUNCH && playerState.currentState != PLAYERSTATE.KICK && isGrounded) { //如果时间在组合窗口内,则继续进行下一次攻击 bool insideComboWindow = (lastAttack != null && (Time.time < (lastAttackTime + lastAttack.duration + lastAttack.comboResetTime))); if (insideComboWindow && !continuePunchCombo && (attackNum < KickCombo.Length - 1)) { attackNum += 1; } else { attackNum = 0; } if (PunchCombo[attackNum] != null && PunchCombo[attackNum].animTrigger.Length > 0) { DoAttack(PunchCombo[attackNum], PLAYERSTATE.PUNCH, INPUTACTION.PUNCH); } } //默认脚踢 if (action == INPUTACTION.KICK && playerState.currentState != PLAYERSTATE.KICK && playerState.currentState != PLAYERSTATE.PUNCH && isGrounded) { 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], PLAYERSTATE.KICK, INPUTACTION.KICK); return; } //跳踢 if (action == INPUTACTION.KICK && !isGrounded) { if (JumpKickData.animTrigger.Length > 0) { DoAttack(JumpKickData, PLAYERSTATE.JUMPKICK, INPUTACTION.KICK); StartCoroutine(JumpKickInProgress()); } return; } //捡起物品 if (action == INPUTACTION.PUNCH && itemInRange != null && isGrounded && currentWeapon == null) { InteractWithItem(); return; } //使用武器 if (action == INPUTACTION.PUNCH && isGrounded && currentWeapon != null) { UseCurrentWeapon(); return; } //如果在拳头攻击中已按下,则进行组合打击 if (action == INPUTACTION.PUNCH && (playerState.currentState == PLAYERSTATE.PUNCH) && !continuePunchCombo && isGrounded) { if (attackNum < PunchCombo.Length - 1) { continuePunchCombo = true; continueKickCombo = false; return; } } //如果在脚踢攻击中已按下,则进行组合打击 if (action == INPUTACTION.KICK && (playerState.currentState == PLAYERSTATE.KICK) && !continueKickCombo && isGrounded) { if (attackNum < KickCombo.Length - 1) { continueKickCombo = true; continuePunchCombo = false; return; } } //敌人倒地地面拳击 if (action == INPUTACTION.PUNCH && (playerState.currentState != PLAYERSTATE.PUNCH && NearbyEnemyDown()) && isGrounded) { if (GroundPunchData.animTrigger.Length > 0) { DoAttack(GroundPunchData, PLAYERSTATE.GROUNDPUNCH, INPUTACTION.PUNCH); } return; } //敌人倒地地面脚踢 if (action == INPUTACTION.KICK && (playerState.currentState != PLAYERSTATE.KICK && NearbyEnemyDown()) && isGrounded) { if (GroundKickData.animTrigger.Length > 0) { DoAttack(GroundKickData, PLAYERSTATE.GROUNDKICK, INPUTACTION.KICK); } return; } //切换到另一个组合链时重置组合(用户设置) if (resetComboChainOnChangeCombo && (action != lastAttackInput)) { attackNum = -1; } } }