private IEnumerator StartAttacking(BattleEnemySpot enemySpot) { GameEvents.OnSpeedRush?.Invoke(); var attackPosition = enemySpot.PlayerActionSpot.position; var speed = 4f; lockInputs = true; ThisAnim.SetFloat(BasicMovement, 1); float step = (speed / (transform.position - attackPosition).magnitude) * Time.fixedDeltaTime; float t = 0; while (t <= .3f) { t += step; transform.position = Vector3.Lerp(transform.position, attackPosition, t); if (t > .3f) { ThisAnim.SetFloat(BasicMovement, 0); } yield return(new WaitForFixedUpdate()); } transform.position = attackPosition; transform.position = attackPosition; ThisAnim.SetTrigger(Attack); AudioManager.AttackSFX(); yield return(new WaitForSeconds(.5f)); GameEvents.OnPlayerUseAttack?.Invoke(); yield return(new WaitForSeconds(1f)); GameEvents.OnPlayerCast?.Invoke(); ThisAnim.SetFloat(BasicMovement, 1); speed = 8f; t = 0; while (t <= .3f) { t += step; transform.position = Vector3.Lerp(transform.position, originalPlayerPosition, t); transform.eulerAngles = Vector3.Lerp(transform.eulerAngles, new Vector3(0, 180, 0), t * 5f); if (t > .3f) { ThisAnim.SetFloat(BasicMovement, 0); } yield return(new WaitForFixedUpdate()); } transform.position = originalPlayerPosition; speed = 10f; t = 0; while (t <= .2f) { t += step; transform.eulerAngles = Vector3.Lerp(transform.eulerAngles, new Vector3(0, 0, 0), t * 5f); yield return(new WaitForFixedUpdate()); } transform.eulerAngles = new Vector3(0, 0, 0); lockInputs = false; GameEvents.OnPlayerFinishCasting.Invoke(); GameManager.GetNextBattlePhase(); }
private IEnumerator StartCastingMagic(BattleEnemySpot enemySpot) { lockInputs = true; yield return(new WaitForSeconds(.5f)); AudioManager.AttackSFX(); GameEvents.OnPlayerUseMagic?.Invoke(); yield return(new WaitForSeconds(.5f)); lockInputs = false; GameEvents.OnPlayerFinishCasting.Invoke(); GameManager.GetNextBattlePhase(); }
private void MoveToAttackEnemy(BattleEnemySpot battleSpot) { if (actionMoveCoroutine != null) { StopCoroutine(actionMoveCoroutine); } switch (attackOption) { case AttackOptionSelected.Attack: actionMoveCoroutine = StartCoroutine(StartAttacking(battleSpot)); break; case AttackOptionSelected.Magic: actionMoveCoroutine = StartCoroutine(StartCastingMagic(battleSpot)); break; case AttackOptionSelected.Guard: actionMoveCoroutine = StartCoroutine(StartGuardPose(battleSpot)); break; } }
private IEnumerator StartGuardPose(BattleEnemySpot enemySpot) { GameEvents.OnPlayerReceiveDamage?.Invoke(1); GameEvents.OnUpdateUi?.Invoke(); lockInputs = true; yield return(new WaitForSeconds(.5f)); if (gameEnded) { yield break; } GameEvents.OnPlayerUseGuard?.Invoke(); onGuard = true; GuardEffect.SetActive(true); GuardSFX.Play(); yield return(new WaitForSeconds(.5f)); lockInputs = false; GameEvents.OnPlayerFinishCasting.Invoke(); GameManager.ResetBattlePhase(); //GameManager.GetNextBattlePhase(); }