Пример #1
0
    public bool IsSatisfied(EnumAttackType input, float time)
    {
        if (!locked)
        {
            failed = true;
            if (Mathf.Abs(playTime - time) < CombatDecoder.Instance.beatLength * 0.15)
            {
                if (aType == EnumAttackType.AtkEither)
                {
                    if (input == EnumAttackType.AtkA || input == EnumAttackType.AtkB)
                    {
                        failed = false;
                    }
                }
                else if (aType == input)
                {
                    failed = false;
                }
            }
            locked   = true;
            lockTime = time;
        }

        Debug.Log($"Satisfaction: {(!failed).ToString()}");
        return(!failed);
    }
Пример #2
0
 public void CleanUI()
 {
     locked = false;
     animator.runtimeAnimatorController = null;
     currentAnimator      = EnumAttackType.None;
     transform.localScale = Vector3.one;
     transform.position   = -10 * Vector3.one;
 }
Пример #3
0
 public void SetSprite(CombatNote note)
 {
     if (!locked)
     {
         if (currentAnimator != note.AtkType)
         {
             if (controllers[(int)note.AtkType] != null)
             {
                 currentAnimator = note.AtkType;
                 animator.runtimeAnimatorController = controllers[(int)note.AtkType];
             }
         }
         if (note.Status != 0)
         {
             locked = true;
             if (note.Status == 1) // Correct hit
             {
                 animator.SetBool("Pressed", true);
             }
             else
             {
                 animator.runtimeAnimatorController = failController;
             }
         }
     }
     if (locked)
     {
         if (CombatCoordinator.Instance.SongProgress > note.PlayTime && note.Status == 1 && animator.GetBool("Pop") != true)
         {
             animator.SetBool("Pop", true);
         }
         else if (note.Status == -1)
         {
             if (animator.GetInteger("State") == 0)
             {
                 if (note.AtkType.ToString().Contains("Def"))
                 {
                     animator.SetInteger("State", 1);
                 }
                 else if (note.AtkType.ToString().Contains("Atk"))
                 {
                     animator.SetInteger("State", 2);
                 }
             }
             if (CombatCoordinator.Instance.SongProgress > note.PlayTime && animator.GetBool("Pop") != true)
             {
                 animator.SetBool("Pop", true);
             }
         }
     }
 }
Пример #4
0
 private void GetCombatInfo(EnumAttackType action, bool successful)
 {
     if (successful)
     {
         if (action == EnumAttackType.AtkA || action == EnumAttackType.AtkB || action == EnumAttackType.AtkEither)
         {
             CurrentEnemyHealth -= 10;
         }
     }
     else
     {
         if (action == EnumAttackType.DefUp || action == EnumAttackType.DefLeft || action == EnumAttackType.DefDown || action == EnumAttackType.DefRight)
         {
             CurrentPlayerHealth -= 15;
         }
     }
 }
Пример #5
0
    private void GetCombatInfo(EnumAttackType action, bool successful)
    {
        bool change = false;

        if ((action == EnumAttackType.DefLeft || action == EnumAttackType.DefUp) && !successful)
        {
            SetBoolTrue("Hit");
            change = true;
        }
        else if (action == EnumAttackType.DefLeft && successful)
        {
            SetBoolTrue("Dodge_Back");
            change = true;
        }
        else if (action == EnumAttackType.DefUp && successful)
        {
            SetBoolTrue("Dodge_Up");
            change = true;
        }
        else if (action == EnumAttackType.AtkA)
        {
            SetBoolTrue("Attack_Fwd");
            change = true;
        }
        else if (action == EnumAttackType.AtkB)
        {
            SetBoolTrue("Attack_Dwn");
            change = true;
        }

        if (change)
        {
            SetBoolTrue("Idle");
            StartCoroutine(BackToIdle());
        }
    }
