public ObjectOnInfo GetObjctInfoById(int id) { ObjectOnInfo info = new ObjectOnInfo(); objectInfoDict.TryGetValue(id, out info); return(info); }
public void setId(int id) { this.id = id; ObjectOnInfo info = ObjectInfo._instance.GetObjctInfoById(id); setInfo(info); }
string GetEquipDes(ObjectOnInfo info) { string str = ""; str += "名称:" + info.name + "\n"; switch (info.dressType) { case DressType.Headgear: str += "穿戴部位:头盔" + "\n"; break; case DressType.Accessory: str += "穿戴部位:饰品" + "\n"; break; case DressType.Armor: str += "穿戴部位:法杖" + "\n"; break; case DressType.Left_Hand: str += "穿戴部位:左手" + "\n"; break; case DressType.Right_Hand: str += "穿戴部位:右手" + "\n"; break; case DressType.Shoe: str += "穿戴部位:鞋子" + "\n"; break; default: break; } switch (info.applicationType) { case ApplicationType.Swordman: str += "适用职业:战士" + "\n"; break; case ApplicationType.Magician: str += "适用职业:法师" + "\n"; break; case ApplicationType.Common: str += "适用职业:所有职业" + "\n"; break; default: break; } str += "攻击值:" + info.attack + "\n"; str += "防御值:" + info.def + "\n"; str += "速度值:" + info.speed + "\n"; str += "出售价:" + info.price_sell + "\n"; str += "购买价:" + info.price_buy + "\n"; return(str); }
public void Show(int id) { this.gameObject.SetActive(true); time = 0.1f; //转化为世界坐标 transform.position = UICamera.currentCamera.ScreenToWorldPoint(Input.mousePosition); // print("============================"+id); ObjectOnInfo info = ObjectInfo._instance.GetObjctInfoById(id); string des = ""; switch (info.type) { case ObjectType.Drug: des = GetDrugDes(info); break; case ObjectType.Equip: des = GetEquipDes(info); break; default: break; } label.text = des; }
//把物体拖离一个空格到另一个空格,清空这个空格的内容。 public void ClearInfo() { id = 0; num = 0; info = null; //numLabel.gameObject.SetActive(false); numLabel.enabled = false; }
void PlusProperty(EquipmentItem item) { if (item != null) { ObjectOnInfo equipmentInfo = ObjectInfo._instance.GetObjctInfoById(item.id); this.attack += equipmentInfo.attack; this.def += equipmentInfo.def; this.speed += equipmentInfo.speed; } }
string GetDrugDes(ObjectOnInfo info) { string str = ""; str += "名称:" + info.name + "\n"; str += "HP:" + info.hp + "\n"; str += "MP:" + info.mp + "\n"; str += "出售价:" + info.price_sell + "\n"; str += "购买价:" + info.price_buy + "\n"; //print("============================" + str); return(str); }
//调用方法更新背包单元格内容的显示 public void SetId(int id, int num = 1) { this.id = id; info = ObjectInfo._instance.GetObjctInfoById(id);//通过ID得到这个物品 InventoryItem item = this.GetComponentInChildren <InventoryItem>(); item.SetIconName(id, info.icon_name); //更新显示 //numLabel.gameObject.SetActive(true); numLabel.enabled = true; this.num = num; numLabel.text = num.ToString(); }
public void SetId(int id) { ObjectOnInfo info = ObjectInfo._instance.GetObjctInfoById(id); sprite.spriteName = info.icon_name; }
void ReadInfo() { string text = objectsInfoLIst.text; string[] strArray = text.Split('\n'); ObjectOnInfo info; //存储读取的信息 foreach (string str in strArray) { info = new ObjectOnInfo(); string[] proArray = str.Split(','); int id = int.Parse(proArray[0]); string name = proArray[1]; string icon_name = proArray[2]; string str_type = proArray[3]; ObjectType type = ObjectType.Drug; switch (str_type) { case "Drug": type = ObjectType.Drug; break; case "Equip": type = ObjectType.Equip; break; case "Mat": type = ObjectType.Mat; break; default: break; } info.id = id; info.name = name; info.icon_name = icon_name; info.type = type; if (type == ObjectType.Drug) { int hp = int.Parse(proArray[4]); int mp = int.Parse(proArray[5]); int price_sell = int.Parse(proArray[6]); int price_buy = int.Parse(proArray[7]); info.hp = hp; info.mp = mp; info.price_sell = price_sell; info.price_buy = price_buy; } else if (type == ObjectType.Equip) { info.attack = int.Parse(proArray[4]); info.def = int.Parse(proArray[5]); info.speed = int.Parse(proArray[6]); info.price_sell = int.Parse(proArray[9]); info.price_buy = int.Parse(proArray[10]); string str_dressType = proArray[7]; switch (str_dressType) { case "Headgear": info.dressType = DressType.Headgear; break; case "Armor": info.dressType = DressType.Armor; break; case "Right_Hand": info.dressType = DressType.Right_Hand; break; case "Left_Hand": info.dressType = DressType.Left_Hand; break; case "Shoe": info.dressType = DressType.Shoe; break; case "Accessory": info.dressType = DressType.Accessory; break; default: break; } string str_applicationType = proArray[8]; switch (str_applicationType) { case "Swordman": info.applicationType = ApplicationType.Swordman; break; case "Magician": info.applicationType = ApplicationType.Magician; break; case "Common": info.applicationType = ApplicationType.Common; break; default: break; } } objectInfoDict.Add(id, info);//添加数据到字典中,ID为key,可以很方便的根据ID查看数据 } }
//处理装备的穿戴与脱下 public bool DressEquipment(int id) { ObjectOnInfo info = ObjectInfo._instance.GetObjctInfoById(id); if (info.type != ObjectType.Equip) { return(false); } if (ps.heroType == HeroType.Magician) { if (info.applicationType == ApplicationType.Swordman) { return(false); } } if (ps.heroType == HeroType.Swordman) { if (info.applicationType == ApplicationType.Magician) { return(false); } } GameObject parent = null; switch (info.dressType) { case DressType.Headgear: //print("----这是头盔"); parent = headgear; break; case DressType.Armor: //print("----这是盔甲"); parent = armor; break; case DressType.Left_Hand: parent = left_Hand; //print("------这是左手"); break; case DressType.Right_Hand: //print("----这是右手"); parent = right_Hand; break; case DressType.Shoe: //print("----这是鞋子"); parent = shoe; break; case DressType.Accessory: //print("----这是饰品"); parent = accessory; break; default: break; } EquipmentItem item = parent.GetComponentInChildren <EquipmentItem>(); // EquipmentItem._instance.setInfo(info); if (item != null) { Inventory._instance.GetId(item.id); //把已经穿戴的装备脱下放回背包 item.setInfo(info); // 更新新装备 } else { GameObject itemGo = NGUITools.AddChild(parent, equipment); itemGo.transform.localPosition = Vector3.zero; itemGo.GetComponent <EquipmentItem>().setInfo(info); } UpdateProperty(); return(true); }
public void setInfo(ObjectOnInfo info) { this.id = info.id; sprite.spriteName = info.icon_name; }