private InputResponse CheckCommand(TrackCommand tc, ControlButton button) { if (tc.Type != button.Type) { FailedCommand(tc); return(InputResponse.TrackAndSwallow); } if (tc.Progress < this.EarlyGrace * 0.35f && tc.Progress > this.LateGrace * 0.35f) { Debug.Log("PERFECT HIT! " + tc.Progress); HitCommand(tc); } else if (tc.Progress < this.EarlyGrace && tc.Progress > this.LateGrace) { Debug.Log("Mistimed Hit " + tc.Progress); MistimedCommand(tc); } else { FailedCommand(tc); return(InputResponse.TrackAndSwallow); } return(InputResponse.None); }
private void CheckFailure(TrackCommand tc) { if (tc.Progress < this.LateGrace) { FailedCommand(tc); } }
public void Add(TrackCommand command) { command.GameObject.transform.parent = transform; command.Progress = 1.0f; this.TrackCommands.Add(command); SetCommandPosition(command, true); }
public TrackCommand GetNext() { if (this.CurrentCombo == null) { this.CurrentCombo = this.ComboManager.GetCombo(this.Level); } if (this.Index >= this.CurrentCombo.Length) { this.CurrentCombo = this.ComboManager.GetCombo(this.Level); this.Index = 0; } string nextLetter = this.CurrentCombo[this.Index].ToString(); this.Index++; Poolable poolable = this.Pool.Get(); TrackCommand tc = poolable.GetComponent <TrackCommand>(); tc.Reset(); tc.Init(TypeForLetter(nextLetter)); if (tc.Type == ControlButtonType.None) { poolable.Repool(); return(null); } return(tc); }
public TrackCommand GetRandomCommand() { Poolable poolable = this.Pool.Get(); TrackCommand tc = poolable.GetComponent <TrackCommand>(); tc.Reset(); tc.Init((ControlButtonType)Random.Range(0, 26)); return(tc); }
private void FailedCommand(TrackCommand command) { if (this.OnFail != null) { OnFail(this, command); } command.Fail(); PlaySound(true); this.TrackCommands.Remove(command); }
private void MissedCommand(TrackCommand command) { if (this.OnMiss != null) { OnMiss(this, command); } command.Miss(); PlaySound(true); this.TrackCommands.Remove(command); }
private void MistimedCommand(TrackCommand command) { if (this.OnMistimed != null) { OnMistimed(this, command); } command.MistimedHit(); PlaySound(false); this.TrackCommands.Remove(command); }
public void UpdateTrack(float dt) { for (int i = this.TrackCommands.Count - 1; i >= 0; i--) { TrackCommand tc = this.TrackCommands[i]; tc.UpdateTrackCommand(dt); SetCommandPosition(tc); CheckFailure(tc); } }
private void OnHit(Track track, TrackCommand trackCommand) { int dmg = 1; if (Mathf.Abs(trackCommand.Progress) < 0.01f) { dmg = 2; } this.CharacterManager.PlayerStrike(dmg); }
private void HitCommand(TrackCommand command) { if (this.OnHit != null) { OnHit(this, command); } command.Hit(); PlaySound(false); this.TrackCommands.Remove(command); }
public InputResponse OnButtonDown(ControlButton button) { Debug.Log(gameObject.name + " Button down: " + button.Type); if (this.IsUpperCase && !Input.GetKey(KeyCode.LeftShift)) { return(InputResponse.None); } else if (!this.IsUpperCase && Input.GetKey(KeyCode.LeftShift)) { return(InputResponse.None); } this.Bouncer.Bounce(); List <TrackCommand> eligibleCommands = new List <TrackCommand>(); for (int i = this.TrackCommands.Count - 1; i >= 0; i--) { TrackCommand tc = this.TrackCommands[i]; if (tc.Progress < this.Activatable) { eligibleCommands.Add(tc); } } TrackCommand nextCommand; nextCommand = null; float minProgress; minProgress = 1.0f; if (eligibleCommands.Count > 0) { foreach (TrackCommand command in eligibleCommands) { if (command.Progress < minProgress && command.Progress > this.LateGrace) { nextCommand = command; minProgress = nextCommand.Progress; } } } if (nextCommand != null) { return(CheckCommand(nextCommand, button)); } return(InputResponse.None); }
private void SpawnCommand() { TrackCommand nextCommand = this.CommandManager.GetNext(); if (nextCommand == null) { return; } bool uppcase = Random.Range(0, 10) < 3; if (uppcase) { this.TrackManager.Track1.Add(nextCommand); } else { this.TrackManager.Track2.Add(nextCommand); } }
private void SetCommandPosition(TrackCommand tc, bool immediate = false) { Vector2 targetPos; if (tc.Progress >= 0) { targetPos = Vector2.Lerp(this.TrackStart.position, this.TrackEnd.position, tc.Progress); } else { targetPos = Vector2.Lerp(this.TrackStart.position - (this.TrackEnd.position - this.TrackStart.position), this.TrackStart.position, tc.Progress + 1.0f); } if (immediate) { tc.Position = targetPos; } else { tc.Position += (targetPos - tc.Position) * 0.9f; } }
private void OnFail(Track track, TrackCommand trackCommand) { this.CharacterManager.EnemyStrike(); }