Esempio n. 1
0
        protected IEnumerator AddToReceptaclePivotOverTime(WorldItem potentialOccupant, ReceptaclePivot pivotInFocus)
        {
            //remove it from any situation that could cause a c**k-up
            worlditem.Group.AddChildItem(potentialOccupant);
            potentialOccupant.SetMode(WIMode.World);
            //this will put it into the world and un-equip it etc
            //wait for that to happen
            yield return(null);

            WIStack      pivotStack = worlditem.StackContainer.StackList [pivotInFocus.State.Index];
            WIStackError error      = WIStackError.None;

            //do not auto convert to stack item
            if (!Stacks.Push.Item(pivotStack, potentialOccupant, StackPushMode.Manual, ref error))
            {
                Debug.Log("Couldn't push item into group because " + error.ToString());
                yield break;
            }
            //wait again for the worlditem to get situated
            yield return(null);

            potentialOccupant.OnRemoveFromStack += Refresh;
            potentialOccupant.OnModeChange      += Refresh;
            potentialOccupant.tr.parent          = pivotInFocus.tr;
            //this will move it into the recepticle position
            pivotInFocus.Refresh();
            yield return(null);

            OnItemPlacedInReceptacle.SafeInvoke();
            mAddingToReceptaclePivot = false;
        }
Esempio n. 2
0
 public virtual void SetStack(WIStack stack)
 {
     if (HasStack)
     {
         if (stack != null)
         {
             if (stack != mStack)
             {
                 mStack.RefreshAction -= mRefreshRequest;
                 mStack = stack;
                 mStack.RefreshAction += mRefreshRequest;
                 //this will automatically refresh the display
                 mStack.Refresh();
             }
         }
         else
         {
             mStack.RefreshAction -= mRefreshRequest;
             mStack = null;
             //update the display to reflect the dead stack
             RefreshRequest();
         }
     }
     else if (stack != null)
     {
         mStack = stack;
         mStack.RefreshAction += mRefreshRequest;
         //this will automatically refresh the display
         mStack.Refresh();
     }
 }
Esempio n. 3
0
        public virtual bool AddToReceptacle(WorldItem potentialOccupant)
        {
            if (State.Locked)
            {
                return(false);
            }

            if (mCooldownStartTime + mCooldownInterval > WorldClock.RealTime)
            {
                return(false);
            }

            bool            result     = false;
            ReceptaclePivot emptyPivot = null;

            if (HasRoom(potentialOccupant, out emptyPivot) && IsObjectPermitted(potentialOccupant, emptyPivot.Settings))
            {
                //first we have to move the potential occupant into our group
                WIStack      pivotStack = worlditem.StackContainer.StackList [emptyPivot.State.Index];
                WIStackError error      = WIStackError.None;
                result = Stacks.Push.Item(pivotStack, potentialOccupant, ref error);
            }

            if (result)
            {
                potentialOccupant.OnRemoveFromStack        += Refresh;
                potentialOccupant.OnUnloaded               += Refresh;
                potentialOccupant.OnAddedToPlayerInventory += Refresh;
                OnItemPlacedInReceptacle.SafeInvoke();
                emptyPivot.Refresh();
            }

            return(result);
        }
Esempio n. 4
0
 public IEnumerator AddItems(WIStack stack, int numItems)
 {
     for (int i = 0; i < numItems; i++)
     {
         Stacks.Pop.Force(stack, true);                 //TEMP TODO make it not destroy shit!
     }
     yield break;
 }
Esempio n. 5
0
        public bool AddItems(WIStack stack)
        {
//			while (stack.NumItems > 0)
//			{
//				AddItems (stack.Pop ( ));
//			}
            return(true);
        }
