//大地图请求根据势力生成1个新的小队 public CharacterProperty[] BuildTeamOfTemp(CharacterProperty.CharacterKind kind, int LeaderID, int memeberID) { CharacterProperty[] returnProp = new CharacterProperty[5]; returnProp[0] = charPropList[LeaderID]; returnProp[1] = charPropList[memeberID]; returnProp[2] = charPropList[memeberID]; returnProp[3] = charPropList[memeberID]; returnProp[4] = charPropList[memeberID]; return(returnProp); }
/// <summary> /// 解析模板角色信息 /// </summary> void ParseCharacterJson() { charPropList = new List <CharacterProperty>(); TextAsset charText = Resources.Load <TextAsset>("Characters"); string charJson = charText.text; JSONObject charObjects = new JSONObject(charJson); foreach (JSONObject temp in charObjects.list) { int id = (int)temp["id"].n; string name = temp["name"].str; CharacterProperty.CharacterFaction faction = (CharacterProperty.CharacterFaction)System.Enum.Parse(typeof(CharacterProperty.CharacterFaction), temp["faction"].str); CharacterProperty.CharacterType type = (CharacterProperty.CharacterType)System.Enum.Parse(typeof(CharacterProperty.CharacterType), temp["characterType"].str); int consititution = (int)temp["constitution"].n; int strength = (int)temp["strength"].n; int agility = (int)temp["agility"].n; int dexterous = (int)temp["dexterous"].n; int concentration = (int)temp["concentration"].n; string sprite = temp["sprite"].str; int allExperience = (int)temp["allExperience"].n; int headID = 0; Item.ItemTechnology headTech = Item.ItemTechnology.T0; int clothID = 0; Item.ItemTechnology clothTech = Item.ItemTechnology.T0; int pantsID = 0; Item.ItemTechnology pantsTech = Item.ItemTechnology.T0; int beltID = 0; Item.ItemTechnology beltTech = Item.ItemTechnology.T0; int weaponID = 0; Item.ItemTechnology weaponTech = Item.ItemTechnology.T0; if (temp["head"].IsNumber) { headID = (int)temp["head"].n; } if (temp["head"].IsString) { headTech = (Item.ItemTechnology)System.Enum.Parse(typeof(Item.ItemTechnology), temp["head"].str); } if (temp["cloth"].IsNumber) { clothID = (int)temp["cloth"].n; } if (temp["cloth"].IsString) { clothTech = (Item.ItemTechnology)System.Enum.Parse(typeof(Item.ItemTechnology), temp["cloth"].str); } if (temp["pants"].IsNumber) { pantsID = (int)temp["pants"].n; } if (temp["pants"].IsString) { pantsTech = (Item.ItemTechnology)System.Enum.Parse(typeof(Item.ItemTechnology), temp["pants"].str); } if (temp["belt"].IsNumber) { beltID = (int)temp["belt"].n; } if (temp["belt"].IsString) { beltTech = (Item.ItemTechnology)System.Enum.Parse(typeof(Item.ItemTechnology), temp["belt"].str); } if (temp["weapon"].IsNumber) { weaponID = (int)temp["weapon"].n; } if (temp["weapon"].IsString) { weaponTech = (Item.ItemTechnology)System.Enum.Parse(typeof(Item.ItemTechnology), temp["weapon"].str); } if (headTech != Item.ItemTechnology.T0) { List <Item> allRightItems = InventoryManager.Instance.GetItemsByTechAndEquipType(headTech, Equipment.EquipmentType.Head); int i = Random.Range(0, allRightItems.Count); headID = allRightItems[i].ID; } if (clothTech != Item.ItemTechnology.T0) { List <Item> allRightItems = InventoryManager.Instance.GetItemsByTechAndEquipType(clothTech, Equipment.EquipmentType.Cloth); int i = Random.Range(0, allRightItems.Count); clothID = allRightItems[i].ID; } if (pantsTech != Item.ItemTechnology.T0) { List <Item> allRightItems = InventoryManager.Instance.GetItemsByTechAndEquipType(pantsTech, Equipment.EquipmentType.Pants); int i = Random.Range(0, allRightItems.Count); pantsID = allRightItems[i].ID; } if (beltTech != Item.ItemTechnology.T0) { List <Item> allRightItems = InventoryManager.Instance.GetItemsByTechAndEquipType(beltTech, Equipment.EquipmentType.Belt); int i = Random.Range(0, allRightItems.Count); beltID = allRightItems[i].ID; } if (weaponTech != Item.ItemTechnology.T0) { Item.ItemType weaponType = Random.Range(0, 2) == 0 ? Item.ItemType.MeleeWeapon : Item.ItemType.ShootWeapon; List <Item> allRightItems = InventoryManager.Instance.GetItemsByTechAndType(weaponTech, weaponType); int i = Random.Range(0, allRightItems.Count); weaponID = allRightItems[i].ID; } int[] skills = new int[20]; for (int i = 0; i < 20; i++) { skills[0] = 0; } //TODO 特异值(主体质) CharacterProperty.CharacterKind kind = (CharacterProperty.CharacterKind)System.Enum.Parse(typeof(CharacterProperty.CharacterKind), temp["characterKind"].str); CharacterProperty charProp = new CharacterProperty(id, name, faction, type, sprite, kind, consititution, strength, agility, dexterous, concentration, InventoryManager.Instance.GetItemByID(weaponID), allExperience, 0, skills, 0, headID, clothID, pantsID, beltID); charPropList.Add(charProp); } }