// Update is called once per frame void Update() { switch (curState) { case PlayerState.PlayerInput: AttackInput(); // Check for player attacks break; case PlayerState.SwordAttack: currentAttackHitbox.attack(swordDamage, swordAttackStartTime); //swordAttack(currentAttackHitbox, swordAttackStartTime); break; case PlayerState.firingLazer: // deliberate fallthrough case PlayerState.chargingLazer: handleLazer(); break; } }
void AttackInput() { if (Input.GetKeyDown(KeyCode.LeftShift)) { isSprinting = true; } if (Input.GetKeyUp(KeyCode.LeftShift) || (curStamina < 1)) { isSprinting = false; } /* * //TODO remove this * if (Input.GetKeyDown(KeyCode.G)) { * knockBack(new Vector3(1, 0, 0)); * * }*/ // change to enum/switch if (Input.GetKeyDown(KeyCode.S)) // Phone bullet { if (hasPhoneLazer) { PhoneAttackAnimation(); curState = PlayerState.chargingLazer; lazerChargedAtTime = Time.time + lazerBeamChargeTime; } else if (hasPhoneBullet) { PhoneAttackAnimation(); waitForPhoneAnimationAndFire(PhonePower.Bullet); } } else if (Input.GetKeyDown(KeyCode.D) && hasPhoneStun) // Phone stun { waitForPhoneAnimationAndFire(PhonePower.Stun); } else if (Input.GetKeyDown(KeyCode.A) && hasSword) // Sword Attack { curState = PlayerState.SwordAttack; swordAttackStartTime = Time.time; switch (curDirection) { case FacingDirection.Up: currentAttackHitbox = upHitbox; curAnim.Play("swordUp"); break; case FacingDirection.Left: currentAttackHitbox = leftSideHitbox; curAnim.Play("swordLeft"); break; case FacingDirection.Down: currentAttackHitbox = downHitbox; curAnim.Play("swordDown"); break; case FacingDirection.Right: currentAttackHitbox = rightSideHitbox; curAnim.Play("swordRight"); break; } currentAttackHitbox.attack(swordDamage, swordAttackStartTime); //swordAttack(currentAttackHitbox, swordAttackStartTime); swordAudioChannel.Play(); curAnim.Resume(); StartCoroutine(waitForAnimationtoEnd()); } else if (Input.GetKeyDown(KeyCode.F)) // flashlight { flashLight.toggleOnOff(); } }
void AttackInput() { if (Input.GetKeyDown(KeyCode.LeftShift)) { isSprinting = true; } if (Input.GetKeyUp(KeyCode.LeftShift) || (curStamina < 1)) { isSprinting = false; } /* //TODO remove this if (Input.GetKeyDown(KeyCode.G)) { knockBack(new Vector3(1, 0, 0)); }*/ // change to enum/switch if(Input.GetKeyDown(KeyCode.S)){ // Phone bullet if (hasPhoneLazer) { PhoneAttackAnimation(); curState = PlayerState.chargingLazer; lazerChargedAtTime = Time.time + lazerBeamChargeTime; } else if (hasPhoneBullet) { PhoneAttackAnimation(); waitForPhoneAnimationAndFire(PhonePower.Bullet); } } else if (Input.GetKeyDown(KeyCode.D) && hasPhoneStun) { // Phone stun waitForPhoneAnimationAndFire(PhonePower.Stun); } else if(Input.GetKeyDown(KeyCode.A) && hasSword){ // Sword Attack curState = PlayerState.SwordAttack; swordAttackStartTime = Time.time; switch(curDirection) { case FacingDirection.Up: currentAttackHitbox = upHitbox; curAnim.Play("swordUp"); break; case FacingDirection.Left: currentAttackHitbox = leftSideHitbox; curAnim.Play("swordLeft"); break; case FacingDirection.Down: currentAttackHitbox = downHitbox; curAnim.Play("swordDown"); break; case FacingDirection.Right: currentAttackHitbox = rightSideHitbox; curAnim.Play("swordRight"); break; } currentAttackHitbox.attack(swordDamage, swordAttackStartTime); //swordAttack(currentAttackHitbox, swordAttackStartTime); swordAudioChannel.Play (); curAnim.Resume(); StartCoroutine(waitForAnimationtoEnd()); } else if (Input.GetKeyDown(KeyCode.F)) { // flashlight flashLight.toggleOnOff(); } }