Esempio n. 6
0
        public override void TryToRemoveItem(IStackOwner skillUseTarget, WIStack fromStack, WIStack toStack, WIGroup toGroup, Action callBack, int flavor)
        {
            //instead of attempting to remove it now
            //this skill launched the barter dialog
            //and sets up a session
            WorldItem worldItem = null;

            Stacks.Convert.TopItemToWorldItem(fromStack, out worldItem);
            IWIBase    worldItemToMove = worldItem;
            IInventory barterInventory = null;
            Character  character       = null;

            //this only works with character-owned items
            if (skillUseTarget.IsWorldItem && skillUseTarget.worlditem.Is <Character> (out character))
            {
                barterInventory = character;
                //make sure we can actually barter with the player
                ReputationState rep = Profile.Get.CurrentGame.Character.Rep.GetReputation(character.worlditem.FileName);
                if (rep.NormalizedReputationDifference(Profile.Get.CurrentGame.Character.Rep.GlobalReputation) > Extensions.MaxNormaliedReputationDifference)
                {
                    GUIManager.PostWarning(character.worlditem.DisplayName + " is not interested in bartering with you.");
                    return;
                }

                if (mCurrentSession == null)
                {
                    mCurrentSession = new BarterSession(this, mCharacterGoods, mPlayerGoods);
                }
                mCurrentSession.Reset(Player.Local.Inventory, barterInventory);
                mCurrentSession.BarteringCharacter = character;
                //add the selected goods to the current session immediately
                //so it's there when we start bartering
                mCurrentSession.CharacterStartupItem = worldItemToMove;
                //if the startup item is already in the character's inventory
                //no need to create a startup stack
                //but if it isn't we'll need the startup stack to display it
                WIStack startupStack = null;
                if (!character.HasItem(worldItemToMove, out startupStack))
                {
                    Debug.Log("Item " + worldItemToMove.FileName + " was NOT in character's inventory, creating temporary startup stack");
                    if (fromStack.NumItems == 1)
                    {
                        //just hold the one item
                        mCurrentSession.CharacterStartupStack = character.HoldTemporaryItem(worldItemToMove);
                    }
                    else
                    {
                        mCurrentSession.CharacterStartupStack = character.HoldTemporaryItem(fromStack);
                    }
                }
                else
                {
                    Debug.Log("Item " + worldItemToMove.FileName + " was in character's inventory");
                    mCurrentSession.CharacterStartupStack = startupStack;
                }
                SpawnBarterDialog();
            }
        }
Esempio n. 7
0
        public void SwapStackWithSelectedStack(WIStack selectedStack)
        {
            WIStackError error = WIStackError.None;

            if (Stacks.Add.Items(selectedStack, mStack, ref error))
            {
                UpdateDisplay();
            }
        }
Esempio n. 8
0
        public bool FillLiquidContainer(IWIBase liquidContainer, IWIBase foodStuff, WIStack foodStuffStack)
        {
            if (!foodStuff.Is <FoodStuff>())
            {
                //nope! can't do it
                return(false);
            }

            System.Object fssObject = null;
            //check the foodstuff first since it has to be liquid
            if (foodStuff.GetStateOf <FoodStuff>(out fssObject))
            {
                FoodStuffState fss = (FoodStuffState)fssObject;
                if (fss.IsLiquid(foodStuff.State))
                {
                    //okay we've confirmed it's a liquid
                    //now see if the liquid container can hold it
                    if (!liquidContainer.Is <LiquidContainer>())
                    {
                        //we're returning true because it'll make the correct noise and the item will disappear
                        GUIManager.PostWarning("The liquid cannot be held by this container. It seeps away.");
                        foodStuff.RemoveFromGame();
                        return(true);
                    }

                    System.Object lcObject = null;
                    if (liquidContainer.GetStateOf <LiquidContainer>(out lcObject))
                    {
                        LiquidContainerState lcs         = (LiquidContainerState)lcObject;
                        string           liquidFillError = string.Empty;
                        int              numFilled       = 0;
                        GenericWorldItem genericLiquid   = new GenericWorldItem(foodStuff);
                        if (lcs.TryToFillWith(genericLiquid, foodStuffStack.NumItems, out numFilled, out liquidFillError))
                        {
                            //hooray, it worked
                            //how we have to pop items off the top of the food stuff stack
                            for (int i = 0; i < numFilled; i++)
                            {
                                Stacks.Pop.AndToss(foodStuffStack);
                            }
                            GUIManager.PostInfo("Filled " + numFilled.ToString());
                            return(true);
                        }
                        else
                        {
                            GUIManager.PostWarning(liquidFillError);
                        }
                    }
                }
            }
            return(false);
        }
