Example #1
0
    void CreateBuilding(StoryTownData sTD)
    {
//		BlockBuilding bb = BlockBuilding.GetBuilding(sTD.mBuildingId);
//
//        List<Vector3> npcPositionList;
//        List<CreatItemInfo> itemInfoList;
//        Dictionary<int, BuildingNpc> npcIdNum;
//		Vector3 size;
////        Dictionary<IntVector3, B45Block> retBuild = BuildBlockManager.self.BuildBuilding(sTD.mPosition, sTD.mBuildingId, sTD.mRot, out size
////			, out npcPositionList, out itemInfoList, out npcIdNum);
//		Dictionary<IntVector3, B45Block> retBuild = new Dictionary<IntVector3, B45Block>
//
//		foreach(IntVector3 index in retBuild.Keys)
//			Block45Man.self.DataSource.SafeWrite(retBuild[index], index.x, index.y, index.z, 0);
//
//		foreach(CreatItemInfo cii in itemInfoList)
//			DragArticleAgent.PutItemByProroId(cii.mItemId, cii.mPos, cii.mRotation);
//
//
//		List<int> missionIdList = new List<int>();
//
//		foreach(int missionId in npcIdNum.Keys)
//				missionIdList.Add(missionId);
//
//		int npcPosIndex = 0;
//		for(int i = 0; i < missionIdList.Count; i++)
//		{
//			if(i < npcPositionList.Count)
//			{
//				if (!NpcMissionDataRepository.m_AdRandMisNpcData.ContainsKey(missionIdList[i]))
//		        {
//		            LogManager.Error("not exist! id: ", missionIdList[i], " Pos: ", npcPositionList[npcPosIndex]);
//		            continue;
//		        }
//		        Vector3 npcPos = npcPositionList[npcPosIndex] + 0.2f * Vector3.up;
//
//	            AdNpcData adNpcData = NpcMissionDataRepository.m_AdRandMisNpcData[missionIdList[i]];
//	            int RNpcId = adNpcData.mRnpc_ID;
//	            int Qid = adNpcData.mQC_ID;
//
//                //NpcRandom nr = NpcManager.Instance.CreateRandomNpc(RNpcId, npcPos);
//                //StroyManager.Instance.NpcTakeMission(RNpcId, Qid,npcPos, nr, adNpcData.m_CSRecruitMissionList);
//
//                //mNpcList.Add(nr.mNpcId);
//			}
//		}
    }
Example #2
0
    public void LoadData()
    {
//
        string _strFilePath = GameConfig.GetUserDataPath() + "/PlanetExplorers/Building/StoryBuildings.txt";

        if (File.Exists(_strFilePath))
        {
            using (FileStream _fileStream = new FileStream(_strFilePath, FileMode.Open, FileAccess.Read))
            {
                BinaryReader _in         = new BinaryReader(_fileStream);
                int          readVersion = _in.ReadInt32();
                switch (readVersion)
                {
                case 1:
                    int count = _in.ReadInt32();
                    for (int i = 0; i < count; i++)
                    {
                        StoryTownData sTD = new StoryTownData();
                        sTD.mId         = i;
                        sTD.mBuildingId = _in.ReadInt32();
                        sTD.mPosition   = new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle());;
                        sTD.mRot        = _in.ReadInt32();
                        mTownDataList.Add(sTD);
                    }
                    break;
                }
                _in.Close();
            }
        }
        else
        {
            _strFilePath = "StoryBuildings";
            UnityEngine.Object file = Resources.Load(_strFilePath);
            if (file)
            {
                TextAsset    textFile    = file as TextAsset;
                MemoryStream ms          = new MemoryStream(textFile.bytes);
                BinaryReader _in         = new BinaryReader(ms);
                int          readVersion = _in.ReadInt32();
                switch (readVersion)
                {
                case 1:
                    int count = _in.ReadInt32();
                    for (int i = 0; i < count; i++)
                    {
                        StoryTownData sTD = new StoryTownData();
                        sTD.mId         = i;
                        sTD.mBuildingId = _in.ReadInt32();
                        sTD.mPosition   = new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle());;
                        sTD.mRot        = _in.ReadInt32();
                        mTownDataList.Add(sTD);
                    }
                    break;
                }
                _in.Close();
                //			Resources.UnloadAsset(file);
            }
        }


        //if (!GameConfig.IsMultiMode && Record.m_RecordBuffer.ContainsKey((int)Record.RecordIndex.RECORD_STORYTOWN))
        //    Import(Record.m_RecordBuffer[(int)Record.RecordIndex.RECORD_STORYTOWN]);

        for (int i = 0; i < mTownDataList.Count; i++)
        {
            if (!mActivelist.Contains(mTownDataList[i].mId))
            {
                mUnactivedList.Add(mTownDataList[i]);
            }
        }
    }