示例#1
0
文件: Track.cs 项目: niksg/LDJam41
        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
文件: Track.cs 项目: niksg/LDJam41
 private void CheckFailure(TrackCommand tc)
 {
     if (tc.Progress < this.LateGrace)
     {
         FailedCommand(tc);
     }
 }
示例#3
0
文件: Track.cs 项目: niksg/LDJam41
 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
文件: Track.cs 项目: niksg/LDJam41
 private void FailedCommand(TrackCommand command)
 {
     if (this.OnFail != null)
     {
         OnFail(this, command);
     }
     command.Fail();
     PlaySound(true);
     this.TrackCommands.Remove(command);
 }
示例#7
0
文件: Track.cs 项目: niksg/LDJam41
 private void MissedCommand(TrackCommand command)
 {
     if (this.OnMiss != null)
     {
         OnMiss(this, command);
     }
     command.Miss();
     PlaySound(true);
     this.TrackCommands.Remove(command);
 }
示例#8
0
文件: Track.cs 项目: niksg/LDJam41
 private void MistimedCommand(TrackCommand command)
 {
     if (this.OnMistimed != null)
     {
         OnMistimed(this, command);
     }
     command.MistimedHit();
     PlaySound(false);
     this.TrackCommands.Remove(command);
 }
示例#9
0
文件: Track.cs 项目: niksg/LDJam41
 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
文件: Track.cs 项目: niksg/LDJam41
        private void HitCommand(TrackCommand command)
        {
            if (this.OnHit != null)
            {
                OnHit(this, command);
            }

            command.Hit();
            PlaySound(false);
            this.TrackCommands.Remove(command);
        }
示例#12
0
文件: Track.cs 项目: niksg/LDJam41
        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
文件: Track.cs 项目: niksg/LDJam41
        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();
 }