Esempio n. 9
0
        public bool HasItem(IWIBase item, out WIStack stack)
        {
            stack = null;
            if (mContainerEnabler == null)
            {
                return(false);
            }
            if (!mContainerEnabler.HasEnablerStack)
            {
                return(false);
            }
            WIStack        nextStack     = null;
            List <WIStack> enablerStacks = mContainerEnabler.EnablerStacks;

            for (int i = 0; i < enablerStacks.Count; i++)
            {
                nextStack = enablerStacks [i];
                if (nextStack.Items.Contains(item))
                {
                    stack = nextStack;
                    break;
                }
            }

            if (stack == null)
            {
                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
                    List <Container> containers = new List <Container> ();
                    if (WIGroups.GetAllContainers(worlditem.Group, containers))
                    {
                        foreach (Container container in containers)
                        {
                            if (Stacks.Find.Item(container.worlditem.StackContainer, item, out stack))
                            {
                                Debug.Log("Found item in shop owner container");
                                break;
                            }
                        }
                    }
                }
            }

            return(stack != null);
        }
Esempio n. 10
0
 public virtual void TryToRemoveItem(IStackOwner skillUseTarget, IWIBase itemToMove, IInventory toInventory, Action callBack, int flavor)
 {
     LastFromStack  = null;
     LastToStack    = null;
     LastItemToMove = itemToMove;
     LastInventory  = toInventory;
     LastCallback   = callBack;
     if (!CheckForSkillImmunity(itemToMove, this, out mImmunityMessage))
     {
         GUIManager.PostDanger(mImmunityMessage);
         FailImmediately();
         return;
     }
     //use the skill against the target
     Use(skillUseTarget.worlditem, LastSkillFlavor);
 }
Esempio n. 11
0
 public virtual void TryToRemoveItem(IStackOwner skillUseTarget, WIStack fromStack, WIStack toStack, WIGroup toGroup, Action callBack, int flavor)
 {
     LastInventory = null;
     LastFromStack = fromStack;
     LastToStack   = toStack;
     LastToGroup   = toGroup;
     LastCallback  = callBack;
     //make sure the item we're moving isn't immune to our skill
     if (!CheckForSkillImmunity(fromStack.TopItem, this, out mImmunityMessage))
     {
         GUIManager.PostDanger(mImmunityMessage);
         FailImmediately();
         return;
     }
     //use the skill against the target
     Use(skillUseTarget.worlditem, LastSkillFlavor);
 }
Esempio n. 12
0
    /// <summary>
    /// Show a tooltip with the tooltip text for the specified item.
    /// </summary>

    static public void ShowItem(WIStack stack)
    {
        if (stack != null)
        {
            if (stack.IsEmpty)
            {
                ShowText("(Empty)");
            }
            else
            {
//				ShowText(WorldItems.CleanWorldItemName (stack.TopItem.name));
            }
            return;
        }
        if (mInstance != null)
        {
            mInstance.mTarget = 0f;
        }
    }
Esempio n. 13
0
        public static bool ConsumeRequirement(WIStack itemStack, IWIBase item, GenericWorldItem template, bool requirementsMet)
        {
            if (!requirementsMet)
            {
                return(false);
            }

            bool result = false;

            if (item.Is <LiquidContainer> ())
            {
                //see if the thing inside the liquid container has what we need
                bool foundState                  = false;
                LiquidContainerState state       = null;
                System.Object        stateObject = null;
                if (item.GetStateOf <LiquidContainer> (out stateObject))
                {
                    state      = (LiquidContainerState)stateObject;
                    foundState = state != null;
                }

                if (foundState)
                {
                    //hooray it is a liquid
                    if (!state.IsEmpty)
                    {
                        //and it's not empty so steal one
                        state.Contents.InstanceWeight--;
                        result = true;
                        item.SetStateOf <LiquidContainer> (state);
                    }
                }
            }
            else
            {
                Stacks.Pop.AndToss(itemStack);
                result = true;
            }
            return(result);
        }
