private void _register(string key, string name) { Type myClass = Type.GetType(name); if (myClass == null) { DevDebug.Log("[" + name + "] is not found! please create class first!"); return; } key = key.ToUpper(); try { ReBase reBase = (ReBase)Activator.CreateInstance(myClass); ConfigDataBase config = _allConfig[key]; int len = config.ConfigList().Length; for (int i = 0; i < len; ++i) { reBase.ReLoadFunc(config.ConfigList()[i], i, len); } _reConfigs.Add(key, reBase); } catch (Exception e) { DevDebug.Log(e); } }
public LogicBase mgr(string key) { if (_mgr.ContainsKey(key)) { return(_mgr[key]); } DevDebug.Log("[" + key + "] is NULL! Please Register First"); return(null); }
private void _tryCreateItemVo(string itemId, int count) { int len = packVo.items.Length; ITEMRESOURCE config = ConfigManager.Inst.GetItemResourceByID(itemId); if (config == null) { DevDebug.Log("道具[" + itemId + "]配置不存!"); return;// 道具配置不存在 } for (int i = 0; i < len; i++) { if (packVo.items[i] == null) { continue; } if (packVo.items[i].configId != itemId) { continue; } if (packVo.items[i].count >= config.limit) { continue; } if ((packVo.items[i].count + count) > config.limit) { count = count - config.limit + packVo.items[i].count; packVo.items[i].count = config.limit; } else { packVo.items[i].count += count; count = 0; } break; } while (count > 0) { // 创建物品 ItemVO itemVo = _createItemVO(itemId); if (count > config.limit) { count -= config.limit; itemVo.count = config.limit; } else { itemVo.count = count; count = 0; } // 将物品放入到背包中 packVo.items.SetValue(itemVo, itemVo.index); } }
public void AnalysisConfig <T>(MAINRESOURCE res) where T : BaseResource { try { TextAsset text = Resources.Load <TextAsset>(res.url); ConfigData <T> config = JsonUtility.FromJson <ConfigData <T> >(text.text); _allConfig.Add(res.name.ToUpper(), config); } catch (Exception e) { DevDebug.Log(e); } }
private void _register(string key) { Type T = Type.GetType(this.GetType().Namespace + "." + key); if (T != null) { LogicBase inst = (LogicBase)Activator.CreateInstance(T); inst.Init(); _mgr.Add(key, inst); } else { DevDebug.Log("Register [" + key + "] is Error! Class [" + key + "] is not found!"); } }
private LGUIBase _creatLgui(string key) { Type T = Type.GetType(this.GetType().Namespace + "." + key); if (T != null) { LGUIBase inst = (LGUIBase)Activator.CreateInstance(T); inst.Init(); _host.Add(key, inst); return(inst); } else { DevDebug.Log("Register [" + key + "] is Error! Class [" + key + "] is not found!"); } return(null); }