コード例 #1
0
ファイル: NetServer.cs プロジェクト: XspeedPL/PaintKiller
 /// <summary>Writes data of a single game object into a packet</summary>
 /// <param name="data">The output packet</param>
 /// <param name="go">A game object to extract data from</param>
 private void WriteData(NetPacket.Factory data, GameObj go)
 {
     data.WriteUInt(go.ID);
     data.WriteString(go.GetType().FullName);
     data.WriteShort(go.hp);
     data.WriteShort(go.mp);
     data.WriteByte(go.state);
     data.WriteByte(go.frame);
     data.WriteFloat(go.dir);
     data.WriteFloat(go.ang.X);
     data.WriteFloat(go.ang.Y);
     data.WriteFloat(go.spd.X);
     data.WriteFloat(go.spd.Y);
     data.WriteFloat(go.pos.X);
     data.WriteFloat(go.pos.Y);
     data.WriteFloat(go.fce.X);
     data.WriteFloat(go.fce.Y);
     // TODO: Add a member method into GameObj for writing/reading?
     if (go is GEC)
     {
         GEC g = (GEC)go;
         data.WriteString(g.gfx.Name);
         data.WriteByte(g.GetPrefs());
     }
     else if (go is GPChain)
     {
         GPChain g = (GPChain)go;
         data.WriteFloat(g.GetBoltDest().X);
         data.WriteFloat(g.GetBoltDest().Y);
     }
 }