Esempio n. 14
0
 public WIStack HoldTemporaryItem(WIStack stackToHold)
 {
     //create a temporary item stack if we don't have one
     if (mTemporaryItemEnabler == null)
     {
         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();
         mTemporaryItemEnabler = Stacks.Create.StackEnabler(CharacterInventoryGroup);
         mTemporaryItemEnabler.UseRawContainer = true;
     }
     else
     {
         //drop anything we're holding currently
         DropTemporaryItem();
     }
     return(Stacks.Display.ItemsInContainer(stackToHold, mTemporaryItemEnabler.EnablerContainer));
 }
Esempio n. 15
0
        public static void SetMouseoverItemLabelText(WIStack stack)
        {
            string finalText = string.Empty;

            if (stack != null && stack.HasTopItem)
            {
                string mouseOverLabelText = string.Empty;
                string sizeText           = string.Empty;
                string stackNumberText    = string.Empty;
                Color  labelColor         = Get.MouseoverItemLabel.color;

                mouseOverLabelText = stack.TopItem.DisplayName;
                sizeText           = " (" + stack.TopItem.Size.ToString() + ") ";
                if (stack.NumItems > 1)
                {
                    stackNumberText = stack.NumItems.ToString() + "/" + stack.MaxItems.ToString();
                }

                finalText = mouseOverLabelText + Colors.ColorWrap(sizeText + stackNumberText, Colors.Darken(labelColor));
            }
            Get.MouseoverItemLabel.text = finalText;
        }
Esempio n. 16
0
        public int NumGoodsSent(BarterParty party, WIStack stack)
        {
            List <BarterGoods> goods = null;

            if (party == BarterParty.Player)
            {
                goods = PlayerGoods;
            }
            else
            {
                goods = CharacterGoods;
            }
            int numItems = 0;

            foreach (BarterGoods good in goods)
            {
                if (good.TryGetValue(stack, out numItems))
                {
                    break;
                }
            }
            return(numItems);
        }
Esempio n. 17
0
        protected IEnumerator PushEditObjectToNGUIObjectOverTime()
        {
            //wait a tick - we do this to allow our containers to be built, etc.
            while (PlayerInventoryDisplay == null)
            {
                yield return(null);
            }

            PlayerInventoryDisplay.Session    = mEditObject;
            CharacterInventoryDisplay.Session = mEditObject;
            PlayerGoodsDisplay.Session        = mEditObject;
            CharacterGoodsDisplay.Session     = mEditObject;
            //this will build the squares
            PlayerInventoryDisplay.Refresh();
            CharacterInventoryDisplay.Refresh();
            PlayerGoodsDisplay.Refresh();
            CharacterGoodsDisplay.Refresh();
            //set up the banks so they'll transfer to each other correctly when clicked
            PlayerInventoryBank.SetBank(mEditObject.PlayerInventory.InventoryBank, mEditObject.PlayerGoodsBank);
            CharacterInventoryBank.SetBank(mEditObject.CharacterInventory.InventoryBank, mEditObject.CharacterGoodsBank);
            PlayerGoodsBank.SetBank(mEditObject.PlayerGoodsBank, mEditObject.PlayerInventory.InventoryBank);
            CharacterGoodsBank.SetBank(mEditObject.CharacterGoodsBank, mEditObject.CharacterInventory.InventoryBank);

            while (!PlayerInventoryDisplay.HasCreatedSquares)
            {
                yield return(null);
            }
            //this will automatically refresh everything
            EditObject.Activate();

            PlayerNameLabel.text    = mEditObject.PlayerInventory.InventoryOwnerName;
            CharacterNameLabel.text = mEditObject.CharacterInventory.InventoryOwnerName;
            //BuyDisplay.SetEnabler (mEditObject.BuyEnabler);
            //SellDisplay.SetEnabler (mEditObject.SellEnabler);

            //are we being asked to barter a specific item?

            /*
             *                      if (mEditObject.HasCharacterStartupItem) {
             *                              BarterGoods startupGoods = new BarterGoods ();
             *                              startupGoods.Add (mEditObject.CharacterStartupStack, 1);
             *                              mEditObject.CharacterGoods.Add (startupGoods);
             *                              mEditObject.CurrentCharacterStackEnablerIndex = 0;
             *                              //the next page button will automatically set the goods to 1
             *                              //which is where temporary items are held
             *                      }
             */
            //now find the stack enabler to start with
            bool goToNextCharacterPage = true;

            if (mEditObject.HasCharacterStartupItem)
            {
                bool foundStartupStack = false;
                int  iterations        = 0;
                int  maxIterations     = 100;
                while (!foundStartupStack)
                {
                    OnClickCharacterNextPageButton();
                    while (mWaitingForContainer)
                    {
                        yield return(null);
                    }
                    //check the stack
                    List <WIStack> stacks = mEditObject.CurrentCharacterStackEnabler.EnablerStacks;
                    for (int i = 0; i < stacks.Count; i++)
                    {
                        if (stacks [i] == mEditObject.CharacterStartupStack)
                        {
                            foundStartupStack = true;
                            break;
                        }
                        else
                        {
                            WIStack newStartupStack = null;
                            if (Stacks.Find.Item(mEditObject.CurrentPlayerStackEnabler.EnablerContainer, mEditObject.CharacterStartupItem, out newStartupStack))
                            {
                                mEditObject.CharacterStartupStack = newStartupStack;
                                foundStartupStack = true;
                                break;
                            }
                        }
                    }
                    if (iterations > maxIterations)
                    {
                        Debug.Log("Reached max iterations, breaking");
                        break;
                    }
                }
                if (foundStartupStack)
                {
                    //now put that good in the 'buy' column immediately for convenience
                    mEditObject.AddGoods(mEditObject.CharacterStartupStack, 1, BarterParty.Character);
                    goToNextCharacterPage = false;
                }
            }

            if (goToNextCharacterPage)
            {
                OnClickCharacterNextPageButton();
                while (mWaitingForContainer)
                {
                    yield return(null);
                }
            }
            OnClickPlayerNextPageButton();
            while (mWaitingForContainer)
            {
                yield return(null);
            }
            yield return(null);

            mPushingObjectToNGUIObjectOverTime = false;
            yield break;
        }
