Пример #1
0
        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);
        }
Пример #2
0
 private void CheckFailure(TrackCommand tc)
 {
     if (tc.Progress < this.LateGrace)
     {
         FailedCommand(tc);
     }
 }
Пример #3
0
 public void Add(TrackCommand command)
 {
     command.GameObject.transform.parent = transform;
     command.Progress = 1.0f;
     this.TrackCommands.Add(command);
     SetCommandPosition(command, true);
 }
Пример #4
0
        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);
        }
Пример #5
0
        public TrackCommand GetRandomCommand()
        {
            Poolable     poolable = this.Pool.Get();
            TrackCommand tc       = poolable.GetComponent <TrackCommand>();

            tc.Reset();
            tc.Init((ControlButtonType)Random.Range(0, 26));
            return(tc);
        }
Пример #6
0
 private void FailedCommand(TrackCommand command)
 {
     if (this.OnFail != null)
     {
         OnFail(this, command);
     }
     command.Fail();
     PlaySound(true);
     this.TrackCommands.Remove(command);
 }
Пример #7
0
 private void MissedCommand(TrackCommand command)
 {
     if (this.OnMiss != null)
     {
         OnMiss(this, command);
     }
     command.Miss();
     PlaySound(true);
     this.TrackCommands.Remove(command);
 }
Пример #8
0
 private void MistimedCommand(TrackCommand command)
 {
     if (this.OnMistimed != null)
     {
         OnMistimed(this, command);
     }
     command.MistimedHit();
     PlaySound(false);
     this.TrackCommands.Remove(command);
 }
Пример #9
0
 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);
     }
 }
Пример #10
0
        private void OnHit(Track track, TrackCommand trackCommand)
        {
            int dmg = 1;

            if (Mathf.Abs(trackCommand.Progress) < 0.01f)
            {
                dmg = 2;
            }
            this.CharacterManager.PlayerStrike(dmg);
        }
Пример #11
0
        private void HitCommand(TrackCommand command)
        {
            if (this.OnHit != null)
            {
                OnHit(this, command);
            }

            command.Hit();
            PlaySound(false);
            this.TrackCommands.Remove(command);
        }
Пример #12
0
        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);
        }
Пример #13
0
        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);
            }
        }
Пример #14
0
        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;
            }
        }
Пример #15
0
 private void OnFail(Track track, TrackCommand trackCommand)
 {
     this.CharacterManager.EnemyStrike();
 }