public static void showbag() { // AssetDatabase.Refresh(); //Save.SaveGoods(); //Analysis.GoodsAnalysis(); //Analysis.GoodsAnalysis(); GameObject pa = GameObject.Find("BagPanel(Clone)").transform.GetChild(1).GetChild(0).gameObject; for (int i = 0; i < Save.Goodlist.Count; i++) { if (Save.Goodlist[i].Num > 0) { DataMgr.Item tt1 = DataMgr.GetInstance().GetItemID(Save.Goodlist[i].Id); GameObject ga = GameObject.Instantiate(Resources.Load <GameObject>("bagga")); Debug.Log(Save.Goodlist.Count); ga.transform.SetParent(pa.transform.GetChild(i)); // ga.transform.position = ga.transform.parent.transform.position; ga.transform.localScale = Vector3.one; ga.transform.localPosition = new Vector3(0f, 0, 0); ga.transform.GetChild(0).GetComponent <Image>().sprite = Resources.Load <Sprite>(tt1.item_Img); ga.transform.GetChild(1).GetComponent <Text>().text = Save.Goodlist[i].Num.ToString(); ga.transform.GetChild(0).GetComponent <Button>().onClick.AddListener(() => { TTUIPage.ShowPage <ttttt>(tt1); }); ga.transform.GetComponent <Button>().onClick.AddListener(() => TTUIPage.ShowPage <ttttt>(Save.Goodlist[i])); } }// }
public override void Awake(GameObject go) { base.Awake(go); //查找各种UI itemPrefab = Resources.Load <GameObject>("UIPrefab/ShopItem"); itemParent = transform.Find("Scroll View/Viewport/Content"); //itemParent = Tools.FindInChildren<GridLayoutGroup>(go).transform; itemInfo = transform.Find("ItemInfo").gameObject; group = transform.Find("ToggleGroup").GetComponent <ToggleGroup>(); buttonClose = transform.Find("ButtonClose").GetComponent <Button>(); buttonClose.onClick.AddListener(Hide); //信息显示相关的UI infoName = itemInfo.transform.Find("TextName").GetComponent <Text>(); infoDes = itemInfo.transform.Find("TextDes").GetComponent <Text>(); //选中一个物品后,执行显示信息的方法 ShopItem.OnItemSelected += ShowSelectedItemInfo; //从NPC身上传过来的物品列表 List <int> tempList = (List <int>)data; //根据物品列表列出物品 for (int i = 0; i < tempList.Count; i++) { GameObject obj = GameObject.Instantiate(itemPrefab); Item info = DataMgr.GetInstance().GetItemByID(tempList[i]);//得到物品信息 obj.transform.SetParent(itemParent); obj.transform.Find("ImageSlot").GetComponent <Toggle>().group = group; obj.transform.GetComponent <ShopItem>().Init(info); } }
/// <summary> /// 使用物品后人物属性更新 /// </summary> public static void UpdateUser() { if (saveUser == null) { saveUser = new List <UserModel>(); } saveUser[1].Attack = 0; saveUser[1].Defend = 0; saveUser[1].MaxHp = 0; saveUser[1].Speed = 0; saveUser[1].Hit = 0; foreach (EquipModel em in equipList) { Item item = DataMgr.GetInstance().GetItemByID(em.Id); saveUser[1].Attack += item.atk; saveUser[1].Defend += item.def; saveUser[1].MaxHp += item.hp; saveUser[1].Speed += item.spd; saveUser[1].Hit += item.hit; } if (saveUser[0].Hp > saveUser[0].MaxHp) { saveUser[0].Hp = saveUser[0].MaxHp; } }
public void Init(TaskModel _item) { task = _item; transform.localScale = Vector3.one; transform.localPosition = Vector3.zero; if (task.Task_Type == Task_Type.collect) { item = DataMgr.GetInstance().GetItemByID(task.id); Item Ritem = DataMgr.GetInstance().GetItemByID(task.Reward_ID); transform.Find("TaskName").GetComponent <Text>().text = "任务名:收集物品"; transform.Find("TaskDescribe").GetComponent <Text>().text = "任务描述:收集" + item.item_Name + "*" + task.num; transform.Find("TaskProgress/Test").GetComponent <Text>().text = item.item_Name + " " + "0" + "/" + task.num; transform.Find("TaskReward/Text").GetComponent <Text>().text = "奖励" + Ritem.item_Name + "*" + task.Reward_num; transform.Find("FinishTask/Text").GetComponent <Text>().text = "未完成"; } else { transform.Find("TaskName").GetComponent <Text>().text = "击杀小怪"; //transform.Find("TaskDescribe").GetComponent<Text>().text = "击杀" + item.item_Name + "*" + task.num; //transform.Find("TaskProgress/Test").GetComponent<Text>(); //transform.Find("TaskReward/Text").GetComponent<Text>().text = "奖励" + Ritem.item_Name + "*" + task.Reward_num; } switch (task.accept) { case Task_State.Accept: transform.Find("AcceptTask/Text").GetComponent <Text>().text = "接受任务"; break; case Task_State.Renounce: transform.Find("AcceptTask/Text").GetComponent <Text>().text = "放弃任务"; break; } }
public override void Refresh() { //base.Refresh(); // AssetDatabase.Refresh(); if (Save.Equiplist == null) { HP.text = "HP: " + (hp).ToString(); MP.text = "MP: " + (mp).ToString(); ATK.text = "ATK: " + (atk).ToString(); DEF.text = "DEF: " + (def).ToString(); SPEDD.text = "SPEDD: " + (speed).ToString(); } else { DataMgr dataMgr = DataMgr.GetInstance(); for (int i = 0; i < Save.Equiplist.Count; i++) { S = DataMgr.instance.GetItemID(Save.Equiplist[i].Id); HP.text = "HP: " + (hp += dataMgr.GetItemID(S.item_ID).hp).ToString(); MP.text = "MP: " + (mp += dataMgr.GetItemID(S.item_ID).mp).ToString(); ATK.text = "ATK: " + (atk += dataMgr.GetItemID(S.item_ID).atk).ToString(); DEF.text = "DEF: " + (def += dataMgr.GetItemID(S.item_ID).def).ToString(); SPEDD.text = "SPEDD: " + (speed += dataMgr.GetItemID(S.item_ID).spd).ToString(); } } }
public void ShowBag() { //清除背包 ClearBag(); //遍历物品信息 int j = 0; foreach (GoodsModel item in Save.SaveGoods) { if (item.Num != 0)//物品数量不等于零时 { //创建物品 GameObject go = GameObject.Instantiate(itemPrefab); go.transform.SetParent(Grid.GetChild(j)); go.GetComponent <RectTransform>().sizeDelta = new Vector2(60, 60); go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; //显示物体的图片及数量 Sprite tempSprite = Resources.Load <Sprite>("Image/" + item.Id); go.GetComponent <Image>().sprite = tempSprite; go.transform.GetChild(0).GetComponent <Text>().text = item.Num + ""; Item i = DataMgr.GetInstance().GetItemByID(item.Id); go.GetComponent <BagItem>().Init(i, tempSprite); j++; } } }
/// <summary> /// 卸下装备更新数据 /// </summary> /// <param name="_item"></param> public static void UnloadEquip(Item _item) { EquipModel gm = EquipList.Find(x => x.Id == _item.item_ID); EquipList.Remove(gm); Item item = DataMgr.GetInstance().GetItemByID(gm.Id); BuyItem(item); UpdateUser(); SaveEquip(); }
public void OnPointerClick(PointerEventData eventData) { ga = eventData.pointerEnter.gameObject; Debug.Log(ga.name); ga.transform.parent.GetChild(6).GetComponent <Toggle>().isOn = true; GameObject Me = GameObject.Find("Message"); Me.transform.localScale = Vector3.one; Me.transform.GetChild(6).GetComponent <Button>().onClick.AddListener(close); Debug.Log(Me.transform.GetChild(6).name); List <GameObject> gameObjects = new List <GameObject>(); DataMgr dataMgr = DataMgr.GetInstance(); GameObject game = GameObject.Find("Content"); for (int i = 0; i < game.transform.childCount; i++) { gameObjects.Add(game.transform.GetChild(i).gameObject); } Sprite s = ga.transform.parent.GetChild(0).GetComponent <Image>().sprite; Me.transform.GetChild(1).GetComponent <Image>().sprite = s; if (ShopItemlist.tag1 == "W") { for (int i = 0; i < gameObjects.Count; i++) { if (gameObjects[i].transform.GetChild(0).transform.GetChild(0).GetComponent <Image>().sprite == s) { Debug.Log(gameObjects[i].transform.GetChild(0).transform.GetChild(0).gameObject.name); Me.transform.GetChild(2).GetComponent <Text>().text = "名字 :" + dataMgr.GetItemID(DataMgr.itemList[i + 3].item_ID).item_Name; Me.transform.GetChild(3).GetComponent <Text>().text = "类型 :" + dataMgr.GetItemID(DataMgr.itemList[i + 3].item_ID).item_Type; Me.transform.GetChild(4).GetComponent <Text>().text = "价格 :" + (dataMgr.GetItemID(DataMgr.itemList[i + 3].item_ID).price).ToString(); Me.transform.GetChild(5).GetComponent <Text>().text = "描述 :" + (dataMgr.GetItemID(DataMgr.itemList[i + 3].item_ID).description).ToString(); } } } else { for (int i = 0; i < 3; i++) { if (gameObjects[i].transform.GetChild(0).GetChild(0).GetComponent <Image>().sprite == s) { Me.transform.GetChild(2).GetComponent <Text>().text = "名字 :" + dataMgr.GetItemID(DataMgr.itemList[i].item_ID).item_Name; Me.transform.GetChild(3).GetComponent <Text>().text = "类型 :" + dataMgr.GetItemID(DataMgr.itemList[i].item_ID).item_Type; Me.transform.GetChild(4).GetComponent <Text>().text = "价格 :" + (dataMgr.GetItemID(DataMgr.itemList[i].item_ID).price).ToString(); Me.transform.GetChild(5).GetComponent <Text>().text = "描述 :" + (dataMgr.GetItemID(DataMgr.itemList[i].item_ID).description).ToString(); } } } }
public static void FinishTask(int taskID) { TaskModel tm = userList.Find(x => x.Id == taskID); Item item = DataMgr.GetInstance().GetItemByID(tm.Reward_ID); GoodsModel gm = GoodsList.Find(x => x.Id == tm.id); gm.Num -= tm.num; BuyItem(item); UserTask.Remove(tm); SaveTask(); }
/// <summary> /// 锻造装备更新数据 /// </summary> /// <param name="_id"></param> public static void ForgingItem(int _id) { GoodsModel gm = GoodsList.Find(x => x.Id == _id);//在背包找到这个物品 if (gm.Num > 2) { gm.Num -= 2; Forging fg = ForgingList.Find(x => x.id == _id); Item item = DataMgr.GetInstance().GetItemByID(fg.ID); BuyItem(item); } }
public void SetPar(Transform trans, EquipModel item) { GameObject go = GameObject.Instantiate(itemPrefab); go.transform.SetParent(trans); go.GetComponent <RectTransform>().sizeDelta = new Vector2(50, 50); go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; Sprite tempSprite = Resources.Load <Sprite>("Image/" + item.Id); go.GetComponent <Image>().sprite = tempSprite; Item gm = DataMgr.GetInstance().GetItemByID(item.Id); go.GetComponent <BagItem>().Init(gm, tempSprite); }
/// <summary> /// 使用物品时装备栏更新和人物属性更新 /// </summary> /// <param name="_item">要使用的物品</param> public static void UseItem(Item _item) { if (equipList == null) { equipList = new List <EquipModel>(); } GoodsModel gm = GoodsList.Find(x => x.Id == _item.item_ID); //在背包找到这个物品 if (gm.Num <= 1) //使用了这个物品,背包要移除这个物品 { GoodsList.Remove(gm); //如果背包栏这个物品数据为1则移除这个物品 } else { gm.Num -= 1; //如果这个物品数据大于1则数量减一 } if (_item.equipment_Type != Equipment_Type.Null) //判断这个物品是不是装备 { //判断背包栏是不是有这个类型的武器,类型是穿戴在武器穿戴的位置 EquipModel em = EquipList.Find(x => x.Equipment_Type == _item.equipment_Type); if (em != null) //如果这个位置已经有物体就要替换 { em.Value += 1; //如果这个位置有物体了,让这个物体的数量加1 if (em.Value > 1) //看这个位置的物体数量是不是1,如果大于一则移除这个物体 { EquipList.Remove(em); //在武器数据中移除这个数据 Item item = DataMgr.GetInstance().GetItemByID(em.Id); //在数据库中找到移除的这个物体 BuyItem(item); //将他保存回背包数据中 } } //给背包数据添加这个新的要使用的物品,达到替换的效果 equipList.Add(new EquipModel() { Id = _item.item_ID, Equipment_Type = _item.equipment_Type, Value = 1 }); } else { if (saveUser[0].Hp < saveUser[0].MaxHp) { saveUser[0].Hp += _item.hp; } } SaveEquip(); }
/// <summary> /// 显示物品信息 /// </summary> /// <param name="gm"></param> private void ShowSelectedItemInfo(GoodsModel gm) { infoParent.gameObject.SetActive(true); Item tempItem = DataMgr.GetInstance().GetItemByID(gm.Id); infoName.text = tempItem.item_Name; infoDes.text = tempItem.description; //修改弹出框的位置 Vector3 worldPos; if (RectTransformUtility.ScreenPointToWorldPointInRectangle( TTUIRoot.Instance.root as RectTransform, Input.mousePosition, TTUIRoot.Instance.uiCamera, out worldPos)) { infoParent.position = worldPos; } }
public override void Awake(GameObject go) { base.Awake(go); itemPrefab = Resources.Load <GameObject>("UIPrefab/Grid"); conter = transform.Find("Scroll View/Viewport/Content"); iteminfo = transform.Find("ItemInfo").gameObject; group = transform.Find("ToggleGroup").GetComponent <ToggleGroup>(); ShopItem.OnItemSelected += ShowSelectedItemInfo; infoName = iteminfo.transform.Find("TextName").GetComponent <Text>(); infoDes = iteminfo.transform.Find("TextDes").GetComponent <Text>(); iteminfo.gameObject.SetActive(false); List <int> _itemID = (List <int>)data; for (int i = 0; i < _itemID.Count; i++) { GameObject Grid = GameObject.Instantiate(itemPrefab); Item info = DataMgr.GetInstance().GetItemByID(_itemID[i]); Grid.transform.SetParent(conter); Grid.transform.Find("ImageSlot").GetComponent <Toggle>().group = group; Grid.transform.GetComponent <ShopItem>().Init(info); } }
public override void InitConfig() { JobList = DataMgr.GetInstance().GetConfigItems <int, CJob>(Define.DataType.Job); }
public override void InitConfig() { SkillList = DataMgr.GetInstance().GetConfigItems <int, CSkill>(Define.DataType.Skill); }
protected Dictionary <N, T> ReadConfigData <N, T>(DataType type) where T : Base.BaseData, new() { return(DataMgr.GetInstance().GetConfigItems <N, T>(type)); }
public static void showequip() { AssetDatabase.Refresh(); // Analysis.GoodsEquip(); // Save.SaveEquip(); if (Save.Equiplist == null) { } else { for (int i = 0; i < Save.Equiplist.Count; i++) { GameObject ga = GameObject.Instantiate(Resources.Load <GameObject>("zhuangbei")); DataMgr.Item tt1 = DataMgr.GetInstance().GetItemID(Save.Equiplist[i].Id); GameObject go = GameObject.Find("NormalRoot").transform.Find("EquipPanel(Clone)").gameObject; switch (tt1.equipment_Type) { case DataMgr.Equipment_Type.Head_Gear: ga.transform.SetParent(go.transform.GetChild(0)); ga.transform.GetComponent <Image>().sprite = Resources.Load <Sprite>(tt1.item_Img); ga.transform.localScale = Vector3.one; ga.transform.GetComponent <RectTransform>().localPosition = Vector3.zero; ga.GetComponent <Button>().onClick.AddListener(() => { TTUIPage.ShowPage <tipequ>(tt1); }); break; case DataMgr.Equipment_Type.Armor: ga.transform.SetParent(go.transform.GetChild(1)); ga.transform.GetComponent <Image>().sprite = Resources.Load <Sprite>(tt1.item_Img); ga.transform.localScale = Vector3.one; ga.transform.GetComponent <RectTransform>().localPosition = Vector3.zero; ga.GetComponent <Button>().onClick.AddListener(() => { TTUIPage.ShowPage <tipequ>(tt1); }); break; case DataMgr.Equipment_Type.Shoes: ga.transform.SetParent(go.transform.GetChild(4)); ga.transform.GetComponent <Image>().sprite = Resources.Load <Sprite>(tt1.item_Img); ga.transform.localScale = Vector3.one; ga.transform.GetComponent <RectTransform>().localPosition = Vector3.zero; ga.GetComponent <Button>().onClick.AddListener(() => { TTUIPage.ShowPage <tipequ>(tt1); }); break; case DataMgr.Equipment_Type.Accessory: ga.transform.SetParent(go.transform.GetChild(5)); ga.transform.GetComponent <Image>().sprite = Resources.Load <Sprite>(tt1.item_Img); ga.transform.localScale = Vector3.one; ga.transform.GetComponent <RectTransform>().localPosition = Vector3.zero; ga.GetComponent <Button>().onClick.AddListener(() => { TTUIPage.ShowPage <tipequ>(tt1); }); break; case DataMgr.Equipment_Type.Left_Hand: ga.transform.SetParent(go.transform.GetChild(3)); ga.transform.GetComponent <Image>().sprite = Resources.Load <Sprite>(tt1.item_Img); ga.transform.localScale = Vector3.one; ga.transform.GetComponent <RectTransform>().localPosition = Vector3.zero; ga.GetComponent <Button>().onClick.AddListener(() => { TTUIPage.ShowPage <tipequ>(tt1); }); break; case DataMgr.Equipment_Type.Right_Hand: ga.transform.SetParent(go.transform.GetChild(2)); ga.transform.GetComponent <Image>().sprite = Resources.Load <Sprite>(tt1.item_Img); ga.transform.localScale = Vector3.one; ga.transform.GetComponent <RectTransform>().localPosition = Vector3.zero; ga.GetComponent <Button>().onClick.AddListener(() => { TTUIPage.ShowPage <tipequ>(tt1); }); break; case DataMgr.Equipment_Type.Two_Hand: ga.transform.SetParent(go.transform.GetChild(2)); ga.transform.GetComponent <Image>().sprite = Resources.Load <Sprite>(tt1.item_Img); ga.transform.localScale = Vector3.one; ga.transform.GetComponent <RectTransform>().localPosition = Vector3.zero; ga.GetComponent <Button>().onClick.AddListener(() => { TTUIPage.ShowPage <tipequ>(tt1); }); //GameObject clone = GameObject.Instantiate(Resources.Load<GameObject>("zhuangbei")); //clone.transform.SetParent(go.transform.GetChild(3)); //clone.transform.GetComponent<Image>().sprite = Resources.Load<Sprite>(tt1.item_Img); //clone.transform.localPosition = Vector3.zero; //clone.transform.localScale = Vector3.one; break; default: break; } } } }
public override void Refresh() { base.Refresh(); DataMgr dataMgr = DataMgr.GetInstance(); List <GameObject> gameObjects = new List <GameObject>(); dataMgr.GetItemID(DataMgr.itemList[3].item_ID); Debug.Log(dataMgr.GetItemID(DataMgr.itemList[3].item_ID)); g = GameObject.Find("Content").transform.GetComponent <ToggleGroup>(); GameObject game = GameObject.Find("Content"); //for (int i = 0; i < game.transform.childCount; i++) //{ // gameObjects.Add(game.transform.GetChild(i).gameObject); //} //Debug.Log(gameObjects.Count); Debug.Log(ShopItemlist.tag1); if (ShopItemlist.tag1 == "W") { for (int i = 3; i < DataMgr.itemList.Count; i++) { //创建物品 NGUITools.AddChild(父物体,预设物); GameObject ga = GameObject.Instantiate(Resources.Load <GameObject>("Weapon")); ga.transform.SetParent(game.transform); ga.transform.position = ga.transform.parent.transform.position; ga.transform.localScale = Vector3.one; ga.transform.localPosition = new Vector3(117.5f, 0, 0); //显示物体的图片及数量 int S = int.Parse(dataMgr.GetItemID(DataMgr.itemList[i].item_ID).item_Img); Debug.Log(dataMgr.GetItemID(DataMgr.itemList[i].item_ID).item_Img + "11111"); ga.transform.GetChild(0).GetChild(0).GetComponent <Image>().sprite = Resources.Load <Sprite>((dataMgr.GetItemID(DataMgr.itemList[i].item_ID).item_Img).ToString()); ga.transform.GetChild(0).GetChild(1).GetComponent <Text>().text = dataMgr.GetItemID(DataMgr.itemList[i].item_ID).item_Name; ga.transform.GetChild(0).GetChild(2).GetComponent <Text>().text = dataMgr.GetItemID(DataMgr.itemList[i].item_ID).item_Type; ga.transform.GetChild(0).GetChild(3).GetComponent <Text>().text = (dataMgr.GetItemID(DataMgr.itemList[i].item_ID).price).ToString(); ga.transform.GetChild(0).GetChild(5).GetComponent <Tipe>().tipe(dataMgr.GetItemID(DataMgr.itemList[i].item_ID)); Debug.Log("执行了"); ga.transform.GetChild(0).GetChild(6).GetComponent <Toggle>().group = g; } } else { for (int i = 0; i < 3; i++) { //创建物品 NGUITools.AddChild(父物体,预设物); GameObject ga = GameObject.Instantiate(Resources.Load <GameObject>("Weapon")); ga.transform.SetParent(game.transform); ga.transform.position = ga.transform.parent.transform.position; ga.transform.localScale = Vector3.one; ga.transform.localPosition = new Vector3(117.5f, 0, 0); //显示物体的图片及数量 int S = int.Parse(dataMgr.GetItemID(DataMgr.itemList[i].item_ID).item_Img); Debug.Log(dataMgr.GetItemID(DataMgr.itemList[i].item_ID).item_Img + "11111"); ga.transform.GetChild(0).GetChild(0).GetComponent <Image>().sprite = Resources.Load <Sprite>((dataMgr.GetItemID(DataMgr.itemList[i].item_ID).item_Img).ToString()); ga.transform.GetChild(0).GetChild(1).GetComponent <Text>().text = dataMgr.GetItemID(DataMgr.itemList[i].item_ID).item_Name; ga.transform.GetChild(0).GetChild(2).GetComponent <Text>().text = dataMgr.GetItemID(DataMgr.itemList[i].item_ID).item_Type; ga.transform.GetChild(0).GetChild(3).GetComponent <Text>().text = (dataMgr.GetItemID(DataMgr.itemList[i].item_ID).price).ToString(); ga.transform.GetChild(0).GetChild(5).GetComponent <Tipe>().tipe(dataMgr.GetItemID(DataMgr.itemList[i].item_ID)); Debug.Log("执行了"); ga.transform.GetChild(0).GetChild(6).GetComponent <Toggle>().group = g; } } statue = true; }