Exemplo n.º 1
0
        private void OnSwipeOver(SwipeAction sender, GemController gem1, GemController gem2, bool isMatched)
        {
            if (gem1.CurrentSwipeAction == sender)
            {
                gem1.CurrentSwipeAction = null;
            }
            if (gem2.CurrentSwipeAction == sender)
            {
                gem2.CurrentSwipeAction = null;
            }
            if (isMatched)
            {
                return;
            }
            int x1 = gem1.Position.x;
            int y1 = gem1.Position.y;
            int x2 = gem2.Position.x;
            int y2 = gem2.Position.y;

            SwitchGems(x1, y1, x2, y2);
            gem1.SetPosition(x2, y2, true);
            gem2.SetPosition(x1, y1, true);
            SetGemNeighbor(gem1);
            SetGemNeighbor(gem2);
        }
Exemplo n.º 2
0
        public void OnGemMove(GemController gem, Direction direction)
        {
            GemController neighbor = gem.GetNeighbor(direction);

            if (neighbor == null)
            {
                return;
            }
            if (!neighbor.IsActive || !gem.IsActive)
            {
                return;
            }
            if (gem.SpecialType != GemSpecialType.Regular && neighbor.SpecialType != GemSpecialType.Regular ||
                gem.SpecialType == GemSpecialType.HitType || neighbor.SpecialType == GemSpecialType.HitType)
            {
                DoSpecialSwipe(gem, neighbor);
                return;
            }
            int x1 = gem.Position.x;
            int y1 = gem.Position.y;
            int x2 = neighbor.Position.x;
            int y2 = neighbor.Position.y;

            SwitchGems(x1, y1, x2, y2);
            gem.SetPosition(x2, y2, true);
            neighbor.SetPosition(x1, y1, true);
            SetGemNeighbor(gem);
            SetGemNeighbor(neighbor);
            SwipeAction swipeAction = new SwipeAction(gem, neighbor);

            swipeAction.OnSwipeActionOver += OnSwipeOver;
            gem.CurrentSwipeAction         = swipeAction;
            neighbor.CurrentSwipeAction    = swipeAction;
        }