Ejemplo n.º 1
0
    public void ProcessAction(ActionResult result, Vector2 pos)
    {
        FlyingText rft  = FlyingText.Spawn(pos);
        var        text = result.successGrade.ToString() + "!";

        if (texts.ContainsKey(result.successGrade))
        {
            text = texts[result.successGrade];
        }
        rft.SetText(text);

        var delay = 0.15f;

        if (result.points > 0)
        {
            FlyingText pft = FlyingText.Spawn(pos);
            pft.Delay(delay);
            delay += 0.15f;
            pft.SetText("+" + result.points);
        }

        if (result.successGrade < ActionSuccessGrade.Good)
        {
            comboCounter = 0;
            comboImage.gameObject.SetActive(false);
            comboCounterItem.GetComponent <Animation>().enabled = false;
        }
        else
        {
            comboCounter++;
        }
        comboCounterItem.SetProgress(comboCounter / 3.0f);

        if (comboCounter >= 3)
        {
            comboImage.gameObject.SetActive(true);
            comboCounterItem.GetComponent <Animation>().enabled = true;
            result.points = (int)(result.points * 2f) + (comboCounter - 3) * 20;
            FlyingText ft = FlyingText.Spawn(pos, delay);
            if (comboCounter > 3)
            {
                ft.SetText("COMBO x" + (comboCounter - 2) + "!!");
            }
            else
            {
                ft.SetText("COMBO!");
            }
        }

        var infos = GameObject.FindObjectsOfType <GamePlayer>();

        foreach (var i in infos)
        {
            i.ChangeScore(result.points);
        }
//        if (GamePlayer.Instance != null)
//        {
//             GamePlayer.Instance.DeltaPoints(result.points);
//        }
//
        if (result.successGrade != ActionSuccessGrade.Fail)
        {
            _animations.MySuccessAnimation();
        }
    }