Esempio n. 18
0
        public void OnPlayerUseWorldItemSecondary(object secondaryResult)
        {
            WIListResult dialogResult = secondaryResult as WIListResult;

            switch (dialogResult.SecondaryResult)
            {
            case "PourOnSelf":
                MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, "FillLiquidContainer");
                Player.Local.Status.RemoveCondition("BurnedByFire");
                Player.Local.Status.AddCondition("Wet");
                State.Contents.Clear();
                break;

            case "Drink":
                WorldItem liquid = null;
                if (WorldItems.Get.PackPrefab(State.Contents.PackName, State.Contents.PrefabName, out liquid))                                                                  //this is tricky - we want to drink it without destroying the prefab
                {
                    FoodStuff foodstuff = null;
                    if (liquid.Is <FoodStuff>(out foodstuff))                                                                                   //DON'T consume the foodstuff!
                    {
                        FoodStuff.Drink(foodstuff);
                        State.Contents.InstanceWeight--;
                        GUIManager.PostInfo("Drank 1 " + State.Contents.DisplayName + ", " + State.Contents.InstanceWeight.ToString() + "/" + State.Capacity.ToString() + " left.");
                    }
                }
                break;

            case "Pour Out":
                //two options here
                //if we're in the inventory then we want to add our contents to the selected stack
                //if we're in the world we want to dump it into the world
                bool playSound = false;
                if (PrimaryInterface.IsMaximized("Inventory"))
                {
                    WIStack selectedStack = Player.Local.Inventory.SelectedStack;
                    if (Stacks.Can.Stack(selectedStack, State.Contents))
                    {
                        WIStackError error = WIStackError.None;
                        for (int i = 0; i < State.Contents.InstanceWeight; i++)
                        {
                            StackItem contents = State.Contents.ToStackItem();
                            if (!Stacks.Push.Item(selectedStack, contents, ref error))
                            {
                                break;
                            }
                            else
                            {
                                playSound = true;
                            }
                        }
                    }
                }
                else
                {
                    State.Contents.Clear();
                    GUIManager.PostInfo("Discarded contents");
                    if (Player.Local.Surroundings.IsWorldItemInRange)
                    {
                        Flammable flammable = null;
                        if (Player.Local.Surroundings.WorldItemFocus.worlditem.Is <Flammable>(out flammable) && flammable.IsOnFire)
                        {
                            flammable.Extinguish();
                        }
                    }
                    playSound = true;
                }
                if (playSound)
                {
                    MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, "FillLiquidContainer");
                }
                break;

            default:
                break;
            }
        }
