コード例 #1
0
        public static ContainerMoveState.ActionState AddItem(OwnedItemInformation addItem, ItemContainer targetContainer)
        {
            if (addItem.IsLocked)
            {
                return(ContainerMoveState.ActionState.No);
            }

            ContainerMoveState targetAddState = targetContainer.GetContainerAddState(addItem);

            switch (targetAddState.ContainerActionState)
            {
            case ContainerMoveState.ActionState.Add:

                targetContainer.Add(addItem, targetAddState.PossibleAddAmount);

                break;

            case ContainerMoveState.ActionState.No:
                break;

            default:
                break;
            }

            return(targetAddState.ContainerActionState);
        }
コード例 #2
0
        public static ContainerMoveState.ActionState MoveItem(OwnedItemInformation movingItemData, ItemContainer targetContainer)
        {
            try
            {
                if (movingItemData.IsLocked)
                    return ContainerMoveState.ActionState.No;

                if (movingItemData == null)
                    throw new Exception("Can Not Move null item");

                if (targetContainer == null)
                    throw new Exception("Can not move item to null container");

                ContainerMoveState targetAddState = targetContainer.GetContainerAddState(movingItemData);

                switch (targetAddState.ContainerActionState)
                {
                    case ContainerMoveState.ActionState.Add:

                        OwnedItemInformation newItemData = new OwnedItemInformation();
                        newItemData.Amount = movingItemData.Amount;
                        newItemData.Information = movingItemData.Information;
                        newItemData.OwnerContainer = movingItemData.OwnerContainer;
                        newItemData.StackLocationId = movingItemData.StackLocationId;
                        newItemData.Location = movingItemData.Location;

                        if (movingItemData.OwnerContainer != null)
                        {
                            if (RemoveItem(movingItemData, movingItemData.OwnerContainer) == ContainerMoveState.ActionState.No)
                                return ContainerMoveState.ActionState.No;
                        }

                        targetContainer.Add(newItemData, targetAddState.PossibleAddAmount);

                        break;
                    case ContainerMoveState.ActionState.No:
                        break;
                    default:
                        break;
                }

                return targetAddState.ContainerActionState;
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);

                return ContainerMoveState.ActionState.No;
            }
        }
コード例 #3
0
        public static ContainerMoveState.ActionState AddItem(OwnedItemInformation addItem, ItemContainer targetContainer)
        {
            if (addItem.IsLocked)
                return ContainerMoveState.ActionState.No;

            ContainerMoveState targetAddState = targetContainer.GetContainerAddState(addItem);

            switch (targetAddState.ContainerActionState)
            {
                case ContainerMoveState.ActionState.Add:

                    targetContainer.Add(addItem, targetAddState.PossibleAddAmount);

                    break;
                case ContainerMoveState.ActionState.No:
                    break;
                default:
                    break;
            }

            return targetAddState.ContainerActionState;
        }
コード例 #4
0
        protected void RecivedItems(List <InstancedItemInformation> receivedItems)
        {
            Container.Clear();

            foreach (InstancedItemInformation item in receivedItems)
            {
                Container.Add(new OwnedItemInformation()
                {
                    Location        = item.Location,
                    Amount          = item.Amount,
                    Information     = item.Information,
                    IsLocked        = false,
                    OwnerContainer  = Container,
                    StackLocationId = item.StackLocationId
                }, -1, false);
            }

            if (LoadedItemsForContainerEvent != null)
            {
                LoadedItemsForContainerEvent(receivedItems, Container);
            }
        }
コード例 #5
0
        public static ContainerMoveState.ActionState MoveItem(OwnedItemInformation movingItemData, ItemContainer targetContainer)
        {
            try
            {
                if (movingItemData.IsLocked)
                {
                    return(ContainerMoveState.ActionState.No);
                }

                if (movingItemData == null)
                {
                    throw new Exception("Can Not Move null item");
                }

                if (targetContainer == null)
                {
                    throw new Exception("Can not move item to null container");
                }

                ContainerMoveState targetAddState = targetContainer.GetContainerAddState(movingItemData);

                switch (targetAddState.ContainerActionState)
                {
                case ContainerMoveState.ActionState.Add:

                    OwnedItemInformation newItemData = new OwnedItemInformation();
                    newItemData.Amount          = movingItemData.Amount;
                    newItemData.Information     = movingItemData.Information;
                    newItemData.OwnerContainer  = movingItemData.OwnerContainer;
                    newItemData.StackLocationId = movingItemData.StackLocationId;
                    newItemData.Location        = movingItemData.Location;

                    if (movingItemData.OwnerContainer != null)
                    {
                        if (RemoveItem(movingItemData, movingItemData.OwnerContainer) == ContainerMoveState.ActionState.No)
                        {
                            return(ContainerMoveState.ActionState.No);
                        }
                    }


                    targetContainer.Add(newItemData, targetAddState.PossibleAddAmount);

                    break;

                case ContainerMoveState.ActionState.No:
                    break;

                default:
                    break;
                }

                return(targetAddState.ContainerActionState);
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);

                return(ContainerMoveState.ActionState.No);
            }
        }