Ejemplo n.º 1
0
    private List <Tile> GetAllMatches(SwapAction swapInfo)
    {
        List <Tile> matches = new List <Tile>();

        var matchesOnTile1 = FindMatchesAt(swapInfo.p1.x, swapInfo.p1.y, 3);
        var matchesOnTile2 = FindMatchesAt(swapInfo.p2.x, swapInfo.p2.y, 3);

        matches = matchesOnTile1.Union(matchesOnTile2).ToList();
        return(matches);
    }
Ejemplo n.º 2
0
        protected virtual void ProcessSwapAction(SwapAction action, List <StackResponseContainerInfo> stackResponses)
        {
            StackRequestSlotInfo source      = action.Source;
            StackRequestSlotInfo destination = action.Destination;

            Item sourceItem = GetContainerItem(source.ContainerId, source.Slot);
            Item destItem   = GetContainerItem(destination.ContainerId, destination.Slot);

            SetContainerItem(source.ContainerId, source.Slot, destItem);
            SetContainerItem(destination.ContainerId, destination.Slot, sourceItem);

            if (source.ContainerId == 21 || source.ContainerId == 22 || destination.ContainerId == 21 || destination.ContainerId == 22)
            {
                if (!(GetContainerItem(21, 14) is ItemAir) && !(GetContainerItem(22, 15) is ItemAir))
                {
                    Enchantment.SendEnchantments(_player, GetContainerItem(21, 14));
                }
                else
                {
                    Enchantment.SendEmptyEnchantments(_player);
                }
            }

            stackResponses.Add(new StackResponseContainerInfo
            {
                ContainerId = source.ContainerId,
                Slots       = new List <StackResponseSlotInfo>
                {
                    new StackResponseSlotInfo()
                    {
                        Count          = destItem.Count,
                        Slot           = source.Slot,
                        HotbarSlot     = source.Slot,
                        StackNetworkId = destItem.UniqueId
                    }
                }
            });
            stackResponses.Add(new StackResponseContainerInfo
            {
                ContainerId = destination.ContainerId,
                Slots       = new List <StackResponseSlotInfo>
                {
                    new StackResponseSlotInfo()
                    {
                        Count          = sourceItem.Count,
                        Slot           = destination.Slot,
                        HotbarSlot     = destination.Slot,
                        StackNetworkId = sourceItem.UniqueId
                    }
                }
            });
        }
Ejemplo n.º 3
0
    void Update()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit))
            {
                Tile tile = hit.collider.GetComponent <Tile>();
                if (tile.board != this.board)
                {
                    return;
                }
                if (!selected)
                {
                    selected = tile;
                    Debug.LogFormat("Clicked {0} of {1}", tile, board.GetTileType(tile));
                }
                else
                {
                    if (debug)
                    {
                        var swapAction = new SwapAction(board, selected, tile);

                        board.swapStack.Begin();
                        board.swapStack.Add(swapAction);
                        board.swapStack.End();
                    }
                    else
                    {
                        if (board.CheckAdjacent(selected, tile))
                        {
                            var swapAction = new SwapAction(board, selected, tile, swapReason);

                            board.swapStack.Begin();
                            board.swapStack.Add(swapAction);
                            board.swapStack.End();
                        }
                    }

                    selected = null;
                }
            }
        }
    }
Ejemplo n.º 4
0
 public static async Task Exec(Sprite[,] sprites,
                               SwapAction act,
                               Tween tween)
 {
     await new SwapAct(sprites, act, tween).Exec();
 }
Ejemplo n.º 5
0
 private SwapAct(Sprite[,] itemSprites, SwapAction action, Tween tween)
 {
     _sprites = itemSprites;
     _act     = action;
     _tween   = tween;
 }