public void SetUpTradePlane() { SoundManager.Instance.PlayAudioClip("UI/sfx_UI_Trader"); ClearItemDetail(); Trader trader = currentEnteredNpc as Trader; currentEnteredNpc = trader; tradePlane.gameObject.SetActive(true); goodsPool.AddChildInstancesToPool(goodsContainer); List <Item> itemsAsGoods = trader.itemsAsGoodsOfCurrentLevel; for (int i = 0; i < itemsAsGoods.Count; i++) { Item itemAsGoods = itemsAsGoods [i]; // Transform goodsCell = Instantiate (goodsModel.gameObject).transform; // goodsCell.SetParent (goodsContainer); Transform goodsCell = goodsPool.GetInstance <Transform> (goodsModel.gameObject, goodsContainer); goodsCell.GetComponent <GoodsCell> ().SetUpGoodsCell(itemAsGoods); goodsCell.GetComponent <Button>().onClick.RemoveAllListeners(); int goodsIndex = i; goodsCell.GetComponent <Button>().onClick.AddListener(delegate { currentSelectedItem = itemAsGoods; SetUpItemDetailsInTrade(itemAsGoods); UpdateGoodsSelection(goodsIndex); }); } }
private void SaveNpcData() { NPC npcData = null; string prefix = string.Empty; switch (npcType) { case NPCType.Normal: prefix = "Normal"; npcData = new NPC(); break; case NPCType.Trader: prefix = "Trader"; npcData = new Trader(); (npcData as Trader).goodsGroupList = npc.goodsGroupList; break; } npcData.npcId = npc.npcId; npcData.npcName = npc.npcName; npcData.spriteName = npc.spriteName; npcData.greetingDialog = npc.greetingDialog; npcData.attachedFunctions = npc.attachedFunctions; npcData.tasks = npc.tasks; npcData.chatDialogGroups = chatDialogGroups; int attachedFunctionCount = (skillPromotionFunction ? 1 : 0) + (propertyPromotionFunction ? 1 : 0) + (taskFunction ? 1 : 0) + (characterTradeFunction ? 1 : 0); npcData.attachedFunctions = new NPCAttachedFunctionType[attachedFunctionCount]; int index = 0; if (skillPromotionFunction) { npcData.attachedFunctions [index] = NPCAttachedFunctionType.SkillPromotion; index++; } if (propertyPromotionFunction) { npcData.attachedFunctions [index] = NPCAttachedFunctionType.PropertyPromotion; index++; } if (taskFunction) { npcData.attachedFunctions [index] = NPCAttachedFunctionType.Task; index++; } if (characterTradeFunction) { npcData.attachedFunctions [index] = NPCAttachedFunctionType.CharactersTrade; } string npcJson = string.Empty; npcJson = EditorJsonUtility.ToJson(npcData); string npcFilePath = string.Format("{0}/NPCs/{1}_{2}.json", CommonData.originDataPath, prefix, npc.npcName); File.WriteAllText(npcFilePath, npcJson); }