Пример #1
0
        public IEnumerator PrevPlayerStackContainer()
        {
            GetInventoryContainerResult result = new GetInventoryContainerResult();

            yield return(StartCoroutine(mCurrentSession.PlayerInventory.GetInventoryContainer(mCurrentSession.CurrentPlayerStackEnablerIndex, false, result)));

            if (result.FoundContainer)
            {
                mCurrentSession.CurrentPlayerStackEnablerIndex = result.ContainerIndex;
                mCurrentSession.CurrentPlayerStackEnabler      = result.ContainerEnabler;
                BarterInterface.SetPlayerInventoryContainer(mCurrentSession.CurrentPlayerStackEnabler);
            }
            mCurrentSession.RefreshAction.SafeInvoke();
            yield break;
        }
Пример #2
0
        public IEnumerator PrevCharacterStackContainer()
        {
            GetInventoryContainerResult result = new GetInventoryContainerResult();

            yield return(StartCoroutine(mCurrentSession.CharacterInventory.GetInventoryContainer(mCurrentSession.CurrentCharacterStackEnablerIndex, false, result)));

            if (result.FoundContainer)
            {
                mCurrentSession.CurrentCharacterStackEnablerIndex = result.ContainerIndex;
                mCurrentSession.CurrentCharacterStackEnabler      = result.ContainerEnabler;
                BarterInterface.SetCharacterInventoryContainer(mCurrentSession.CurrentCharacterStackEnabler);
                BarterInterface.CharacterNameLabel.text = (result.ContainerIndex + 1).ToString() + " / " + result.TotalContainers.ToString();
            }
            mCurrentSession.RefreshAction.SafeInvoke();
            yield break;
        }
Пример #3
0
        public IEnumerator GetInventoryContainer(int currentIndex, bool forward, GetInventoryContainerResult result)
        {
            if (result == null)
            {
                yield break;
            }

            mOnAccessInventory.SafeInvoke();

            if (mContainerEnabler == null)
            {
                //if we don't have an enabler, we need one now
                if (CharacterInventoryGroup == null)
                {
                    //if we don't have a character group, we'll need to create it to store our stuff
                    CharacterInventoryGroup = WIGroups.GetOrAdd(worlditem.FileName, WIGroups.Get.World, worlditem);
                }
                //make sure the group is loaded
                CharacterInventoryGroup.Load();
                //create a new container enabler for our stuff
                mContainerEnabler = Stacks.Create.StackEnabler(CharacterInventoryGroup);
            }

            int       totalContainers = 1;
            ShopOwner shopOwner       = null;

            if (worlditem.Is <ShopOwner> (out shopOwner))
            {
                //are we alive? if so, this can mean any containers that are owned by us in the group
                //start in the group that
                int nextIndex = currentIndex;
                List <Container> containers = new List <Container> ();
                if (WIGroups.GetAllContainers(worlditem.Group, containers))
                {
                    if (forward)
                    {
                        nextIndex = containers.NextIndex <Container> (currentIndex);
                    }
                    else
                    {
                        nextIndex = containers.PrevIndex <Container> (currentIndex);
                    }
                    //tell the container that we're opening it, then wait a tick for it to fill
                    try {
                        containers [nextIndex].OnOpenContainer();
                    } catch (Exception e) {
                        Debug.LogException(e);
                        yield break;
                    }
                    yield return(null);

                    mContainerEnabler.EnablerStack.Items.Clear();
                    Stacks.Display.ItemInEnabler(containers [nextIndex].worlditem, mContainerEnabler);
                    result.ContainerEnabler = mContainerEnabler;
                    result.ContainerIndex   = nextIndex;
                    result.TotalContainers  = containers.Count;
                }
            }
            else
            {
                //if we're not a shop owner
                //then there's exactly one container, our inventory container
                //if we're holding a temporary item then there are two
                if (IsHoldingTemporaryItem)
                {
                    Debug.Log("We're holding item so we'll return 2 containers");
                    //index 0 is our container enabler
                    //index 1 is our temporary item
                    result.TotalContainers = 2;
                    if (currentIndex == 0)                      //toggle to our held item
                    //Stacks.Display.ItemInEnabler (worlditem, mTemporaryItemEnabler);
                    {
                        result.ContainerIndex   = 1;
                        result.ContainerEnabler = mTemporaryItemEnabler;
                    }
                    else                        //toggle to our container enabler
                    {
                        Stacks.Display.ItemInEnabler(worlditem, mContainerEnabler);
                        result.ContainerIndex   = 0;
                        result.ContainerEnabler = mContainerEnabler;
                    }
                }
                else
                {
                    Stacks.Display.ItemInEnabler(worlditem, mContainerEnabler);
                    result.ContainerIndex   = 0;
                    result.TotalContainers  = 1;
                    result.ContainerEnabler = mContainerEnabler;
                }
                //this is always the same
                result.InventoryBank = InventoryBank;
            }
            yield break;
        }