예제 #1
0
    public void MoveItem(S.MoveItem p)
    {
        MirItemCell toCell, fromCell;

        switch (p.Grid)
        {
        case MirGridType.Inventory:
            fromCell = p.From < User.BeltIdx ? BeltCells[p.From] : Inventory.Cells[p.From - User.BeltIdx];
            break;

        default:
            return;
        }

        switch (p.Grid)
        {
        case MirGridType.Inventory:
            toCell = p.To < User.BeltIdx ? BeltCells[p.To] : Inventory.Cells[p.To - User.BeltIdx];
            break;

        default:
            return;
        }

        if (toCell == null || fromCell == null)
        {
            return;
        }

        toCell.Locked   = false;
        fromCell.Locked = false;

        if (!p.Success)
        {
            return;
        }

        UserItem i = fromCell.Item;

        fromCell.Item = toCell.Item;
        toCell.Item   = i;
    }
예제 #2
0
 public static void MoveItem(S.MoveItem p)
 {
     GameManager.GameScene.MoveItem(p);
 }
예제 #3
0
        public void MoveItem(MirGridType grid, int from, int to)
        {
            S.MoveItem p = new S.MoveItem { Grid = grid, From = from, To = to, Success = false };
            UserItem[] array;
            switch (grid)
            {
                case MirGridType.Inventory:
                    array = Info.Inventory;
                    break;
                case MirGridType.Storage:
                    if (NPCPage == null || !String.Equals(NPCPage.Key, NPCObject.StorageKey, StringComparison.CurrentCultureIgnoreCase))
                    {
                        Enqueue(p);
                        return;
                    }
                    NPCObject ob = null;
                    for (int i = 0; i < CurrentMap.NPCs.Count; i++)
                    {
                        if (CurrentMap.NPCs[i].ObjectID != NPCID) continue;
                        ob = CurrentMap.NPCs[i];
                        break;
                    }

                    if (ob == null || !Functions.InRange(ob.CurrentLocation, CurrentLocation, Globals.DataRange))
                    {
                        Enqueue(p);
                        return;
                    }
                    array = Account.Storage;
                    break;
                case MirGridType.Trade:
                    array = Info.Trade;
                    TradeItem();
                    break;
                case MirGridType.Refine:
                    array = Info.Refine;
                    break;
                default:
                    Enqueue(p);
                    return;
            }

            if (from >= 0 && to >= 0 && from < array.Length && to < array.Length)
            {
                if (array[from] == null)
                {
                    Report.ItemError("MoveItem", grid, grid, from, to);
                    ReceiveChat("Item Move Error - Please report the item you tried to move and the time", ChatType.System);
                    Enqueue(p);
                    return;
                }

                UserItem i = array[to];
                array[to] = array[from];

                Report.ItemMoved("MoveItem", array[to], grid, grid, from, to);

                array[from] = i;

                Report.ItemMoved("MoveItem", array[from], grid, grid, to, from);

                p.Success = true;
                Enqueue(p);
                return;
            }

            Enqueue(p);
        }
예제 #4
0
        public void MoveItem(MirGridType grid, int from, int to)
        {
            S.MoveItem p = new S.MoveItem { Grid = grid, From = from, To = to, Success = false };
            UserItem[] array;
            switch (grid)
            {
                case MirGridType.Inventory:
                    array = Info.Inventory;
                    break;
                case MirGridType.Storage:
                    if (NPCPage == null || !String.Equals(NPCPage.Key, NPCObject.StorageKey, StringComparison.CurrentCultureIgnoreCase))
                    {
                        Enqueue(p);
                        return;
                    }
                    NPCObject ob = null;
                    for (int i = 0; i < CurrentMap.NPCs.Count; i++)
                    {
                        if (CurrentMap.NPCs[i].ObjectID != NPCID) continue;
                        ob = CurrentMap.NPCs[i];
                        break;
                    }

                    if (ob == null || !Functions.InRange(ob.CurrentLocation, CurrentLocation, Globals.DataRange))
                    {
                        Enqueue(p);
                        return;
                    }
                    array = Account.Storage;
                    break;
                default:
                    Enqueue(p);
                    return;
            }

            if (from >= 0 && to >= 0 && from < array.Length && to < array.Length)
            {
                UserItem i = array[to];
                array[to] = array[from];
                array[from] = i;

                p.Success = true;
                Enqueue(p);
                return;
            }

            Enqueue(p);
        }
예제 #5
0
    public void MoveItem(S.MoveItem p)
    {
        MirItemCell toCell, fromCell;

        switch (p.Grid)
        {
        case MirGridType.Inventory:
            fromCell = Inventory.Cells[p.From];
            break;

        default:
            return;
        }

        switch (p.Grid)
        {
        case MirGridType.Inventory:
            toCell = Inventory.Cells[p.To];
            break;

        default:
            return;
        }

        if (toCell == null || fromCell == null)
        {
            return;
        }

        toCell.Locked   = false;
        fromCell.Locked = false;

        if (!p.Success)
        {
            return;
        }

        UserItem     i    = fromCell.Item;
        MirQuickCell toqc = toCell.QuickCell;

        if (fromCell.QuickCell != null)
        {
            toCell.QuickCell      = fromCell.QuickCell;
            toCell.QuickCell.Item = toCell;
        }
        else
        {
            toCell.QuickCell = null;
        }

        if (toqc != null)
        {
            fromCell.QuickCell      = toqc;
            fromCell.QuickCell.Item = fromCell;
        }
        else
        {
            fromCell.QuickCell = null;
        }

        fromCell.Item = toCell.Item;
        toCell.Item   = i;
    }