public Object(ObjectsType _type, Vector3 _position, Material _mat, Dictionary <string, double> _parameters) { type = _type; position = _position; material = _mat; parameters = _parameters; }
private void Spawner() { if (objectSpawned < objectsNumber) { ObjectsType currentType = objectsType[objectSpawned]; animatorThrower.SetTrigger(currentType == ObjectsType.fruit ? "Watermelon" : "Bomb"); StartCoroutine(CreateObject((int)currentType)); } }
void ReadInfo() { string text = objectsInfoList.text; string[] strArray = text.Split('\n'); foreach (string str in strArray) { ObjectsInfo info = new ObjectsInfo(); string[] proArray = str.Split(','); info.id = int.Parse(proArray[0]); info.name = proArray[1]; info.icon_name = proArray[2]; string str_type = proArray[3]; ObjectsType type = ObjectsType.Drug; switch (str_type) { case "Drug": type = ObjectsType.Drug; break; case "Equip": type = ObjectsType.Equip; break; case "Mat": type = ObjectsType.Mat; break; } if (type == ObjectsType.Drug) { info.hp = int.Parse(proArray[4]); info.mp = int.Parse(proArray[5]); info.price_sell = int.Parse(proArray[6]); info.price_buy = int.Parse(proArray[7]); info.type = type; } else if (type == ObjectsType.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]); info.type = type; string str_dressType = proArray[7]; //穿戴类型 switch (str_dressType) { case "Headgear": info.dressType = DressType.Headgear; break; case "Armor": info.dressType = DressType.Armor; break; case "RightHand": info.dressType = DressType.RightHand; break; case "LeftHand": info.dressType = DressType.LeftHand; break; case "Shoe": info.dressType = DressType.Shoe; break; case "Accessory": info.dressType = DressType.Accessory; break; } string str_appType = proArray[8]; //适用类型 switch (str_appType) { case "Swordman": info.applicationType = ApplicationType.Swordman; break; case "Magician": info.applicationType = ApplicationType.Magician; break; case "Common": info.applicationType = ApplicationType.Common; break; } } objectInfoDict.Add(info.id, info); //添加到字典中,id为key,可以很方便地根据id查找到物品 } }