Esempio n. 19
0
        public bool AddGoods(WIStack newGoodsStack, int numGoodsToAdd, BarterParty party)
        {
            bool result = false;
            List <BarterGoods> goods = CharacterGoods;

            if (party == BarterParty.Player)
            {
                goods = PlayerGoods;
            }

            int         goodIndex        = 0;
            int         numExistingGoods = 0;
            BarterGoods existingGood     = null;
            BarterGoods emptyGood        = null;
            BarterGoods compatibleGood   = null;

            foreach (BarterGoods good in goods)
            {
                if (good.Count == 0)
                {
                    if (emptyGood == null)
                    {
                        //save our first empty record for later
                        emptyGood = good;
                    }
                }
                else
                {
                    //there's a chance this good already has a record for this stack
                    //if that's the case we can drop it here and end our search
                    if (good.TryGetValue(newGoodsStack, out numExistingGoods))
                    {
                        //hooray, success
                        existingGood = good;
                    }
                    else if (compatibleGood == null)
                    {
                        //okay, it wasn't in the records, but it may still stack
                        //get the top item in this good and see if it stacks with the new item
                        WIStack topRecord = good.Keys.First();
                        if (Stacks.Can.Stack(topRecord, newGoodsStack))
                        {
                            //save our first compatible record for later
                            compatibleGood = good;
                        }
                    }
                }
                goodIndex++;
                //don't break the look if we've found a compatible good
                //because we don't want to lose the chance that we
                //find the existing record entry
            }
            //the only way we've left by now is if we found an exact mach
            //so settle for second and third best here
            if (existingGood != null)
            {
                //we set numExistingGoods when we found the existing good
                //so just add the goods to add and we're set
                existingGood [newGoodsStack] = (numExistingGoods + numGoodsToAdd);
                result = true;
            }
            else if (compatibleGood != null)
            {
                compatibleGood.Add(newGoodsStack, numGoodsToAdd);
                result = true;
            }
            else if (emptyGood != null)
            {
                emptyGood.Add(newGoodsStack, numGoodsToAdd);
                result = true;
            }
            if (result)
            {
                //recaluclate our total values
                RecalculateValueOfGoods(party, true);
                //refresh our squares and interface
                RefreshAction.SafeInvoke();
            }
            return(result);
        }
Esempio n. 20
0
        public override void TryToRemoveItem(IStackOwner skillUseTarget, IWIBase worldItemToMove, IInventory toInventory, Action callBack, int flavor)
        {
            //instead of attempting to remove it now
            //this skill launched the barter dialog
            //and sets up a session
            if (flavor == BuyFlavor)
            {
                int baseCurrencyValue = Mathf.CeilToInt(worldItemToMove.BaseCurrencyValue);
                if (Player.Local.Inventory.InventoryBank.CanAfford(baseCurrencyValue))
                {
                    Player.Local.Inventory.InventoryBank.TryToRemove(baseCurrencyValue);
                    worldItemToMove.Add("OwnedByPlayer");
                    WIStackError error = WIStackError.None;
                    if (!Player.Local.Inventory.AddItems(worldItemToMove, ref error))
                    {
                        Player.Local.ItemPlacement.ItemForceCarry(worldItemToMove.worlditem);
                    }
                    //improve rep with shopkeeper
                    Profile.Get.CurrentGame.Character.Rep.GainPersonalReputation(skillUseTarget.FileName, skillUseTarget.DisplayName, Globals.ReputationChangeTiny);
                    return;
                }
                else
                {
                    GUIManager.PostInfo("You can't afford that.");
                    return;
                }
            }
            else
            {
                IInventory barterInventory = null;
                Character  character       = null;
                //this only works with character-owned items
                if (skillUseTarget.IsWorldItem && skillUseTarget.worlditem.Is <Character> (out character))
                {
                    barterInventory = character;
                    //make sure we can actually barter with the player
                    ReputationState rep = Profile.Get.CurrentGame.Character.Rep.GetReputation(character.worlditem.FileName);
                    if (rep.NormalizedReputationDifference(Profile.Get.CurrentGame.Character.Rep.GlobalReputation) > Extensions.MaxNormaliedReputationDifference)
                    {
                        GUIManager.PostWarning(character.worlditem.DisplayName + " is not interested in bartering with you.");
                        return;
                    }

                    if (mCurrentSession == null)
                    {
                        mCurrentSession = new BarterSession(this, mCharacterGoods, mPlayerGoods);
                    }
                    mCurrentSession.Reset(Player.Local.Inventory, barterInventory);
                    mCurrentSession.BarteringCharacter = character;
                    //add the selected goods to the current session immediately
                    //so it's there when we start bartering
                    mCurrentSession.CharacterStartupItem = worldItemToMove;
                    WIStack startupStack = null;
                    //if the startup item is already in the character's inventory
                    //no need to create a startup stack
                    //but if it isn't we'll need the startup stack to display it
                    if (!character.HasItem(worldItemToMove, out startupStack))
                    {
                        //TODO put entire container in inventory
                        Debug.Log("Item " + worldItemToMove.FileName + " was NOT in character's inventory, creating temporary startup stack");
                        mCurrentSession.CharacterStartupStack = character.HoldTemporaryItem(worldItemToMove);
                    }
                    SpawnBarterDialog();
                }
            }
        }
