示例#1
0
        public override void PopulateOptionsList(System.Collections.Generic.List <GUIListOption> options, List <string> message)
        {
            if (mGenericLiquid == null)
            {
                if (!WorldItems.GetRandomGenericWorldItemFromCatgeory(State.LiquidCategory, out mGenericLiquid))
                {
                    return;
                }
            }

            mOptionsListItems.Clear();
            LiquidContainer liquidContainer = null;

            if (Player.Local.Tool.IsEquipped && Player.Local.Tool.worlditem.Is <LiquidContainer>(out liquidContainer))
            {
                options.Add(new GUIListOption("Fill " + liquidContainer.worlditem.DisplayName, "Fill"));
            }
//			Dictionary <int,IWIBase> QuickslotItems = Player.Local.Inventory.QuickslotItems;
//			foreach (KeyValuePair <int,IWIBase> quickslotItem in QuickslotItems) {
//				IWIBase qsItem = quickslotItem.Value;
//				//foreach liquid container in quickslots
//				if (qsItem.Is <LiquidContainer> () && qsItem.IsWorldItem) {
//					//TODO make sure we can actually fill the item
//					options.Add (new GUIListOption ("Fill " + qsItem.DisplayName, qsItem.FileName));
//					mOptionsListItems.Add (qsItem.FileName, qsItem);
//				}
//			}

            options.Add(new GUIListOption("Drink " + mGenericLiquid.DisplayName, "Drink"));
        }
示例#2
0
        public void OnPlayerUseWorldItemSecondary(object secondaryResult)
        {
            OptionsListDialogResult dialogResult = secondaryResult as OptionsListDialogResult;

            if (dialogResult.SecondaryResult.Contains("Drink"))
            {
                WorldItem worlditem = null;
                if (WorldItems.Get.PackPrefab(mGenericLiquid.PackName, mGenericLiquid.PrefabName, out worlditem))
                {
                    FoodStuff foodStuff = null;
                    if (worlditem.gameObject.HasComponent <FoodStuff>(out foodStuff))
                    {
                        FoodStuff.Drink(foodStuff);
                    }
                }
            }
            else
            {
                LiquidContainer liquidContainer = null;
                if (Player.Local.Tool.IsEquipped && Player.Local.Tool.worlditem.Is <LiquidContainer>(out liquidContainer))
                {
                    LiquidContainerState liquidContainerState = liquidContainer.State;
                    int    numFilled    = 0;
                    string errorMessage = string.Empty;
                    if (liquidContainerState.TryToFillWith(mGenericLiquid, Int32.MaxValue, out numFilled, out errorMessage))
                    {
                        GUIManager.PostInfo("Filled " + liquidContainer.worlditem.DisplayName + " with " + numFilled.ToString() + " " + mGenericLiquid.PrefabName + "(s)");
                        MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, "FillLiquidContainer");
                    }
                }
//				IWIBase qsItem = null;
//				if (mOptionsListItems.TryGetValue (dialogResult.SecondaryResult, out qsItem)) {
//					System.Object liquidContainerStateObject = null;
//					if (qsItem.GetStateOf <LiquidContainer> (out liquidContainerStateObject)) {
//						LiquidContainerState liquidContainerState = liquidContainerStateObject as LiquidContainerState;
//						if (liquidContainerState != null) {
//							int numFilled = 0;
//							string errorMessage = string.Empty;
//							if (liquidContainerState.TryToFillWith (mGenericLiquid, Int32.MaxValue, out numFilled, out errorMessage)) {
//								GUIManager.PostInfo ("Filled " + qsItem.DisplayName + " with " + numFilled.ToString () + " " + mGenericLiquid.PrefabName + "(s)");
//								MasterAudio.PlaySound (MasterAudio.SoundType.PlayerInterface, "FillLiquidContainer");
//							}
//						}
//					}
//				}
            }
            mOptionsListItems.Clear();
        }
示例#3
0
        public void OnPlayerUseWorldItemSecondary(object secondaryResult)
        {
            WIListResult dialogResult = secondaryResult as WIListResult;

            switch (dialogResult.SecondaryResult)
            {
            case "Drink":
                if (!CanBuyDrink)
                {
                    if (gBartenderSpeech == null)
                    {
                        gBartenderSpeech = new Speech();
                    }
                    gBartenderSpeech.Text = "That's enough for one night, {lad/lass}.";
                    worlditem.Get <Talkative>().SayDTS(gBartenderSpeech);
                }
                else
                {
                    if (Player.Local.Inventory.InventoryBank.TryToRemove(PricePerDrink))
                    {
                        Profile.Get.CurrentGame.Character.Rep.GainGlobalReputation(1);
                        //spawn a cup and put some mead in it
                        WorldItem cup = null;
                        if (WorldItems.CloneRandomFromCategory("BartenderCups", WIGroups.Get.World, out cup))
                        {
                            cup.Initialize();
                            LiquidContainer container = null;
                            if (cup.Is <LiquidContainer>(out container))
                            {
                                container.State.Contents.CopyFrom(BartenderDrinkContents);
                                container.State.Contents.InstanceWeight = container.State.Capacity;
                            }
                            //try to equip it in the player's hands
                            Player.Local.Inventory.TryToEquip(cup);
                        }
                        State.NumTimesBoughtDrink++;
                        State.NumTimesBoughtDrinkTonight++;
                        State.LastTimeBoughtDrink = WorldClock.AdjustedRealTime;
                    }
                }
                break;

            case "Round":
                if (Player.Local.Inventory.InventoryBank.TryToRemove(PricePerRound))
                {
                    if (gBartenderSpeech == null)
                    {
                        gBartenderSpeech = new Speech();
                    }
                    gBartenderSpeech.Text = "Looks like this round's on {PlayerFirstName}!";
                    worlditem.Get <Talkative>().SayDTS(gBartenderSpeech);
                    Profile.Get.CurrentGame.Character.Rep.GainGlobalReputation(5);
                    State.NumTimesBoughtRound++;
                    State.LastTimeBoughtRound = WorldClock.AdjustedRealTime;
                }
                break;

            default:
                break;
            }
        }