示例#1
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);
        });
    }
示例#2
0
文件: Cube.cs 项目: hskim3000/Match3
    void Start()
    {
        sequence = GOTween.Sequence().SetEase(GOEase.SmoothStep);
        sequence.Insert(1, transform.GOLocalMove(
                            new Vector3(0, 5, 0),
                            1f
                            ));

        StartCoroutine(StartAddingPosition());
    }
示例#3
0
 void SwapGems(List <GemModel> swappingGemModels, GOSequence sequence, float currentTime)
 {
     foreach (var gemModel in swappingGemModels)
     {
         var gemView      = gemViews[gemModel.id];
         var position     = gemModel.Position;
         var nextPosition = new Vector3(position.col * gemSize.x, position.row * gemSize.y, 0);
         var gapOfTurn    = gemView.PreservedFromMatch - Model.currentTurn + 1;
         sequence.Insert(currentTime, gemView.transform.GOLocalMove(
                             nextPosition,
                             gapOfTurn * (TIME_PER_FRAME * FRAME_BY_TURN)
                             ));
     }
 }
示例#4
0
    void CheckHasAnyMatchableGems()
    {
        var matchableGems = Controller.GetMatchableGems();

        if (matchableGems.Count == 0)
        {
            AddAction(Model.currentTurn, (sequence, currentTime) => {
                Toast.Show("There's doesn't have any match.", 3f);
            });
            AddAction(Model.currentTurn + A_QUARTER_OF_SHUFFLE, (sequence, currentTime) => {
                foreach (var gemModel in Controller.Shuffle(Model.currentTurn + A_QUARTER_OF_SHUFFLE * 3))
                {
                    var gemView        = gemViews[gemModel.id];
                    var aQuarterOfTime = A_QUARTER_OF_SHUFFLE * (TIME_PER_FRAME * FRAME_BY_TURN);
                    sequence.Insert(currentTime, gemView.transform.GOMove(Vector3.zero, aQuarterOfTime).SetEase(GOEase.EaseIn));
                    sequence.Insert(currentTime + aQuarterOfTime, gemView.transform.GOLocalMove(
                                        new Vector2(gemModel.Position.col * gemSize.x, gemModel.Position.row * gemSize.y),
                                        aQuarterOfTime
                                        ).SetEase(GOEase.EaseOut));
                }
            });
            UpdateChanges();
        }
        else
        {
            var matchableGem = matchableGems[UnityEngine.Random.Range(0, matchableGems.Count)];
            if (matchableGem.sourceGemModel != null)
            {
                gemViews[matchableGem.sourceGemModel.id].Highlight();
            }
            if (matchableGem.nearGemModel != null)
            {
                gemViews[matchableGem.nearGemModel.id].Highlight();
            }
        }
    }
示例#5
0
文件: Cube.cs 项目: hskim3000/Match3
    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++;
        }
    }
示例#6
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());
            }
        }
        ;
    }