コード例 #1
0
    private static void SaveMesh(CAIBakedNavmesh targ, string filePath)
    {
        if (filePath.Length == 0 || !targ.HasNavmesh)
        {
            return;
        }

        FileStream      fs        = null;
        BinaryFormatter formatter = new BinaryFormatter();

        try
        {
            fs = new FileStream(filePath, FileMode.Create);
            formatter.Serialize(fs, targ.GetNavmesh().GetSerializedMesh());
        }
        catch (System.Exception ex)
        {
            Debug.LogError(targ.name + ": BakedNavmesh: Save bytes failed: "
                           + ex.Message);
        }
        finally
        {
            if (fs != null)
            {
                fs.Close();
            }
        }


        FileStream pFileStream = null;

        try
        {
            byte[] meshData = targ.GetNavmesh().GetSerializedMesh();
            pFileStream = new FileStream(filePath + ".byte", FileMode.OpenOrCreate);
            pFileStream.Write(meshData, 0, meshData.Length);
        }
        catch
        {
            //return false;
        }
        finally
        {
            if (pFileStream != null)
            {
                pFileStream.Close();
            }
        }

        //return true;
    }
コード例 #2
0
ファイル: BattleManager.cs プロジェクト: niuniuzhu/Lockstep
        public static void Init(BattleParams param)
        {
            _init = true;
            _shouldSendActions = false;

            string          model       = ModelFactory.GetBattleData(Utils.GetIDFromRID(param.id)).model;
            CAIBakedNavmesh navmeshData = AssetsManager.LoadAsset <CAIBakedNavmesh>("scene/" + model + "_navmesh",
                                                                                    "CAIBakedNavmesh");

            _framesPerKeyFrame = param.framesPerKeyFrame;
            _frameRate         = param.frameRate;
            _nextKeyFrame      = param.framesPerKeyFrame;

            cBattle = new VBattle(param);
            lBattle = new Battle(param, navmeshData.GetNavmesh(), Env.LUA_ENV);

            _logicThread = new Thread(LogicWorker);
            _logicThread.IsBackground = true;
            _logicThread.Start();

            NetModule.instance.AddACMDListener(Module.BATTLE, Command.ACMD_BATTLE_START, HandleBattleStart);
            NetModule.instance.AddACMDListener(Module.BATTLE, Command.ACMD_FRAME, HandleFrame);
            NetModule.instance.AddACMDListener(Module.BATTLE, Command.ACMD_BATTLE_END, HandleBattleEnd);
            NetModule.instance.Send(ProtocolManager.PACKET_BATTLE_QCMD_BATTLE_CREATED());
        }
コード例 #3
0
    private static void SaveMesh(CAIBakedNavmesh targ, string filePath)
    {
        if (filePath.Length == 0 || !targ.HasNavmesh)
        {
            return;
        }

        FileStream      fs        = null;
        BinaryFormatter formatter = new BinaryFormatter();

        try
        {
            fs = new FileStream(filePath, FileMode.Create);
            formatter.Serialize(fs, targ.GetNavmesh().GetSerializedMesh());
        }
        catch (System.Exception ex)
        {
            Debug.LogError(targ.name + ": BakedNavmesh: Save bytes failed: "
                           + ex.Message);
        }
        finally
        {
            if (fs != null)
            {
                fs.Close();
            }
        }
    }
コード例 #4
0
    private static void SaveMesh(CAIBakedNavmesh targ, string filePath)
    {
        if (filePath.Length == 0 || !targ.HasNavmesh)
        {
            return;
        }

        FileStream      fs        = null;
        BinaryFormatter formatter = new BinaryFormatter();

        try
        {
            fs = new FileStream(filePath, FileMode.Create);
            formatter.Serialize(fs, targ.GetNavmesh().GetSerializedMesh());
        }
        catch (System.Exception ex)
        {
            Debug.LogError(targ.name + ": BakedNavmesh: Save bytes failed: "
                           + ex.Message);
        }
        finally
        {
            if (fs != null)
            {
                fs.Close();
            }
        }

        fs = new FileStream(filePath, FileMode.Open);

        System.Object obj   = formatter.Deserialize(fs);
        byte[]        datas = (byte[])obj;

        string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(filePath);

        filePath = filePath.Replace(fileNameWithoutExtension + ".", "NFServer_" + fileNameWithoutExtension + ".");
        FileStream fs1 = new FileStream(filePath, FileMode.Create, FileAccess.Write);

        fs1.Write(datas, 0, datas.Length);
        fs1.Close();
        fs.Close();
    }