Esempio n. 21
0
 public override void SetStack(WIStack stack)
 {
     stack.Mode = WIStackMode.Wearable;
     base.SetStack(stack);
 }
Esempio n. 22
0
 public void OnSelectedStackChanged(WIStack stack)
 {
     //Debug.Log ("Selected stack changed - inventory");
 }
 public override void SetStack(WIStack stack)
 {
     return;
 }
Esempio n. 24
0
 public override void SetStack(WIStack stack)
 {
     //wtf are you doing
     return;
 }
        protected InventorySquareWearable CreateWearableSquare(GameObject parentObject, Vector3 squarePosition, WearableType type, BodyPartType bodyPart, BodyOrientation orientation, WIStack stack)
        {
            //Debug.Log("Creating wearable square: " + type.ToString() + ", " + bodyPart.ToString() + ", " + orientation.ToString());

            GameObject inventorySquareGameObject = NGUITools.AddChild(parentObject, GUIManager.Get.InventorySquareWearable);
            InventorySquareWearable square       = inventorySquareGameObject.GetComponent <InventorySquareWearable>();

            square.BodyPart                = bodyPart;
            square.Orientation             = orientation;
            square.Type                    = type;
            square.transform.localPosition = squarePosition;
            square.SetStack(stack);

            Squares.Add(square);

            stack.RefreshAction += Refresh;

            return(square);
        }
