Beispiel #1
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
Beispiel #2
0
        private void UpdateDisplay(ObjectiveStatType type, ObjectiveStats target, ObjectiveStats current,
                                   ObjectiveStats start, bool immediate)
        {
            gameObject.SetActive(true);

            // Build text
            string t = string.Empty;
            Sprite s = null;

            if (type == ObjectiveStatType.HighestMultiplier)
            {
                t = "x" + target.highestCombo;

                // Disable icon for now
                // t = (target.highestCombo - current.highestCombo).ToString();
                // s = ObjectiveData.GetIcon("combo_best");

                // if (current.highestCombo == 0 && lastStats.highestCombo > 0)
                // {
                //   Reset();
                //   immediate = true;
                //
                //   // Create a bunch of ejected stars
                //   for (int i = 0; i < lastStats.highestCombo; i++)
                //   {
                //     var image = GameUIScript.CreateObjectiveIcon(player.grid, this, transform.position);
                //     var p = transform.position + RandomEx.GetVector3(-4, 4f, 0f, 3f, 0, 0);
                //     image.transform.DOMove(p, 0.35f)
                //       .SetEase(Ease.OutCubic).OnComplete(() =>
                //       {
                //         image.transform.DOScale(Vector3.zero, 0.15f)
                //           .OnComplete(() => { Destroy(image.gameObject); });
                //       });
                //   }
                // }
            }

            if (type == ObjectiveStatType.Score)
            {
                t = "<b>" + Mathf.Max(0, target.score - (current.score - start.score)) + "</b> PTS";
                s = ObjectiveData.GetIcon("score");
            }

            if (type == ObjectiveStatType.TotalCombos)
            {
                t = Mathf.Max(0, target.totalCombos - (current.totalCombos - start.totalCombos)).ToString();
                s = ObjectiveData.GetIcon("combo_total");
            }

            if (type == ObjectiveStatType.Total4Combos)
            {
                t = Mathf.Max(0, target.total4Combos - (current.total4Combos - start.total4Combos)).ToString();
                s = ObjectiveData.GetIcon("combo_4");
            }

            if (type == ObjectiveStatType.Total5Combos)
            {
                t = Mathf.Max(0, target.total5Combos - (current.total5Combos - start.total5Combos)).ToString();
                s = ObjectiveData.GetIcon("combo_5");
            }

            if (type == ObjectiveStatType.TotalLCombos)
            {
                t = Mathf.Max(0, target.totalLCombos - (current.totalLCombos - start.totalLCombos)).ToString();
                s = ObjectiveData.GetIcon("combo_L");
            }

            if (type == ObjectiveStatType.Time)
            {
                t = target.timeReached + "'";
                // s = ObjectiveData.GetIcon("time"); -> null
            }

            if (type == ObjectiveStatType.TimeLimit)
            {
                t = (int)target.timeMax + "'";
                // s = ObjectiveData.GetIcon("time"); -> null
            }

            if (type == ObjectiveStatType.Level)
            {
                t = target.speedLevel.ToString();
                s = ObjectiveData.GetIcon("level");
            }

            if (type == ObjectiveStatType.TotalChains)
            {
                t = Mathf.Max(0, target.totalChains - (current.totalChains - start.totalChains)).ToString();
                s = ObjectiveData.GetIcon("chain");
            }

            if (type == ObjectiveStatType.HighestChain)
            {
                throw new NotImplementedException("Highest chains not used yet");
            }

            if (type == ObjectiveStatType.Height)
            {
                s = ObjectiveData.GetIcon("height");

                if (player == null)
                {
                    player = FindObjectOfType <PlayerScript>();
                }

                if (player != null)
                {
                    int ch = player.grid.HighestY;
                    int th = player.grid.targetHeight;

                    t = (Mathf.Abs(th - ch) + 1).ToString();
                }
                else
                {
                    t = target.digHeight.ToString();
                }
            }

            if (completed == false)
            {
                if (immediate)
                {
                    if (s != null)
                    {
                        SetWithIcon(s, t);
                    }
                    else
                    {
                        SetWithoutIcon(t);
                    }
                }
                else
                {
                    nextValue = t;
                }
            }

            lastStats = current;
        }