コード例 #5
0
    private static void SaveMesh(CAIBakedNavmesh targ, string filePath)
    {
        if (filePath.Length == 0 || !targ.HasNavmesh)
            return;

        FileStream fs = null;
        BinaryFormatter formatter = new BinaryFormatter();

        try
        {
            fs = new FileStream(filePath, FileMode.Create);
            formatter.Serialize(fs, targ.GetNavmesh().GetSerializedMesh());
        }
        catch (System.Exception ex)
        {
            Debug.LogError(targ.name + ": BakedNavmesh: Save bytes failed: "
                + ex.Message);
        }
        finally
        {
            if (fs != null)
                fs.Close();
        }
        
        fs = new FileStream(filePath, FileMode.Open); 
        
        System.Object obj = formatter.Deserialize(fs);
		byte[] datas = (byte[])obj;
		
		string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(filePath);
		filePath = filePath.Replace(fileNameWithoutExtension + ".", "srv_" + fileNameWithoutExtension + ".");
		FileStream fs1 = new FileStream(filePath, FileMode.Create, FileAccess.Write);
        fs1.Write(datas, 0, datas.Length);
        fs1.Close();
        fs.Close();
    }
コード例 #6
0
ファイル: CAIBakedNavmeshEditor.cs プロジェクト: oathx/Six
    private static void SaveMesh(CAIBakedNavmesh targ, string szFilePath)
    {
		if (!string.IsNullOrEmpty(szFilePath) && targ.HasNavmesh)
		{
			string szFileName = GetFileName(szFilePath, true);
			if (szFileName.Length > 0)
			{
				FileStream stream = new FileStream(
					szFilePath, FileMode.Create
					);

				// serialize the file stream
				BinaryFormatter formatter = new BinaryFormatter();
				formatter.Serialize(
					stream, targ.GetNavmesh().GetSerializedMesh()
					);
				
				stream.Close();

				int nStart 	= szFilePath.LastIndexOf("/");
				int nEnd 	= szFilePath.LastIndexOf(".");

				string szServerFilePath = szFilePath.Substring (0, nStart + 1);
				if (!string.IsNullOrEmpty(szServerFilePath))
				{
					// save to server file
					FileStream hStream = new FileStream(
						szFilePath, FileMode.Open
						);
					System.Object bytes = formatter.Deserialize(hStream);
					byte[] datas = (byte[])bytes;

					FileStream hServer = new FileStream(szServerFilePath + szFileName + ".snav", FileMode.Create, FileAccess.Write);
					hServer.Write(datas, 0, datas.Length);

					hServer.Close();
					hStream.Close();

					// export obj file
					if (bExportObj)
					{
						CAIObjFileExport.ExportObj (szServerFilePath);
					}
				}
			}
		}
    }
コード例 #7
0
    private static void SaveMesh(CAIBakedNavmesh targ, string filePath)
    {
        if (filePath.Length == 0 || !targ.HasNavmesh)
            return;

        FileStream fs = null;
        BinaryFormatter formatter = new BinaryFormatter();

        try
        {
            fs = new FileStream(filePath, FileMode.Create);
            formatter.Serialize(fs, targ.GetNavmesh().GetSerializedMesh());
        }
        catch (System.Exception ex)
        {
            Debug.LogError(targ.name + ": BakedNavmesh: Save bytes failed: "
                + ex.Message);
        }
        finally
        {
            if (fs != null)
                fs.Close();
        }
    }