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
    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;
        }
    }