Esempio n. 26
0
        public virtual void OnClickSquare()
        {
            if (!IsEnabled || !HasStack)
            {
                return;
            }
            if (InterfaceActionManager.LastMouseClick == 1)
            {
                OnRightClickSquare();
                return;
            }

            WIStackError error      = WIStackError.None;
            bool         playSound  = false;
            bool         splitStack = false;
            bool         quickAdd   = false;
            string       soundName  = "InventoryPlaceStack";
            //skill usage
            bool useSkillToRemove = false;

            //left clicking can pick up, split, or quick-add
            if (InterfaceActionManager.Get.IsKeyDown(InterfaceActionType.StackSplit))
            {
                splitStack = true;
            }                                    /* else if (AllowShiftClick && InterfaceActionManager.Get.IsKeyDown (InterfaceActionType.StackQuickAdd)) {
                                                  *             quickAdd = true;
                                                  * }*/

            mRemoveItemSkillNames.Clear();

            if (mStack.HasOwner(out mSkillUseTarget))
            {
                //SKILL USE
                if (mSkillUseTarget.UseRemoveItemSkill(mRemoveItemSkillNames, ref mSkillUseTarget))
                {
                    useSkillToRemove = true;
                    quickAdd         = false;
                }
            }

            WIStack selectedStack = Player.Local.Inventory.SelectedStack;

            if (mStack.HasTopItem)
            {
                //if our stack has items
                if (selectedStack.HasTopItem)
                {
                    //and the selected stack ALSO has items
                    //------Special cases------//
                    //LIQUID CONTAINER CHECK - can we put the thing we're holding into the thing we've clicked?
                    if (FillLiquidContainer(mStack.TopItem, selectedStack.TopItem, selectedStack))
                    {
                        playSound = true;
                        soundName = "FillLiquidContainer";
                    }
                    else if (Stacks.Can.Stack(mStack.TopItem, selectedStack.TopItem))
                    {
                        //if the selected stack's items can stack with our stack's items,
                        //then we're putting items IN the stack
                        //this is only allowed if the stack isn't owned
                        if (useSkillToRemove)
                        {
                            //play an error and get out
                            MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, SoundNameFailure);
                            return;
                        }
                        else
                        {
                            //otherwise try to add the items normally
                            playSound = Stacks.Add.Items(selectedStack, mStack, ref error);
                        }
                    }
                    else
                    {
                        //if the selected stack's items can't be stacked
                        //then we're swapping the stack
                        //ie, we're removing items FROM the stack
                        //this is only allowed if the stack isn't owned
                        if (useSkillToRemove)
                        {
                            //so play an error and get out
                            MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, SoundNameFailure);
                            return;
                        }
                        else
                        {
                            //otherwise try to swap stacks normally
                            playSound = Stacks.Swap.Stacks(mStack, selectedStack, ref error);
                        }
                    }
                }
                else
                {
                    //----SHIFT CLICK CHECK----//
                    //check for shift click - this bypasses everything and adds the item to the player's inventory
                    //this only works if the stack does not already belong to the player's group
                    if (quickAdd)
                    {
                        //Debug.Log ("Starting quick add..");
                        if (Player.Local.Inventory.CanItemFit(mStack.TopItem))
                        {
                            if (Player.Local.Inventory.QuickAddItems(mStack, ref error))
                            {
                                soundName = "InventoryPickUpStack";
                                playSound = true;
                            }
                        }
                        else
                        {
                            GUIManager.PostWarning(mStack.TopItem.DisplayName + " won't fit in your inventory");
                        }
                    }
                    else
                    {
                        //if the selected stack does NOT have any items
                        //we're putting items IN the stack
                        if (splitStack && mStack.NumItems > 1)
                        {
                            //we're splitting the stack and adding the contents to the selected stack
                            //this is only allowed if the stack isn't owned
                            if (useSkillToRemove)
                            {
                                //play an error and get out
                                MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, SoundNameFailure);
                                return;
                            }
                            int  numToAdd  = mStack.NumItems / 2;
                            bool addResult = true;
                            //IWIBase topItem = null;
                            for (int i = 0; i < numToAdd; i++)
                            {
                                if (!Stacks.Pop.AndPush(mStack, selectedStack, ref error))
                                {
                                    addResult = false;
                                    break;
                                }
                            }
                            playSound = addResult;
                        }
                        else
                        {
                            //if we're not splitting stacks
                            //THIS is where we finally REMOVE items from this stack using a skill
                            if (useSkillToRemove)
                            {
                                UseSkillsToRemoveStack();
                                return;
                            }
                            else if (Stacks.Add.Items(mStack, selectedStack, ref error))
                            {
                                playSound = true;
                                soundName = "InventoryPickUpStack";
                            }
                        }
                    }
                }
            }
            else if (selectedStack.HasTopItem)
            {
                //if our stack does NOT have items
                //we're adding items TO our stack
                //this is only allowed if the stack isn't owned
                if (useSkillToRemove)
                {
                    //so play an error and get out
                    MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, SoundNameFailure);
                    return;
                }
                else if (Stacks.Add.Items(selectedStack, mStack, ref error))
                {
                    //otherwise try to add the items and get out
                    playSound = true;
                }
            }

            if (error != WIStackError.None)
            {
                GUIManager.PostStackError(error);
            }

            if (playSound)
            {
                MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, soundName);
            }

            UpdateDisplay();
        }
Esempio n. 27
0
 public bool     AddItems(WIStack stack, int numToAdd, ref int numAdded)
 {
     return(false);
 }
Esempio n. 28
0
 public void OnStackContainerChange(WIStack itemStack)
 {
     //Debug.Log ("stack container changed in world item inventory for " + name);
 }