//checks if success is successful - id denotes which attack is being tried to defend against public bool CheckPattern(float delay, InputManager.attackType atk, out int id) { InputManager.attackType patAtk; id = beat.counter; Debug.Log("index: " + id); if (pattern.TryGetValue(id, out patAtk)) { Debug.Log("Type matching: " + (atk == patAtk)); Debug.Log("Delay %: " + delay / maxTime); return((Mathf.Abs(delay / maxTime) <= TimingParameters.threshold) && atk == patAtk); } return(false); }
public float GetDefense(InputManager.attackType type) { switch (type) { case InputManager.attackType.magic: return(mDef); case InputManager.attackType.melee: return(def); default: return(0); } }
public float GetAttack(InputManager.attackType type) { switch (type) { case InputManager.attackType.magic: return(mAtk); case InputManager.attackType.melee: return(atk); default: return(0); } }
public void PlayerDefense(InputManager.attackType type) { switch (type) { case InputManager.attackType.magic: PlayerMagicShield(); break; case InputManager.attackType.melee: PlayerMeleeShield(); break; default: break; } }
public void PlayerAttack(InputManager.attackType type) { switch (type) { case InputManager.attackType.magic: PlayerExplosion(); break; case InputManager.attackType.melee: PlayerSlash(); break; default: break; } }
public void EnemyAttack(InputManager.attackType type) { switch (type) { case InputManager.attackType.magic: EnemyExplosion(); break; case InputManager.attackType.melee: EnemySlash(); break; default: break; } }
public void AttackSfx(InputManager.attackType type) { AudioClip clip = null; switch (type) { case InputManager.attackType.magic: clip = explosionSfx; break; case InputManager.attackType.melee: clip = slashSfx; break; default: break; } sfxSource.clip = clip; sfxSource.Play(); }
public void Spawn(InputManager.attackType type) { if (!active) { return; } GameObject atk = null; switch (type) { case InputManager.attackType.magic: atk = magic; break; case InputManager.attackType.melee: atk = melee; break; default: break; } attacks.Add(Instantiate(atk, ball.transform.position, Quaternion.identity, transform)); }
public void EnemyAction(InputManager.attackType type) { AnM.EnemyAttack(type); }
public void HandleAction(float delay, InputManager.attackType type) { if (!isAttacking && !isDefending && !TM.calibrationFlag) { return; } IV.Spawn(type); //Handle Attack if (isAttacking) { switch (atkStyle) { case attackStyle.pattern: int index; if (TM.CheckPattern(delay, type, out index)) { Debug.Log("Attack successful!"); AnM.PlayerAttack(type); currentPattern.MatchPattern(index); } else { AnM.PlayerTrip(); IV.Disable(); isAttacking = false; } break; case attackStyle.free: default: if (TM.CheckFree(delay)) { Debug.Log("Successful Attack!"); AnM.PlayerAttack(type); float dmg = Mathf.Max(player.GetAttack(type) - enemy.GetDefense(type), 1); enemy.TakeDamage(dmg); } else { AnM.PlayerTrip(); IV.Disable(); isAttacking = false; } break; } } //Handle Defense if (isDefending) { if (!matchingEnabled) { return; } int index; AnM.PlayerDefense(type); if (TM.CheckPattern(delay, type, out index)) { Debug.Log("Block successful!"); currentPattern.MatchPattern(index); } else { StartCoroutine(DisableMatching()); } } }