예제 #1
0
        public static void DisplayChainWidget(GridScript grid, int chainCount, long score, Color color, Vector3 position)
        {
            if (Instance == null)
            {
                return;
            }
            var prefab = Instance.chainPrefab;

            if (prefab == null)
            {
                Log.Error("Missing Chain widget prefab");
                return;
            }

            var go = Instantiate(prefab.gameObject, grid.ui.transform, true);

            go.transform.position   = position + RandomEx.GetVector3(-0.5f, 0.5f, -0.25f, 0.25f, 0, 0);
            go.transform.localScale = Vector3.one;

            var comboWidget = go.AddOrGetComponent <ComboTextWidget>();

            comboWidget.SetMultiplier(chainCount, color);

            ObjectiveWidget targetWidget = null;
            var             widgets      = GetWidgets(grid.player.index);

            widgets = widgets.Where(w => w != null).ToArray();

            // Chains
            foreach (var w in widgets)
            {
                if (w.Objective != null && (w.Objective.GetObjectiveType() == ObjectiveStatType.HighestChain ||
                                            w.Objective.GetObjectiveType() == ObjectiveStatType.TotalChains))
                {
                    AnimateObjectiveUpdate(grid, w, position);
                    targetWidget = w;
                }
            }

            AnimateComboScoreWidget(comboWidget, targetWidget, chainCount);
        }
예제 #2
0
        private static void AnimateObjectiveUpdate(GridScript grid, ObjectiveWidget obj, Vector3 loc)
        {
            if (obj.IsCompleted)
            {
                return;
            }

            var image = CreateObjectiveIcon(grid, obj, loc);

            image.transform.localScale = Vector3.zero;

            var seq = DOTween.Sequence();

            // Move slightly up
            seq.Append(image.transform.DOMove(
                           new Vector3(image.transform.position.x + Random.Range(-1f, 1f),
                                       image.transform.position.y + Random.Range(-1f, 1f)), 0.35f)
                       .SetEase(Ease.OutQuart));
            seq.Join(image.transform.DOScale(Vector3.one, 0.25f).SetEase(Ease.OutBack));

            seq.AppendInterval(0.25f);

            // Create a random path to the icon
            var            destination = obj.Icon.transform.position;
            List <Vector3> path        = new List <Vector3>();
            int            count       = Random.Range(1, 3);

            for (int i = 1; i < count; i++)
            {
                var point = Vector3.Lerp(loc, destination, i / (float)count);
                point += RandomEx.GetVector3(-0.15f, 0.15f, -0.15f, 0.15f, 0, 0);
                path.Add(point);
            }

            path.Add(destination);

            seq.Append(image.transform.DOPath(path.ToArray(), 0.85f, PathType.CatmullRom).SetEase(Ease.InCubic));
            seq.AppendCallback(obj.Highlight);
            seq.Append(image.transform.DOScale(Vector3.zero, 0.15f));
            seq.AppendCallback(() => { Destroy(image.gameObject); });
        }
예제 #3
0
        private static IEnumerator AnimateSendSingle(GridScript gridScript, GameObject s)
        {
            const float DURATION = 1.35f;
            float       t        = 0f;

            Vector3 start = gridScript.transform.position
                            + new Vector3(gridScript.settings.width, gridScript.settings.height, 0)
                            + RandomEx.GetVector3(0f, 4f, 0f, 4f, 0, 0);
            Vector3 end = start + new Vector3(-12, -13, 0);

            while (t < DURATION)
            {
                t += Time.deltaTime;
                float p = Interpolators.EaseOutCurve.Evaluate(t / DURATION);

                s.transform.position = Vector3.Lerp(start, end, p);

                yield return(new WaitForEndOfFrame());
            }

            Destroy(s);
        }
예제 #4
0
        public static void DisplayComboWidget(GridScript grid, int combo, int blocksCount, long score, BlockDefinition def,
                                              Vector2 loc, Vector2[] positions)
        {
            if (Instance == null)
            {
                return;
            }

            var go = Instantiate(Instance.scorePrefab.gameObject, grid.ui.transform, true);

            go.transform.position   = loc + RandomEx.GetVector2(-0.5f, 0.5f, -0.25f, 0.25f);
            go.transform.localScale = Vector3.one;

            var comboWidget = go.AddOrGetComponent <ComboTextWidget>();

            comboWidget.SetScore(score, def.color);

            ObjectiveWidget targetWidget = null;
            var             widgets      = GetWidgets(grid.player.index);

            widgets = widgets.Where(w => w != null).ToArray();

            // Combo
            foreach (var w in widgets)
            {
                if (w.Objective != null && w.Objective.GetObjectiveType() == ObjectiveStatType.TotalCombos)
                {
                    AnimateObjectiveUpdate(grid, w, loc);
                }
            }

            // Score
            foreach (var w in widgets)
            {
                if (w.Objective != null && w.Objective.GetObjectiveType() == ObjectiveStatType.Score)
                {
                    targetWidget = w;
                }
            }

            // 4 combo
            if (blocksCount == 4)
            {
                foreach (var w in widgets)
                {
                    if (w.Objective != null && w.Objective.GetObjectiveType() == ObjectiveStatType.Total4Combos)
                    {
                        AnimateObjectiveUpdate(grid, w, loc);
                    }
                }
            }
            // 5 combo
            else if (blocksCount == 5)
            {
                foreach (var w in widgets)
                {
                    if (w.Objective != null && w.Objective.GetObjectiveType() == ObjectiveStatType.Total5Combos)
                    {
                        AnimateObjectiveUpdate(grid, w, loc);
                    }
                }
            }
            // L combos
            else if (blocksCount > 5)
            {
                foreach (var w in widgets)
                {
                    if (w.Objective != null && w.Objective.GetObjectiveType() == ObjectiveStatType.TotalLCombos)
                    {
                        AnimateObjectiveUpdate(grid, w, loc);
                    }
                }
            }


            if (comboWidget != null)
            {
                AnimateComboScoreWidget(comboWidget, targetWidget, combo);
            }
        }