public CSCreator MultiCreateCreator(int TeamNum) { if (otherCreators.ContainsKey(TeamNum)) { Debug.Log("This TeamNum [" + TeamNum.ToString() + "] is exsit"); return(null); } CSCreator creator = null; GameObject go = new GameObject(); go.transform.parent = transform; go.name = "Team " + TeamNum + " Managed Creator"; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; CSMgCreator mgCreator = go.AddComponent <CSMgCreator>(); creator = mgCreator; CSConst.CreatorType type = CSConst.CreatorType.Managed; creator.m_DataInst = CSDataMgr.CreateDataInst(TeamNum, type); mgCreator.m_Clod = CSClodsMgr.CreateClod(TeamNum); mgCreator.teamNum = TeamNum; otherCreators.Add(TeamNum, creator); return(creator); }
// <CSVD> Main Data Managers Imports public static void Import(byte[] buffer) { Clear(); if (buffer == null) { return; } if (buffer.Length < 8) { return; } if (debugSwitch) { Debug.Log("<color=yellow>" + "Start to Import CSDataMgr" + "</color>"); } MemoryStream ms = new MemoryStream(buffer); BinaryReader r = new BinaryReader(ms); int version = r.ReadInt32(); if (debugSwitch) { Debug.Log("<color=yellow>" + "version:" + version + "</color>"); } if (CUR_VERSION != version) { if (debugSwitch) { Debug.LogWarning("The version of ColonyrecordMgr is newer than the record."); } } if (version >= VERSION000) { int count = r.ReadInt32(); for (int i = 0; i < count; i++) { CSDataInst dataInst = new CSDataInst(); if (debugSwitch) { Debug.Log("<color=yellow>" + i + " count: " + count + "</color>"); } dataInst.m_ID = r.ReadInt32(); if (debugSwitch) { Debug.Log("<color=yellow>" + "m_ID: " + dataInst.m_ID + "</color>"); } dataInst.Import(r); m_DataInsts.Add(dataInst.m_ID, dataInst); } CSClodMgr.Init(); CSClodMgr.Instance.Import(r); CSClodsMgr.Init(); CSClodsMgr.Instance.Import(r); //CSSimulatorDataMgr.ImportMgrs(r, version); } }
public static void Init() { if (s_Instance == null) { s_Instance = new CSClodsMgr(); } }
public static void Clear() { foreach (CSDataInst dataInst in m_DataInsts.Values) { dataInst.ClearData(); } m_DataInsts.Clear(); CSClodMgr.Clear(); CSClodsMgr.Clear(); }
void Awake() { if (s_Instance != null) { Debug.LogError("CSMain must be only one!"); } else { s_Instance = this; } CSEntityLayerIndex = Pathea.Layer.Building; m_Creators = new Dictionary <int, CSCreator>(); if (GameConfig.IsMultiMode) { otherCreators = new Dictionary <int, CSCreator>(); } CSClodMgr.Init(); CSClodsMgr.Init(); CSCreator defMgCreator = CreateCreator(CSConst.ciDefMgCamp, "Default Managed Creator"); if (GameConfig.IsMultiMode) { defMgCreator.teamNum = BaseNetwork.MainPlayer.TeamId; Debug.Log("Main Creator team: " + defMgCreator.teamNum); } CreateCreator(CSConst.ciDefNoMgCamp, "Default Non-Managed Creator", CSConst.CreatorType.NoManaged); DigTerrainManager.onDirtyVoxel += OnDirtyVoxel; FarmManager.Instance.CreatePlantEvent += OnCreatePlant; FarmManager.Instance.RemovePlantEvent += OnRemovePlant; DigTerrainManager.onDigTerrain += OnDigTerrain; // DefmgCreator UI //if ( CSUI_Main.Instance != null) //{ // CSUI_Main.Instance.Creator = defMgCreator; //} if (CSUI_MainWndCtrl.Instance != null) { CSUI_MainWndCtrl.Instance.Creator = defMgCreator; } if (InitOperatItemEvent != null) { InitOperatItemEvent(); InitOperatItemEvent = null; } }
public CSCreator CreateCreator(int ID, string desc, CSConst.CreatorType type = CSConst.CreatorType.Managed) { if (m_Creators.ContainsKey(ID)) { Debug.Log("This ID [" + ID.ToString() + "] is exsit"); return(null); } CSCreator creator = null; if (type == CSConst.CreatorType.Managed) { GameObject go = new GameObject(); go.transform.parent = transform; go.name = desc; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; CSMgCreator mgCreator = go.AddComponent <CSMgCreator>(); creator = mgCreator; creator.m_DataInst = CSDataMgr.CreateDataInst(ID, type); mgCreator.m_Clod = CSClodsMgr.CreateClod(ID); m_Creators.Add(ID, creator); } else if (type == CSConst.CreatorType.NoManaged) { GameObject go = new GameObject(); go.transform.parent = transform; go.name = desc; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; creator = go.AddComponent <CSNoMgCreator>(); creator.m_DataInst = CSDataMgr.CreateDataInst(ID, type); m_Creators.Add(ID, creator); } return(creator); }