Exemplo n.º 1
0
 void GetReady()
 {
     UpdateChanges((Int64 passedTurn) => {
         AddAction(Model.currentTurn + passedTurn, (sequence, currentTime) => {
             sequence.InsertCallback(currentTime, () => {
                 // Hello, Player!
                 MatchSound.Instance.Play("Intro");
                 foreach (var gemModel in Controller.GetAll())
                 {
                     gemViews[gemModel.id].Squash();
                 }
             });
         });
     });
 }
Exemplo n.º 2
0
    void MergeGems(MergedGemInfo mergedGemInfo, GOSequence sequence, float currentTime)
    {
        var mergerGemModel = mergedGemInfo.merger;
        var mergeeGemModel = mergedGemInfo.mergee;

        var mergerPosition = mergerGemModel.Position;
        var mergeePosition = mergeeGemModel.Position;

        var mergeeGemView      = gemViews[mergeeGemModel.id];
        var mergeeNextPosition = new Vector3(mergerPosition.col * gemSize.x, mergerPosition.row * gemSize.y, 0);
        var gapOfTurn          = mergeeGemView.PreservedFromMatch - (Model.currentTurn + 1);

        sequence.Insert(currentTime, mergeeGemView.transform.GOLocalMove(
                            mergeeNextPosition,
                            gapOfTurn * (TIME_PER_FRAME * FRAME_BY_TURN)
                            ).SetEase(GOEase.EaseOut));
        sequence.InsertCallback(currentTime, () => MatchSound.Instance.Play("Merge"));

        var markerID = mergerGemModel.id;

        AddAction((mergeeGemView.PreservedFromMatch + 1), (GOSequence innerSequence, float innerCurrentTime) => {
            SetBlock(mergerPosition, markerID);
            var brokenGemInfo = Controller.Break(mergerPosition, markerID);
            BreakGems(brokenGemInfo.gemModel, true, innerSequence, innerCurrentTime);

            SetBlock(mergeePosition, markerID);
        });
    }
Exemplo n.º 3
0
    void MatchGems(List <MatchedLineInfo> matchedLineInfos, GOSequence sequence, float currentTime)
    {
        foreach (var matchedLineInfo in matchedLineInfos)
        {
            var newAdded          = matchedLineInfo.newAdded;
            var combindedLocation = default(Vector2);
            if (newAdded != null)
            {
                combindedLocation = new Vector2(newAdded.Position.col * gemSize.x, newAdded.Position.row * gemSize.y);
            }

            foreach (var gemModel in matchedLineInfo.gemModels)
            {
                var gemView = RemoveGemView(gemModel, true);
                if (gemView == null)
                {
                    continue;
                }

                sequence.InsertCallback(currentTime, () => {
                    gemView.ReturnToPool(true, combindedLocation);
                    OnGemRemoved.Invoke((int)gemModel.Type, gemView.transform.position, effects.transform);
                });
            }

            if (matchedLineInfo.newAdded != null)
            {
                var gemView = MakeGemView(matchedLineInfo.newAdded);
                gemView.SetActive(false);

                sequence.InsertCallback(currentTime, () => {
                    gemView.Reveal();
                    gemView.Squash();
                });
            }
        }
    }
Exemplo n.º 4
0
    void FallGems(List <GemInfo> fallingGemInfos, GOSequence sequence, float currentTime)
    {
        foreach (var gemInfo in fallingGemInfos)
        {
            var gemView  = gemViews[gemInfo.id];
            var position = gemInfo.position;
            sequence.InsertCallback(currentTime, () => {
                gemView.Reveal();
            });

            var nextPosition = new Vector3(position.col * gemSize.x, position.row * gemSize.y, 0);
            var gapOfTurn    = gemView.PreservedFromMatch - Model.currentTurn + 1;
            var duration     = gapOfTurn * (TIME_PER_FRAME * FRAME_BY_TURN);
            sequence.Insert(currentTime, gemView.transform.GOLocalMove(
                                nextPosition,
                                duration
                                ));
            if (gemInfo.endOfFall)
            {
                sequence.InsertCallback(currentTime + duration, () => gemView.Squash());
            }
        }
        ;
    }
Exemplo n.º 5
0
    void BreakGems(GemModel gemModel, bool needToChaining, GOSequence sequence, float currentTime)
    {
        if (gemModel == null)
        {
            return;
        }

        var gemView = RemoveGemView(gemModel, needToChaining);

        if (gemView == null)
        {
            return;
        }

        sequence.InsertCallback(currentTime, () => {
            gemView.ReturnToPool();
            OnGemRemoved.Invoke((int)gemModel.Type, gemView.transform.position, effects.transform);
        });
    }
Exemplo n.º 6
0
    IEnumerator StartAddingPosition()
    {
        var count = 2;

        while (count <= 5)
        {
            var random  = new System.Random();
            var randomX = random.Next(-5, 5);
            var randomY = random.Next(-5, 5);

            // Debug.Log(count + ": " + randomX + ", " + randomY);

            sequence.Insert(count, transform.GOLocalMove(
                                new Vector3(randomX, randomY, 0),
                                1f
                                ));
            sequence.InsertCallback(count, () => {
                // Debug.Log(count);
            });
            yield return(null);

            count++;
        }
    }