Пример #6
0
    private IEnumerator CombatLoop()
    {
        AnimationSpeedCall?.Invoke(CombatDecoder.Instance.beatLength);
        songProgress    = -CombatDecoder.Instance.beatLength * CombatDecoder.Instance.beats;
        noteTrackPeriod = CombatDecoder.Instance.beatLength * 3.0f;
        while (true)
        {
            if (!playing && songProgress >= 0.0f)
            {
                GetComponent <AudioSource>()?.Play();
                playing = true;
            }

            // input resolution
            EnumAttackType btnInput = EnumAttackType.None;

            if (InputManager.AButton)
            {
                btnInput = EnumAttackType.AtkA;
            }
            else if (InputManager.BButton)
            {
                btnInput = EnumAttackType.AtkB;
            }
            else if (InputManager.LeftArrow)
            {
                btnInput = EnumAttackType.DefLeft;
            }
            else if (InputManager.UpArrow)
            {
                btnInput = EnumAttackType.DefUp;
            }

            // Input response
            Debug.Log($"Found input: {btnInput.ToString()}");

            for (int i = 0; i < noteQueue.Count; ++i)
            {
                if (NoteQueueItem(i).Status == 0)
                {
                    if (NoteInRange(NoteQueueItem(i)))
                    {
                        if (btnInput != EnumAttackType.None || NoteQueueItem(i).TimeOutCheck(songProgress))
                        {
                            Debug.Log("Note in range.");
                            NoteQueueItem(i).IsSatisfied(btnInput, songProgress);
                            break;
                        }
                    }
                    else if (songProgress - NoteQueueItem(i).LockTime < 0.1)
                    {
                        break;
                    }
                }
            }

            // Response to beats reaching goal
            for (int i = 0; i < noteQueue.Count; ++i)
            {
                CombatNote note = NoteQueueItem(i);
                if (songProgress > note.PlayTime)
                {
                    if (!note.Resolved && note.Status != 0)
                    {
                        // Note resolution
                        ResolveAction(note.AtkType, !note.Failed);
                        note.Resolved = true;
                    }
                }
                else
                {
                    break;
                }
            }

            // Check for combat finish
            if (combatState != EnumCombatState.Ongoing)
            {
                // ~~~ End combat things
                break;
            }

            // Render beats
            for (int i = 0; i < noteQueue.Count; ++i)
            {
                if (NoteInRange(NoteQueueItem(i)))
                {
                    if (songProgress - NoteQueueItem(i).PlayTime >= CombatDecoder.Instance.beatLength)
                    {
                        Debug.Log("Beat has left end of track.");
                        NoteQueueItem(i).Reincarnate();
                        queueHeadIdx++;
                        AdvanceIndexCall?.Invoke();
                        continue;
                    }
                    if (NoteQueueItem(i).PlayTime < songProgress && NoteQueueItem(i).Status == 0)
                    {
                        Debug.Log("Note close to time out.");
                        if (NoteQueueItem(i).TimeOutCheck(songProgress))
                        {
                            Debug.LogError("A Christmas miracle!");
                        }
                    }
                    BeatTrackNoteCall(i, NoteQueueItem(i));
                }
            }
            NoMoreBeatsCall?.Invoke();

            yield return(null);

            songProgress += Time.deltaTime;
        }
    }
Пример #7
0
 private void ResolveAction(EnumAttackType action, bool success)
 {
     CombatInfoCall?.Invoke(action, success);
 }
Пример #8
0
 // Creates notes in the queue
 private void AddNoteToQueue(EnumAttackType type, float timeTill)
 {
     noteQueue.Add(new CombatNote(type, timeTill));
     CombatCoordinator.Instance.noteQueue.Add(new CombatNote(type, timeTill));
 }
Пример #9
0
 public CombatNote(EnumAttackType type, float timeTill)
 {
     aType        = type;
     playTime     = timeTill;
     autoFailTime = playTime + CombatDecoder.Instance.beatLength * 0.15f;
 }