Пример #1
0
        public virtual int Size()
        {
            int nSize = 0;

            try {
                nSize += ErrorCode_Serializer.Size(error_code);
                nSize += sizeof(int);
                nSize += sizeof(int);
                nSize += sizeof(int);
                foreach (var tiles_itr in tiles)
                {
                    DungeonTileType tiles_elmt = tiles_itr;
                    nSize += DungeonTileType_Serializer.Size(tiles_elmt);
                }
                nSize += sizeof(ulong);
                nSize += Vector2Int_Serializer.Size(position);
                nSize += sizeof(int);
                foreach (var comrades_itr in comrades)
                {
                    Player comrades_elmt = comrades_itr;
                    nSize += Player_Serializer.Size(comrades_elmt);
                }
                nSize += sizeof(int);
                foreach (var enemies_itr in enemies)
                {
                    Monster enemies_elmt = enemies_itr;
                    nSize += Monster_Serializer.Size(enemies_elmt);
                }
            } catch (System.Exception) {
                return(-1);
            }
            return(nSize);
        }
Пример #2
0
        public virtual int Size()
        {
            int nSize = 0;

            try {
                nSize += Vector2Int_Serializer.Size(destination);
            } catch (System.Exception) {
                return(-1);
            }
            return(nSize);
        }
Пример #3
0
        public virtual int Size()
        {
            int nSize = 0;

            try {
                nSize += sizeof(ulong);
                nSize += Vector2Int_Serializer.Size(position);
            } catch (System.Exception) {
                return(-1);
            }
            return(nSize);
        }
Пример #4
0
 public virtual bool Load(MemoryStream _buf_)
 {
     try {
         if (false == Vector2Int_Serializer.Load(ref destination, _buf_))
         {
             return(false);
         }
     } catch (System.Exception) {
         return(false);
     }
     return(true);
 }
Пример #5
0
 public virtual bool Store(MemoryStream _buf_)
 {
     try {
         if (false == Vector2Int_Serializer.Store(_buf_, destination))
         {
             return(false);
         }
     } catch (System.Exception) {
         return(false);
     }
     return(true);
 }
Пример #6
0
 public virtual bool Store(MemoryStream _buf_)
 {
     try {
         _buf_.Write(BitConverter.GetBytes(unit_seq), 0, sizeof(ulong));
         if (false == Vector2Int_Serializer.Store(_buf_, position))
         {
             return(false);
         }
     } catch (System.Exception) {
         return(false);
     }
     return(true);
 }
Пример #7
0
 public virtual bool Store(MemoryStream _buf_)
 {
     try {
         if (false == ErrorCode_Serializer.Store(_buf_, error_code))
         {
             return(false);
         }
         _buf_.Write(BitConverter.GetBytes(width), 0, sizeof(int));
         _buf_.Write(BitConverter.GetBytes(height), 0, sizeof(int));
         _buf_.Write(BitConverter.GetBytes(tiles.Count), 0, sizeof(int));
         foreach (var tiles_itr in tiles)
         {
             DungeonTileType tiles_elmt = tiles_itr;
             if (false == DungeonTileType_Serializer.Store(_buf_, tiles_elmt))
             {
                 return(false);
             }
         }
         _buf_.Write(BitConverter.GetBytes(unit_seq), 0, sizeof(ulong));
         if (false == Vector2Int_Serializer.Store(_buf_, position))
         {
             return(false);
         }
         _buf_.Write(BitConverter.GetBytes(comrades.Count), 0, sizeof(int));
         foreach (var comrades_itr in comrades)
         {
             Player comrades_elmt = comrades_itr;
             if (false == Player_Serializer.Store(_buf_, comrades_elmt))
             {
                 return(false);
             }
         }
         _buf_.Write(BitConverter.GetBytes(enemies.Count), 0, sizeof(int));
         foreach (var enemies_itr in enemies)
         {
             Monster enemies_elmt = enemies_itr;
             if (false == Monster_Serializer.Store(_buf_, enemies_elmt))
             {
                 return(false);
             }
         }
     } catch (System.Exception) {
         return(false);
     }
     return(true);
 }
Пример #8
0
 public virtual bool Load(MemoryStream _buf_)
 {
     try {
         if (sizeof(ulong) > _buf_.Length - _buf_.Position)
         {
             return(false);
         }
         unit_seq        = BitConverter.ToUInt64(_buf_.GetBuffer(), (int)_buf_.Position);
         _buf_.Position += sizeof(ulong);
         if (false == Vector2Int_Serializer.Load(ref position, _buf_))
         {
             return(false);
         }
     } catch (System.Exception) {
         return(false);
     }
     return(true);
 }
Пример #9
0
 public virtual bool Load(MemoryStream _buf_)
 {
     try {
         if (false == ErrorCode_Serializer.Load(ref error_code, _buf_))
         {
             return(false);
         }
         if (sizeof(int) > _buf_.Length - _buf_.Position)
         {
             return(false);
         }
         width           = BitConverter.ToInt32(_buf_.GetBuffer(), (int)_buf_.Position);
         _buf_.Position += sizeof(int);
         if (sizeof(int) > _buf_.Length - _buf_.Position)
         {
             return(false);
         }
         height          = BitConverter.ToInt32(_buf_.GetBuffer(), (int)_buf_.Position);
         _buf_.Position += sizeof(int);
         if (sizeof(int) > _buf_.Length - _buf_.Position)
         {
             return(false);
         }
         int tiles_length = BitConverter.ToInt32(_buf_.GetBuffer(), (int)_buf_.Position);
         _buf_.Position += sizeof(int);
         for (int tiles_itr = 0; tiles_itr < tiles_length; tiles_itr++)
         {
             DungeonTileType tiles_val = new DungeonTileType();
             if (false == DungeonTileType_Serializer.Load(ref tiles_val, _buf_))
             {
                 return(false);
             }
             tiles.Add(tiles_val);
         }
         if (sizeof(ulong) > _buf_.Length - _buf_.Position)
         {
             return(false);
         }
         unit_seq        = BitConverter.ToUInt64(_buf_.GetBuffer(), (int)_buf_.Position);
         _buf_.Position += sizeof(ulong);
         if (false == Vector2Int_Serializer.Load(ref position, _buf_))
         {
             return(false);
         }
         if (sizeof(int) > _buf_.Length - _buf_.Position)
         {
             return(false);
         }
         int comrades_length = BitConverter.ToInt32(_buf_.GetBuffer(), (int)_buf_.Position);
         _buf_.Position += sizeof(int);
         for (int comrades_itr = 0; comrades_itr < comrades_length; comrades_itr++)
         {
             Player comrades_val = new Player();
             if (false == Player_Serializer.Load(ref comrades_val, _buf_))
             {
                 return(false);
             }
             comrades.Add(comrades_val);
         }
         if (sizeof(int) > _buf_.Length - _buf_.Position)
         {
             return(false);
         }
         int enemies_length = BitConverter.ToInt32(_buf_.GetBuffer(), (int)_buf_.Position);
         _buf_.Position += sizeof(int);
         for (int enemies_itr = 0; enemies_itr < enemies_length; enemies_itr++)
         {
             Monster enemies_val = new Monster();
             if (false == Monster_Serializer.Load(ref enemies_val, _buf_))
             {
                 return(false);
             }
             enemies.Add(enemies_val);
         }
     } catch (System.Exception) {
         return(false);
     }
     return(true);
 }