private void ChoiseMap(TerrainEditorData data)
 {
     m_Instance.Close();
     m_Instance = null;
     TerrainEditorWindow.Instance.OpenTerrain(data);
     EditorWindow.FocusWindowIfItsOpen(typeof(TerrainEditorWindow));
 }
 public void Read (TProtocol iprot)
 {
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 1:
         if (field.Type == TType.List) {
           {
             DataList = new List<TerrainEditorData>();
             TList _list8 = iprot.ReadListBegin();
             for( int _i9 = 0; _i9 < _list8.Count; ++_i9)
             {
               TerrainEditorData _elem10 = new TerrainEditorData();
               _elem10 = new TerrainEditorData();
               _elem10.Read(iprot);
               DataList.Add(_elem10);
             }
             iprot.ReadListEnd();
           }
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
 }
    public void SaveTerrainEditFileList(TerrainEditorDataArray filedata, TerrainEditorData editorData)
    {
        if (null == filedata)
        {
            filedata = new TerrainEditorDataArray();
            filedata.DataList = new System.Collections.Generic.List<TerrainEditorData>();
        }

        if (null != editorData)
        {
            bool bIsNeedAddNew = true;
            for (int i = 0; i < filedata.DataList.Count; ++i)
            {
                if (filedata.DataList[i].ID == editorData.ID)
                {
                    filedata.DataList[i] = editorData;
                    bIsNeedAddNew = false;
                    break;
                }
            }
            if (bIsNeedAddNew)
            {
                filedata.DataList.Add(editorData);
            }
        }

        byte[] data = ThriftSerialize.Serialize(filedata);
        FileUtils.WriteByteFile(m_strDataPath, data);

    }
    private void SaveData()
    {
        if (null == m_TriggerList)
        {
            EditorUtility.DisplayDialog("保存失败","!!!", "ok");
            return;
        }
        if (string.IsNullOrEmpty(m_CurrentEditiongMapName) || string.IsNullOrEmpty(m_CurrentMapResPath) || m_CurrentEditiongMapId <= 0)
        {
            EditorUtility.DisplayDialog("保存失败", "地图信息不完整", "ok");
            return;
        }
        if (null == m_PlayerChar)
        {
            EditorUtility.DisplayDialog("保存失败","必须编辑玩家的出生位置", "ok");
            return;
        }
        m_OutputData = new TerrainEditorData();
        m_OutputData.ID = m_CurrentEditiongMapId;
        m_OutputData.MapName = m_CurrentEditiongMapName;
        m_OutputData.MapResName = m_CurrentMapResPath;

        m_OutputData.TriggerDataList = new System.Collections.Generic.List<TerrainTriggerData>(m_TriggerList.Count);

        for (int i = 0; i < m_TriggerList.Count; ++i)
        {
            m_OutputData.TriggerDataList.Add(m_TriggerList[i].TriggerData);
        }

        m_OutputData.NpcDataList = new System.Collections.Generic.List<TerrainNpcData>(m_NpcList.Count);
        for (int i = 0; i < m_NpcList.Count; ++i)
        {
            m_OutputData.NpcDataList.Add(m_NpcList[i].m_NpcData);
        }
        m_OutputData.PlayerInitPos = new PlayerInitPosData();
        m_OutputData.PlayerInitPos.Pos = new ThriftVector3();
        m_OutputData.PlayerInitPos.Rot = new ThriftVector3();
        m_OutputData.PlayerInitPos.Id = m_PlayerChar.GetInstanceId();
        m_OutputData.PlayerInitPos.Pos.SetVector3(m_PlayerChar.GetTransformData().GetPosition());
        m_OutputData.PlayerInitPos.Rot.SetVector3(m_PlayerChar.GetTransformData().GetRotation());
        m_DataList = GetTerrainEditFileList();

        SaveTerrainEditFileList(m_DataList, m_OutputData);

    }
    public void OpenTerrain(TerrainEditorData data)
    {
        ClearData();

        m_bIsCreateNew = true;
        m_CurrentEditiongMapId = data.ID;
        m_CurrentEditiongMapName = data.MapName;
        m_MapNameInputBuffer = m_CurrentEditiongMapId.ToString();

        m_ObjMap = ResourceManager.Instance.LoadBuildInResource<GameObject>(data.MapResName, AssetType.Map);

        for (int i = 0; data.TriggerDataList != null && i < data.TriggerDataList.Count; ++i)
        {
            TerrainTriggerData elem = data.TriggerDataList[i];

            AddTrigger
                (elem.AreaType,
                elem.Pos.GetVector3(),
                elem.Rot.GetVector3(),
                elem.Scale.GetVector3(),
                elem.TargetMethodId,
                elem.EnterLimitMethodId,
                elem.ExitLimitMethodId,
                elem.EnterFuncMethodId,
                elem.ExitFuncMethodId
                );
        }
        for (int i = 0; null != data.NpcDataList && i < data.NpcDataList.Count; ++i)
        {
            TerrainNpcData elem = data.NpcDataList[i];

            AddNpc(elem.Id, elem.Pos.GetVector3(), elem.Rot.GetVector3(), elem.Scale.GetVector3());
        }

        PlayerInitPosData pos = data.PlayerInitPos;
        if (null != pos)
        {
            CreatePlayerCharactor(pos.Id, pos.Pos.GetVector3(), pos.Rot.GetVector3());
        }
    }
    private void Copy(TerrainEditorData data)
    {
        int max = 0;
        for (int i = 0; i < m_DataList.DataList.Count; ++i)
        {
            if (m_DataList.DataList[i].ID > max)
            {
                max = m_DataList.DataList[i].ID;
            }
        }
        ++ max;
        TerrainEditorData elem = new TerrainEditorData();
        elem.ID = max;
        elem.MapName = data.MapName;
        elem.MapResName = data.MapResName;
        elem.MapSceneName = data.MapSceneName;
        elem.NpcDataList = data.NpcDataList;
        elem.PlayerInitPos = data.PlayerInitPos;
        elem.TriggerDataList = data.TriggerDataList;

        m_DataList.DataList.Add(elem);

        Save();
    }