コード例 #1
0
 /// <summary>
 /// Update an objective
 /// </summary>
 public static void UpdateObjective(PlayerScript player, int index, ObjectiveStats stats)
 {
     if (Instance != null)
     {
         Instance.activeUI.UpdateObjective(player, index, stats);
     }
 }
コード例 #2
0
        public void UpdateObjective(PlayerScript player, int index, ObjectiveStats stats)
        {
            var w = GetWidget(player.player.index, index);

            if (w != null)
            {
                w.UpdateObjective(player, stats);
            }
        }
コード例 #3
0
        public void UpdateObjective(PlayerScript player, ObjectiveStats current)
        {
            if (completed)
            {
                return;
            }
            if (objective == null)
            {
                return;
            }

            UpdateDisplay(objective.GetObjectiveType(), objective.stats, current, objective.StartStats, IsImmediateUpdate);

            if (objective.Succeed(player, current))
            {
                CompleteObjective(true);
            }
        }
コード例 #4
0
        private void UpdateObjectives()
        {
            foreach (var p in players)
            {
                if (p.grid.IsPaused)
                {
                    continue;
                }

                // Give new stats, widget will check if it's relevant
                var currentStats = new ObjectiveStats(p, timeElapsed);

                for (int i = 1; i <= 4; i++)
                {
                    GameUIScript.UpdateObjective(p, i, currentStats);
                }
            }

            var p1 = players[0];

            // Stop here if not started
            if (p1.grid.IsStarted == false)
            {
                return;
            }
            //--------------------------------------------------------------------------------------------------------------

            if (isOver == false)
            {
                for (int i = 0; i < players.Count; i++)
                {
                    var pWinner = players[i];
                    var pStats  = new ObjectiveStats(pWinner, timeElapsed);
                    if (objectives.Succeed(pWinner, pStats))
                    {
                        Log.Info("Versus with level ended!");
                        GameOverVersus(pWinner);

                        break;
                    }
                }
            }
        }
コード例 #5
0
        public bool Succeed(PlayerScript player, ObjectiveStats current)
        {
            bool match = true;

            if (stats.score > 0)
            {
                match &= (current.score - startStats.score) >= stats.score;
            }

            if (stats.speedLevel > 0)
            {
                match &= current.speedLevel >= stats.speedLevel;
            }

            if (stats.totalCombos > 0)
            {
                match &= (current.totalCombos - startStats.totalCombos) >= stats.totalCombos;
            }

            if (stats.total4Combos > 0)
            {
                match &= (current.total4Combos - startStats.total4Combos) >= stats.total4Combos;
            }

            if (stats.total5Combos > 0)
            {
                match &= (current.total5Combos - startStats.total5Combos) >= stats.total5Combos;
            }

            if (stats.totalLCombos > 0)
            {
                match &= (current.totalLCombos - startStats.totalLCombos) >= stats.totalLCombos;
            }

            if (stats.highestCombo > 0)
            {
                match &= current.highestCombo >= stats.highestCombo;
            }

            if (stats.timeReached > 0)
            {
                match &= (current.timeReached - startStats.timeReached) >= stats.timeReached;
            }

            if (stats.timeMax > 0)
            {
                match &= (current.timeMax - startStats.timeMax) < stats.timeMax;
            }

            if (stats.totalChains > 0)
            {
                match &= (current.totalChains - startStats.totalChains) >= stats.totalChains;
            }

            if (stats.highestChain > 0)
            {
                match &= (current.highestChain - startStats.highestChain) >= stats.highestChain;
            }

            if (stats.digHeight > 0)
            {
                int c = player.grid.HighestY;
                int t = player.grid.targetHeight;
                match &= c < t;
            }

            return(match);
        }
コード例 #6
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;
        }