コード例 #1
0
ファイル: Receive.cs プロジェクト: Kukks/CryBits
    private static void Write_Classes(byte Index, NetIncomingMessage Data)
    {
        // Verifica se o jogador realmente tem permissão
        if (Lists.Player[Index].Acess < Game.Accesses.Editor)
        {
            Send.Alert(Index, "You aren't allowed to do this.");
            return;
        }

        // Quantidade de classes
        Lists.Class = new Lists.Structures.Class[Data.ReadByte()];
        Lists.Server_Data.Num_Classes = (byte)Lists.Class.GetUpperBound(0);
        Write.Server_Data();

        for (short i = 1; i < Lists.Class.Length; i++)
        {
            // Redimensiona os valores necessários
            Lists.Class[i]            = new Lists.Structures.Class();
            Lists.Class[i].Vital      = new short[(byte)Game.Vitals.Count];
            Lists.Class[i].Attribute  = new short[(byte)Game.Attributes.Count];
            Lists.Class[i].Tex_Male   = new short[Data.ReadByte()];
            Lists.Class[i].Tex_Female = new short[Data.ReadByte()];
            Lists.Class[i].Item       = new System.Tuple <short, short> [Data.ReadByte()];

            // Lê os dados
            Lists.Class[i].Name        = Data.ReadString();
            Lists.Class[i].Description = Data.ReadString();
            for (byte t = 0; t < Lists.Class[i].Tex_Male.Length; t++)
            {
                Lists.Class[i].Tex_Male[t] = Data.ReadInt16();
            }
            for (byte t = 0; t < Lists.Class[i].Tex_Female.Length; t++)
            {
                Lists.Class[i].Tex_Female[t] = Data.ReadInt16();
            }
            Lists.Class[i].Spawn_Map       = Data.ReadInt16();
            Lists.Class[i].Spawn_Direction = Data.ReadByte();
            Lists.Class[i].Spawn_X         = Data.ReadByte();
            Lists.Class[i].Spawn_Y         = Data.ReadByte();
            for (byte v = 0; v < (byte)Game.Vitals.Count; v++)
            {
                Lists.Class[i].Vital[v] = Data.ReadInt16();
            }
            for (byte a = 0; a < (byte)Game.Attributes.Count; a++)
            {
                Lists.Class[i].Attribute[a] = Data.ReadInt16();
            }
            for (byte n = 0; n < (byte)Lists.Class[i].Item.Length; n++)
            {
                Lists.Class[i].Item[n] = new System.Tuple <short, short>(Data.ReadInt16(), Data.ReadInt16());
            }
        }

        // Salva os dados e envia pra todos jogadores conectados
        Write.Classes();
        for (byte i = 1; i <= Game.HigherIndex; i++)
        {
            if (i != Index)
            {
                Send.Classes(i);
            }
        }
    }