Exemplo n.º 1
0
    // <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);
        }
    }
Exemplo n.º 2
0
 public static CSDataInst CreateDataInst(int id, CSConst.CreatorType type)
 {
     if (m_DataInsts.ContainsKey(id))
     {
         Debug.Log("Still have this data inst.");
         return(m_DataInsts[id]);
     }
     else
     {
         CSDataInst dataInst = new CSDataInst();
         dataInst.m_ID   = id;
         dataInst.m_Type = type;
         m_DataInsts.Add(id, dataInst);
         return(dataInst);
     }
 }