/// <summary> /// 依据道具名字生成一个道具 /// </summary> /// <param name="name"></param> /// <returns></returns> public WeaponBehaviour CreateWeapon(string name, bool bornsound = true) { if (!NameIDDict.ContainsKey(name)) { Debug.LogError("The name: " + name + " is not in the config file!"); return(null); } int id = NameIDDict[name]; WeaponPO po = WeaponData.Instance.GetWeaponPO(id); GameObject obj = ioo.poolManager.Spawn(name); _weapon = obj.GetOrAddComponent <WeaponBehaviour>(); _weapon.Type = (WeaponType)po.Type; _weapon.Assaultable = po.IsEnermy == 1 ? true : false; _weapon.BornVolumeName = po.BornVolumeName; _weapon.DieVolumeName = po.DieVolumeName; _weapon.DamageValue = po.Damage; _weapon.DamagePlane = po.DamagePlane; _weapon.BornEffect = po.BornEffect; _weapon.DieEffect = po.DieEffect; _weapon.Owner = string.Empty; _weapon.Spawn(bornsound); return(_weapon); }
public void Init() { WeaponDict.Clear(); NameIDDict.Clear(); for (int i = StartID; i <= EndID; ++i) { WeaponPO bullet = WeaponData.Instance.GetWeaponPO(i); NameIDDict.Add(bullet.Name, i); } }
static public void LoadHandler(LoadedData data) { JsonData jsonData = JsonMapper.ToObject(data.Value.ToString()); if (!jsonData.IsArray) { return; } for (int index = 0; index < jsonData.Count; index++) { JsonData element = jsonData[index]; WeaponPO po = new WeaponPO(element); WeaponData.Instance.m_dictionary.Add(po.Id, po); } }