//添加任务配置 protected void AddConfig(TEnum type, TaskConfigData config) { int enumIndex = Enum <TEnum> .Int(type); if (ConfigData.ContainsKey(enumIndex)) { CLog.Error("错误!重复AddConfig:{0}", type.ToString()); return; } ConfigData.Add(enumIndex, config); }
public void Spawn(WorldWeatherType type, Vector2 index) { if (Data.ContainsKey(index.ToString())) { return; } if (index.x >= RealCount || index.y >= RealCount) { return; } if (!ConfigData.ContainsKey(type)) { return; } Vector2 pos = PosIndex[(int)index.x, (int)index.y]; Vector3 realPos = new Vector3(pos.x, BaseSceneObject.GetAbsHeight(pos.x, pos.y), pos.y); realPos.x += RandUtil.RandFloat(-50, 50); realPos.z += RandUtil.RandFloat(-50, 50); var perform = PerfomMgr.Spawn(ConfigData[type].Rand(), realPos, Quaternion.identity); Data.Add(index.ToString(), new WorldWeatherData(RandUtil.RandInt(50, 400), perform)); }
public virtual void Init(BaseUnit selfUnit) { if (selfUnit == null) { CLog.Error("Objectiver.Init:selfUnit==null"); return; } SelfBaseUnit = selfUnit; OnAddConfig(); Enum <TEnum> .ForIndex(x => { int enumIndex = x; AssignedTask.Add(enumIndex, new HashSet <Task>()); TypedTask.Add(enumIndex, new List <Task>()); TypeIdles.Add(enumIndex, new HashList <TUnit>()); if (!ConfigData.ContainsKey(enumIndex)) { CLog.Error("错误!{0}:没有配置ConfigData", x.ToString()); } }); BaseUnit.Callback_OnRealDeathG += OnRealDeathG; }