void HideCurrentMenuUI(ShopState state) { ClearShopInfo(); audioManager.PlayTabChange(); switch (state) { case ShopState.StatsMenu: { HideStatsUI(); break; } case ShopState.ShopMenu: { HideShopUI(); break; } case ShopState.UpgradesMenu: { HideUpgradesUI(); break; } case ShopState.AbilitiesMenu: { HideAbilitiesUI(); break; } } }
public override void Cancel() { switch (state) { case ShopState.JanlSelect: state = ShopState.Menu; trade = TradeState.None; break; case ShopState.GoodsSelect: if (trade == TradeState.Buy) { state = ShopState.JanlSelect; nowJanl = null; } else { state = ShopState.Menu; } break; case ShopState.ValueSelect: state = ShopState.GoodsSelect; shopValue = 1; GoodsValueChange(0); break; default: break; } ObjectActive(state); }
public Game1() { _graphics = new GraphicsDeviceManager(this); ScreenRectangle = new Rectangle( 0, 0, ScreenWidth, ScreenHeight); IsMouseVisible = true; Content.RootDirectory = "Content"; Components.Add(new InputHandler(this)); _gameStateManager = new GameStateManager(this); Components.Add(_gameStateManager); _ = new TextureManager(); TitleScreen = new TitleScreen(this, _gameStateManager); StartMenuScreen = new StartMenuScreen(this, _gameStateManager); GamePlayScreen = new GamePlayScreen(this, _gameStateManager); CharacterGeneratorScreen = new CharacterGeneratorScreen(this, _gameStateManager); SkillScreen = new SkillScreen(this, _gameStateManager); LoadGameScreen = new LoadGameScreen(this, _gameStateManager); ConversationScreen = new ConversationScreen(this, _gameStateManager); ShopScreen = new ShopState(this, _gameStateManager); InventoryScreen = new InventoryScreen(this, _gameStateManager); _gameStateManager.ChangeState(TitleScreen); IsFixedTimeStep = false; _graphics.SynchronizeWithVerticalRetrace = false; }
private ShopDialog(PacketAPI api, int id) : base(api) { Buttons = ScrollingListDialogButtons.Cancel; ListItemType = ListDialogItem.ListItemStyle.Large; ID = id; DialogClosing += (o, e) => { if (e.Result == XNADialogResult.Cancel) { Instance = null; ID = 0; } else if (e.Result == XNADialogResult.Back) { e.CancelClose = true; _setState(ShopState.Initial); } }; m_state = ShopState.None; //note - may need to lock around these. //other note - no good way to dispose static textures like this if (BuyIcon == null || SellIcon == null || CraftIcon == null) { BuyIcon = _getDlgIcon(ListIcon.Buy); SellIcon = _getDlgIcon(ListIcon.Sell); CraftIcon = _getDlgIcon(ListIcon.Craft); } }
public void Execute(ItemType itemType, string guid, bool contain) { var avatarState = _initialState.GetAvatarState(_avatarAddress); INonFungibleItem nonFungibleItem; Guid itemId = new Guid(guid); Guid productId = itemId; ItemSubType itemSubType; const long requiredBlockIndex = 0; ShopState legacyShopState = _initialState.GetShopState(); if (itemType == ItemType.Equipment) { var itemUsable = ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, itemId, requiredBlockIndex); nonFungibleItem = itemUsable; itemSubType = itemUsable.ItemSubType; } else { var costume = ItemFactory.CreateCostume(_tableSheets.CostumeItemSheet.First, itemId); costume.Update(requiredBlockIndex); nonFungibleItem = costume; itemSubType = costume.ItemSubType; } var result = new DailyReward2.DailyRewardResult() { id = default,
public void TryGet() { var shopState = new ShopState(); var agentAddress = new PrivateKey().ToAddress(); var avatarAddress = new PrivateKey().ToAddress(); var productId = Guid.NewGuid(); var weaponRow = new EquipmentItemSheet.Row(); weaponRow.Set(new[] { "10100000", "Weapon", "0", "Normal", "0", "ATK", "1", "2", "10100000", }); var itemUsable = new Weapon( weaponRow, Guid.NewGuid(), 0); var price = new FungibleAssetValue(new Currency("NCG", 2, minter: null)); var shopItem = new ShopItem( agentAddress, avatarAddress, productId, price, itemUsable); shopState.Register(shopItem); Assert.True(shopState.TryGet(agentAddress, shopItem.ProductId, out var outShopItem)); Assert.Equal(shopItem, outShopItem); shopState.Unregister(shopItem); Assert.False(shopState.TryGet(agentAddress, shopItem.ProductId, out _)); }
public void Register() { var shopState = new ShopState(); var agentAddress = new PrivateKey().ToAddress(); var avatarAddress = new PrivateKey().ToAddress(); var productId = Guid.NewGuid(); var weaponRow = new EquipmentItemSheet.Row(); weaponRow.Set(new[] { "10100000", "Weapon", "0", "Normal", "0", "ATK", "1", "2", "10100000", }); var itemUsable = new Weapon( weaponRow, Guid.NewGuid(), 0); var price = new FungibleAssetValue(new Currency("NCG", 2, minter: null)); var shopItem = new ShopItem( agentAddress, avatarAddress, productId, price, itemUsable); shopState.Register(shopItem); Assert.Equal(1, shopState.Products.Count); Assert.Contains(productId, shopState.Products); Assert.Equal(shopItem, shopState.Products[productId]); }
public void Restock(Item item) { if (State == ShopState.WithItem) { RemoveItemAndClose(); } ActiveItem = item; CurrentPrice = item.Cost; State = ShopState.WithItem; Text.text = CurrentPrice.ToString(); if (ActiveItem != null && ActiveItem.Prefab != null) { _itemObject = GameObject.Instantiate( ActiveItem.Prefab, PlaceTransform, false); } if (RestockEffect != null) { GameObject.Instantiate(RestockEffect, PlaceTransform.position, Quaternion.identity); } }
public void RegisterThrowShopStateAlreadyContainsException() { var shopState = new ShopState(); var agentAddress = new PrivateKey().ToAddress(); var avatarAddress = new PrivateKey().ToAddress(); var productId = Guid.NewGuid(); var weaponRow = new EquipmentItemSheet.Row(); weaponRow.Set(new[] { "10100000", "Weapon", "0", "Normal", "0", "ATK", "1", "2", "10100000", }); var itemUsable = new Weapon( weaponRow, Guid.NewGuid(), 0); var price = new FungibleAssetValue(new Currency("NCG", 2, minter: null)); var shopItem = new ShopItem( agentAddress, avatarAddress, productId, price, itemUsable); shopState.Register(shopItem); Assert.Throws <ShopStateAlreadyContainsException>(() => shopState.Register(shopItem)); }
private void OnStateChanged(int state) { //only state change is leaving the scene, in all cases Save() after Shopping. fileUtility.Save(); _goldText.text = fileUtility.SaveObject.gold.ToString(); ShopState enumState = (ShopState)state; switch (enumState) { case ShopState.Shop: Debug.Log("Load Shop Deals"); _shopFunction.RandomizeShop(); break; case ShopState.Crafting: SceneManager.LoadScene("CraftingTable"); break; case ShopState.Journal: SceneManager.LoadScene("Journal"); break; default: Debug.Log("State Not Yet Implemented"); break; } }
public async Task Query() { const string query = @"{ address products { sellerAgentAddress sellerAvatarAddress price itemUsable { itemId itemType itemSubType } costume { itemId itemType itemSubType } } }"; var shopState = new ShopState(); var queryResult = await ExecuteQueryAsync <ShopStateType>(query, source : shopState); Assert.Equal( new Dictionary <string, object> { ["address"] = Addresses.Shop.ToString(), ["products"] = new List <object>() }, queryResult.Data ); }
public void OpenShop() { Console.WriteLine("Магазин открылся"); this.ShopState = ShopState.Open; managerThread.Start(); while (this.ShopState == ShopState.Open) { Thread.Sleep(new Random().Next(500, 800)); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Появился новый покупатель"); Console.ForegroundColor = ConsoleColor.White; if (this.RizeNewVisitor != null) { while (this.manager.CurrentBuyer != null) { Thread.Sleep(75); } this.RizeNewVisitor(this, new Buyer(++newBuyerId)); } } }
void manager_FinishedWork(object sender, ManagerState managerState) { if (managerState == ManagerState.NotWork) { this.ShopState = ShopState.Closed; } }
private static string GetGenericReply(ShopState state) { return(state switch { ShopState.Enter => Vendor.EnterGeneric, ShopState.Buy => Vendor.BuyGeneric, ShopState.BuyDeny => Vendor.BuyDenyGeneric, ShopState.BuyEmpty => Vendor.BuyEmptyGeneric, ShopState.BuyFail => Vendor.BuyFailGeneric, ShopState.BuyLimit => Vendor.BuyLimitGeneric, ShopState.SellNotAllowed => Vendor.SellNotAllowedGeneric, ShopState.SellNotOwned => Vendor.SellNotOwnedGeneric, ShopState.SellInvalid => Vendor.SellInvalidGeneric, ShopState.BuyInvalid => Vendor.BuyInvalidGeneric, ShopState.ViewBuy => Vendor.ViewBuyGeneric, ShopState.Sell => Vendor.SellGeneric, ShopState.ViewSell => Vendor.ViewSellGeneric, ShopState.SellDeny => Vendor.SellDenyGeneric, ShopState.SellEmpty => Vendor.SellEmptyGeneric, ShopState.Exit => Vendor.ExitGeneric, ShopState.Timeout => Vendor.TimeoutGeneric, ShopState.Menu => Vendor.MenuGeneric, ShopState.BuyRemainder => Arcadia.Vendor.BuyRemainderGeneric, _ => throw new ArgumentOutOfRangeException(nameof(state), state, null) });
public void NextDay() { money -= ShopInventory.ShopRent; BuyQueue = new List <GameObject>(); if (money < 0f) { if (DaysInRedNumbers >= DaysInRedNumbersToClose) //close shop { shopState = ShopState.CLOSED; gameObject.SetActive(false); WorldState.instance.activeSalesman--; Debug.Log("ME HE ARRUINADO " + gameObject.name); } else { DaysInRedNumbers++; } } else { if (DaysInRedNumbers > 0) { DaysInRedNumbers = 0; } money = salesmanBehaviour.ResupplyShop(money, ref ShopInventory, characterName); } WorldState.instance.hud.UpdateInventoryAndMoneyHud(); }
public void Unregister() { var shopState = new ShopState(); var agentAddress = new PrivateKey().ToAddress(); var avatarAddress = new PrivateKey().ToAddress(); var productId = Guid.NewGuid(); var weaponRow = new EquipmentItemSheet.Row(); weaponRow.Set(new[] { "10100000", "Weapon", "0", "Normal", "0", "ATK", "1", "2", "10100000", }); var itemUsable = new Weapon( weaponRow, Guid.NewGuid(), 0); var price = new FungibleAssetValue(new Currency("NCG", 2, minter: null)); var shopItem = new ShopItem( agentAddress, avatarAddress, productId, itemUsable, price ); shopState.Register(shopItem); shopState.Unregister(agentAddress, shopItem); Assert.Equal(0, shopState.Products.Count); Assert.Equal(0, shopState.AgentProducts.Count); Assert.Equal(0, shopState.ItemSubTypeProducts.Count); Assert.Throws <FailedToUnregisterInShopStateException>(() => shopState.Unregister(agentAddress, shopItem)); }
public async Task StartAsync(IDialogContext context) { await context.PostAsync("Hello! I am shoe bot. I will help you select shoes. You can always say help to get help, or menu for main menu."); State = ShopState.Start; context.Wait(MessageReceivedAsync); }
public static ShopState ShopStateFX() { var shopState = new ShopState(); for (var index = 0; index < TableSheetsFX.EquipmentItemSheet.OrderedList.Count; index++) { var row = TableSheetsFX.EquipmentItemSheet.OrderedList[index]; var equipment = ItemFactory.CreateItemUsable(row, default, 0);
public void VerifyShopIsPermanentlyClosed() { if (!(ShopState.Equals(Shop.ShopStateEnum.PermanentlyClosed))) { StackTrace stackTrace = new StackTrace(); throw new ShopStateException($"Shop {ShopName} is not closed or active. Cant complete method {stackTrace.GetFrame(1).GetMethod().Name}"); } }
public void VerifyShopIsActive() { if (!ShopState.Equals(Shop.ShopStateEnum.Active)) { StackTrace stackTrace = new StackTrace(); throw new ShopStateException($"Shop {ShopName} is not active. Cant complete method {stackTrace.GetFrame(1).GetMethod().Name}"); } }
public void CloseShop() { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Магазин закрыл двери на вход"); Console.ForegroundColor = ConsoleColor.White; this.ShopState = ShopState.Closing; this.manager.EndToWork(); }
public SellCancellation2Test(ITestOutputHelper outputHelper) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.TestOutput(outputHelper) .CreateLogger(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var(key, value) in sheets) { _initialState = _initialState .SetState(Addresses.TableSheet.Derive(key), value.Serialize()); } var tableSheets = new TableSheets(sheets); var currency = new Currency("NCG", 2, minters: null); var goldCurrencyState = new GoldCurrencyState(currency); _agentAddress = new PrivateKey().ToAddress(); var agentState = new AgentState(_agentAddress); _avatarAddress = new PrivateKey().ToAddress(); var rankingMapAddress = new PrivateKey().ToAddress(); var avatarState = new AvatarState( _avatarAddress, _agentAddress, 0, tableSheets.GetAvatarSheets(), new GameConfigState(), rankingMapAddress) { worldInformation = new WorldInformation( 0, tableSheets.WorldSheet, GameConfig.RequireClearedStageLevel.ActionsInShop), }; agentState.avatarAddresses[0] = _avatarAddress; var equipment = ItemFactory.CreateItemUsable( tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); var shopState = new ShopState(); shopState.Register(new ShopItem( _agentAddress, _avatarAddress, Guid.NewGuid(), new FungibleAssetValue(goldCurrencyState.Currency, 100, 0), equipment)); var result = new CombinationConsumable.ResultModel() { id = default,
public Sell0Test(ITestOutputHelper outputHelper) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.TestOutput(outputHelper) .CreateLogger(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var(key, value) in sheets) { _initialState = _initialState .SetState(Addresses.TableSheet.Derive(key), value.Serialize()); } _tableSheets = new TableSheets(sheets); _currency = new Currency("NCG", 2, minters: null); var goldCurrencyState = new GoldCurrencyState(_currency); var shopState = new ShopState(); _agentAddress = new PrivateKey().ToAddress(); var agentState = new AgentState(_agentAddress); _avatarAddress = new PrivateKey().ToAddress(); var rankingMapAddress = new PrivateKey().ToAddress(); _avatarState = new AvatarState( _avatarAddress, _agentAddress, 0, _tableSheets.GetAvatarSheets(), new GameConfigState(), rankingMapAddress) { worldInformation = new WorldInformation( 0, _tableSheets.WorldSheet, GameConfig.RequireClearedStageLevel.ActionsInShop), }; agentState.avatarAddresses[0] = _avatarAddress; var equipment = ItemFactory.CreateItemUsable( _tableSheets.EquipmentItemSheet.First, Guid.NewGuid(), 0); _avatarState.inventory.AddItem2(equipment); _initialState = _initialState .SetState(GoldCurrencyState.Address, goldCurrencyState.Serialize()) .SetState(Addresses.Shop, shopState.Serialize()) .SetState(_agentAddress, agentState.Serialize()) .SetState(_avatarAddress, _avatarState.Serialize()); }
public Shop(Texture2D arrowImg, int windowWidth, int windowHeight, GraphicsDevice graphics, List <Material> items, Dictionary <Material, int> costs, SpriteFont mediumFont, SpriteFont smallFont, BuyItem buy, List <CannonSettings> cannons, Dictionary <CannonSettings, int> cannonCosts, Action <CannonSettings, int> buyCannon, Action <CannonSettings> selectCannon, Dictionary <GiftType, int> giftCosts, Action <GiftType, int> buyGift, Texture2D materialIcon, Texture2D cannonIcon, Texture2D giftIcon) { this.windowWidth = windowWidth; this.windowHeight = windowHeight; this.buy = buy; this.selectCannon = selectCannon; mInfoHover = new MaterialInfoHover(Material.Stone, smallFont, graphics, windowWidth); cInfoHover = new CannonInfoHover(CannonSettings.NormalCannon, smallFont, graphics, windowWidth); nextButton = new MenuButton(NextPage, SPACING, 0, true, graphics, arrowImg); nextButton.X = windowWidth - nextButton.Width - SPACING; nextButton.Y = windowHeight - nextButton.Height - SPACING; prevButton = new MenuButton(PrevPage, SPACING, nextButton.Y, true, graphics, arrowImg); for (int i = 0; i < items.Count; i++) { materialInterfaces.Add(new ShopMaterialInterface(Buy, 0, 0, SHOPINT_WIDTH, SHOPINT_HEIGHT, mediumFont, costs[items[i]], graphics, items[i], windowWidth)); } UpdatePagesToInterfaces(); X_OFFSET = windowWidth / 2 - (((SHOPINT_WIDTH * ITEMS_PER_ROW) + (SPACING * (ITEMS_PER_ROW - 1))) / 2); cannonButton = new MenuButton(new System.Action(() => state = ShopState.Cannons), 0, 0, true, graphics, cannonIcon); cannonButton.X = windowWidth / 2 - cannonButton.Width / 2; cannonButton.Y = windowHeight - cannonButton.Height - SPACING; materialButton = new MenuButton(new System.Action(() => state = ShopState.Materials), 0, cannonButton.Y, true, graphics, materialIcon); materialButton.ImgWidth = cannonButton.ImgWidth; materialButton.ImgHeight = cannonButton.ImgHeight; materialButton.X = cannonButton.X - materialButton.Width - SPACING; giftsButton = new MenuButton(new System.Action(() => state = ShopState.Gifts), cannonButton.X + cannonButton.Width + SPACING, cannonButton.Y, true, graphics, giftIcon); for (int i = 0; i < cannons.Count; i++) { cannonInterfaces.Add(new ShopCannonInterface(cannons[i], mediumFont, cannonCosts[cannons[i]], buyCannon, SelectCannon, false, graphics, 0, 0, SHOPINT_WIDTH, SHOPINT_HEIGHT)); } foreach (KeyValuePair <GiftType, int> kv in giftCosts) { giftInterfaces.Add(new ShopGiftInterface(kv.Key, graphics, mediumFont, 0, 0, SHOPINT_WIDTH, SHOPINT_HEIGHT, kv.Value, buyGift)); } UpdateGiftPositions(); }
//private Dictionary<int, float> npcsRelationships; private void Awake() { ShopInventory = GetComponent <ShopInventory>(); personality = GetComponent <Personality>(); salesmanBehaviour = GetComponent <SalesmanBehaviour>(); shopState = ShopState.OPEN; BuyQueue = new List <GameObject>(); //npcsRelationships = new Dictionary<int, float>(); }
public void RemoveItemAndClose() { ActiveItem = null; State = ShopState.Sold; if (_itemObject != null) { Destroy(_itemObject); } Text.text = string.Empty; }
public Shop() { this.newBuyerId = 0; this.ShopState = ShopState.Closed; this.manager = new Manager(this); this.manager.FinishedWork += new FinishedWorkManager(manager_FinishedWork); this.ShopState = ShopState.Closed; this.managerThread = new Thread(this.manager.StartToWork); managerThread.Name = "managerThread"; }
private void Awake() { Debug.Log("Awake"); StateMachine = new StateMachine(); playing = new PlayingState(); paused = new PausedState(); shop = new ShopState(); }
public BuyMultipleTest(ITestOutputHelper outputHelper) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.TestOutput(outputHelper) .CreateLogger(); _initialState = new State(); var sheets = TableSheetsImporter.ImportSheets(); foreach (var(key, value) in sheets) { _initialState = _initialState .SetState(Addresses.TableSheet.Derive(key), value.Serialize()); } _tableSheets = new TableSheets(sheets); var currency = new Currency("NCG", 2, minters: null); _goldCurrencyState = new GoldCurrencyState(currency); _sellerAgentStateMap = new Dictionary <AvatarState, AgentState>(); _buyerAgentAddress = new PrivateKey().ToAddress(); var buyerAgentState = new AgentState(_buyerAgentAddress); _buyerAvatarAddress = new PrivateKey().ToAddress(); var rankingMapAddress = new PrivateKey().ToAddress(); _buyerAvatarState = new AvatarState( _buyerAvatarAddress, _buyerAgentAddress, 0, _tableSheets.GetAvatarSheets(), new GameConfigState(), rankingMapAddress) { worldInformation = new WorldInformation( 0, _tableSheets.WorldSheet, GameConfig.RequireClearedStageLevel.ActionsInShop), }; buyerAgentState.avatarAddresses[0] = _buyerAvatarAddress; var shopState = new ShopState(); _initialState = _initialState .SetState(GoldCurrencyState.Address, _goldCurrencyState.Serialize()) .SetState(Addresses.Shop, shopState.Serialize()) .SetState(_buyerAgentAddress, buyerAgentState.Serialize()) .SetState(_buyerAvatarAddress, _buyerAvatarState.Serialize()) .MintAsset(_buyerAgentAddress, _goldCurrencyState.Currency * 100); }
/// <summary> /// 샵 상태를 할당한다. /// </summary> /// <param name="state"></param> public void SetShopState(ShopState state) { if (state is null) { Debug.LogWarning($"[{nameof(States)}.{nameof(SetShopState)}] {nameof(state)} is null."); return; } ShopState = state; ReactiveShopState.Initialize(ShopState); }
void Start () { state = ShopState.NONE; shopInventory = GetComponent<Inventory> (); itemDB = (ItemDatabase)GameObject.Find ("ItemDatabase").GetComponent<ItemDatabase> (); shopInventory.AddItem (ItemIDs.RADISH_SEEDS, INFINITE); shopInventory.AddItem (ItemIDs.ONION_SEEDS, INFINITE); shopInventory.AddItem (ItemIDs.POTATO_SEEDS, INFINITE); shopInventory.AddItem (ItemIDs.TOMATO_SEEDS, INFINITE); shopInventory.AddItem (ItemIDs.BEAN_SEEDS, INFINITE); scrollPos = Vector2.zero; ResetItemData (); }
private void _setState(ShopState newState) { ShopState old = m_state; if (old == newState) return; int buyNumInt = m_tradeItems.FindAll(x => x.Buy > 0).Count; int sellNumInt = m_tradeItems.FindAll(x => World.Instance.MainPlayer.ActiveCharacter.Inventory.FindIndex(item => item.id == x.ID) >= 0 && x.Sell > 0).Count; if (newState == ShopState.Buying && buyNumInt <= 0) { EOMessageBox.Show(DATCONST1.SHOP_NOTHING_IS_FOR_SALE, XNADialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); return; } if (newState == ShopState.Selling && sellNumInt <= 0) { EOMessageBox.Show(DATCONST1.SHOP_NOT_BUYING_YOUR_ITEMS, XNADialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); return; } ClearItemList(); switch (newState) { case ShopState.Initial: { string buyNum = string.Format("{0} {1}", m_tradeItems.FindAll(x => x.Buy > 0).Count, World.GetString(DATCONST2.DIALOG_SHOP_ITEMS_IN_STORE)); string sellNum = string.Format("{0} {1}", sellNumInt, World.GetString(DATCONST2.DIALOG_SHOP_ITEMS_ACCEPTED)); string craftNum = string.Format("{0} {1}", m_craftItems.Count, World.GetString(DATCONST2.DIALOG_SHOP_ITEMS_ACCEPTED)); ListDialogItem buy = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0) { Text = World.GetString(DATCONST2.DIALOG_SHOP_BUY_ITEMS), SubText = buyNum, IconGraphic = BuyIcon, OffsetY = 45 }; buy.OnLeftClick += (o, e) => _setState(ShopState.Buying); buy.OnRightClick += (o, e) => _setState(ShopState.Buying); buy.ShowItemBackGround = false; AddItemToList(buy, false); ListDialogItem sell = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 1) { Text = World.GetString(DATCONST2.DIALOG_SHOP_SELL_ITEMS), SubText = sellNum, IconGraphic = SellIcon, OffsetY = 45 }; sell.OnLeftClick += (o, e) => _setState(ShopState.Selling); sell.OnRightClick += (o, e) => _setState(ShopState.Selling); sell.ShowItemBackGround = false; AddItemToList(sell, false); if (m_craftItems.Count > 0) { ListDialogItem craft = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 2) { Text = World.GetString(DATCONST2.DIALOG_SHOP_CRAFT_ITEMS), SubText = craftNum, IconGraphic = CraftIcon, OffsetY = 45 }; craft.OnLeftClick += (o, e) => _setState(ShopState.Crafting); craft.OnRightClick += (o, e) => _setState(ShopState.Crafting); craft.ShowItemBackGround = false; AddItemToList(craft, false); } _setButtons(ScrollingListDialogButtons.Cancel); } break; case ShopState.Buying: case ShopState.Selling: { //re-use the logic for Buying/Selling: it is almost identical bool buying = newState == ShopState.Buying; List<ListDialogItem> itemList = new List<ListDialogItem>(); foreach (ShopItem si in m_tradeItems) { if (si.ID <= 0 || (buying && si.Buy <= 0) || (!buying && (si.Sell <= 0 || World.Instance.MainPlayer.ActiveCharacter.Inventory.FindIndex(inv => inv.id == si.ID) < 0))) continue; ShopItem localItem = si; ItemRecord rec = World.Instance.EIF.GetItemRecordByID(si.ID); string secondary = string.Format("{2}: {0} {1}", buying ? si.Buy : si.Sell, rec.Type == ItemType.Armor ? "(" + (rec.Gender == 0 ? World.GetString(DATCONST2.FEMALE) : World.GetString(DATCONST2.MALE)) + ")" : "", World.GetString(DATCONST2.DIALOG_SHOP_PRICE)); ListDialogItem nextItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large) { Text = rec.Name, SubText = secondary, IconGraphic = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.Items, 2 * rec.Graphic - 1, true), OffsetY = 45 }; nextItem.OnLeftClick += (o, e) => _buySellItem(localItem); nextItem.OnRightClick += (o, e) => _buySellItem(localItem); itemList.Add(nextItem); } SetItemList(itemList); _setButtons(ScrollingListDialogButtons.BackCancel); } break; case ShopState.Crafting: { List<ListDialogItem> itemList = new List<ListDialogItem>(m_craftItems.Count); foreach (CraftItem ci in m_craftItems) { if (ci.Ingredients.Count <= 0) continue; CraftItem localItem = ci; ItemRecord rec = World.Instance.EIF.GetItemRecordByID(ci.ID); string secondary = string.Format("{2}: {0} {1}", ci.Ingredients.Count, rec.Type == ItemType.Armor ? "(" + (rec.Gender == 0 ? World.GetString(DATCONST2.FEMALE) : World.GetString(DATCONST2.MALE)) + ")" : "", World.GetString(DATCONST2.DIALOG_SHOP_CRAFT_INGREDIENTS)); ListDialogItem nextItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large) { Text = rec.Name, SubText = secondary, IconGraphic = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.Items, 2 * rec.Graphic - 1, true), OffsetY = 45 }; nextItem.OnLeftClick += (o, e) => _craftItem(localItem); nextItem.OnRightClick += (o, e) => _craftItem(localItem); itemList.Add(nextItem); } SetItemList(itemList); _setButtons(ScrollingListDialogButtons.BackCancel); } break; } m_state = newState; }
/* * Stop a provided player's shopping session. */ public void StopShopping (int playerIndex) { if (playerIndex == activePlayerIndex) { PlayerController playerController = (PlayerController)FindActivePlayer ().GetComponent<PlayerController> (); playerController.SetNormalState (); ResetItemData (); selectedItem = String.Empty; state = ShopState.NONE; activePlayerIndex = -1; } }
/* * Begin selling. This is designed only for when a player is already shopping. */ public void StartSelling (int playerIndex) { SetActivePlayer (playerIndex); ResetItemData (); state = ShopState.SELLING; }
/* * Set the active shopper to the provided player and put the shop in BUYING state. * If a player is already shopping, they will be returned to a normal state and * the newly provided player will be given control. */ public void StartBuying (int playerIndex) { // Swap player states SetActivePlayer (playerIndex); PlayerController playerController = (PlayerController)FindActivePlayer () .GetComponent<PlayerController> (); playerController.SetShoppingState (); GameObject playerObj = FindInactivePlayer (); if (playerObj != null) { playerController = (PlayerController)playerObj.GetComponent<PlayerController> (); playerController.SetNormalState (); } ResetItemData (); state = ShopState.BUYING; }