예제 #1
0
    void AnalyzeInput()
    {
        bool addedAnAttack = false;

        for (int i = 0; i < availableSqeuences.Length; i++)
        {
            if (addedAnAttack)
            {
                break;
            }
            for (int j = 0; j < inputHistory.Count; j++)
            {
                InputAction action    = inputHistory[j].action;
                float       deltaTime = 0;
                if (j != 0)
                {
                    deltaTime = inputHistory[j].timeStamp - inputHistory[j - 1].timeStamp;
                }
                else
                {
                    deltaTime = Time.time - inputHistory[j].timeStamp;
                }
                Debug.Log(deltaTime);
                ComboStep currentSequnceStep = availableSqeuences[i].sequenceSteps[j];
                if (action == currentSequnceStep.action && deltaTime <= currentSequnceStep.maxChainTime && deltaTime >= currentSequnceStep.minChainTime)
                {
                    var step = new ComboRec(currentSequnceStep, inputHistory[j].timeStamp);
                    if (!tempSequenceWithTimeStamp.Contains(step))
                    {
                        tempSequenceWithTimeStamp.Add(step);
                        addedAnAttack = true;
                        break;
                    }
                }
                else//Sequence Doesn't Match
                {
                    break;
                }
            }
        }

        while (tempSequenceWithTimeStamp.Count > MaxActions)
        {
            tempSequenceWithTimeStamp.RemoveAt(0);
        }

        if (tempSequenceWithTimeStamp.Count > 0)
        {
            var lastStepInSequence = tempSequenceWithTimeStamp[tempSequenceWithTimeStamp.Count - 1];

            if (Time.time - lastStepInSequence.timeStamp > lastStepInSequence.comboStep.maxChainTime)
            {
                tempSequenceWithTimeStamp.Clear();
            }
        }
    }
예제 #2
0
    public ComboStep GetComboStep(int hit)
    {
        ComboStep currentStep = ComboSteps[0];

        foreach (var comboStep in ComboSteps)
        {
            if (hit >= comboStep.Count)
            {
                currentStep = comboStep;
            }
            else
            {
                break;
            }
        }

        return(currentStep);
    }
예제 #3
0
    void UpdateComboUI(object obj)
    {
        //Quickfix
        if (GameManager.Instance.CurrentGamePhase == GamePhase.LevelEnd)
        {
            return;
        }

        int comboCount = GameManager.Instance.ComboCount;

        if (comboCount > 0)
        {
            ComboCountText.gameObject.SetActive(true);
            ComboLabelText.gameObject.SetActive(true);
            ComboCountText.text = comboCount + " HITS";
            ComboStep step = GameManager.instance.GameData.GetComboStep(comboCount);
            ComboLabelText.text  = step.Label;
            ComboCountText.color =
                GameManager.Instance.GameData.GetBlocColorColorValue(GameManager.instance.LastDestroyedColor);

            int indexCombo = GameManager.instance.GameData.ComboSteps.IndexOf(step);
            if (indexCombo > 0 && indexCombo < ComboMedals.Count)
            {
                GameObject medal = ComboMedals[indexCombo - 1];
                if (!medal.activeSelf)
                {
                    medal.SetActive(true);
                    medal.transform.localScale = Vector3.zero;
                    medal.transform.DOScale(2f, 0.25f).OnComplete(() => { medal.transform.DOScale(1f, 0.25f); });
                    ComboLabelText.transform.DOScale(2f, 0.25f).OnComplete(() =>
                    {
                        ComboLabelText.transform.DOScale(1f, 0.25f);
                    });
                }
            }
        }
        else
        {
            ComboCountText.gameObject.SetActive(false);
            ComboLabelText.gameObject.SetActive(false);
        }
    }
예제 #4
0
    //Display the maximum combo (hits, medals and label) at the end of the level if the player wins
    void ShowMaxComboUI(object obj)
    {
        int maxCombo = (int)obj;

        ComboCountText.text = maxCombo + " HITS";
        ComboStep step = GameManager.instance.GameData.GetComboStep(maxCombo);

        ComboLabelText.text  = step.Label;
        ComboCountText.color =
            GameManager.Instance.GameData.GetBlocColorColorValue(GameManager.instance.LastDestroyedColor);

        int indexCombo = GameManager.instance.GameData.ComboSteps.IndexOf(step);

        for (int i = 0; i <= indexCombo; i++)
        {
            if (i >= 0 && i < ComboMedals.Count)
            {
                GameObject medal = ComboMedals[i];
                medal.SetActive(true);
                medal.transform.localScale = Vector3.zero;
                medal.transform.DOScale(2f, 0.25f).OnComplete(() => { medal.transform.DOScale(1f, 0.25f); });
            }
        }
    }
예제 #5
0
 public ComboRec(ComboStep _action, float _timeStamp)
 {
     comboStep = _action;
     timeStamp = _timeStamp;
 }