Esempio n. 1
0
    /// <summary>
    /// 同步切换到的技能栏的序号。
    /// </summary>
    /// <param name="instant">发生时刻</param>
    /// <param name="skillIndex">技能栏序号</param>
    public static void SyncSwitchSkill(Unit unit, long instant, int skillIndex)
    {
        ProtocolBytes protocol = SF.GetProtocolHead(ProtoName.SyncSwitchSkill); //16 bits

        protocol.AddInt((int)instant);                                          //32 bits
        protocol.AddByte((byte)unit.attributes.ID);                             //8 bits
        protocol.AddByte((byte)skillIndex);                                     //32 bits
        Client.Instance.Send(protocol);
    }
Esempio n. 2
0
    public static void SyncAimTarget(long instant, int sourceId, int targetId)
    {
        ProtocolBytes protocol = SF.GetProtocolHead(ProtoName.SyncAimTarget);

        protocol.AddInt((int)instant);
        protocol.AddByte((byte)sourceId);
        protocol.AddByte((byte)targetId);

        Client.Instance.Send(protocol);
    }
Esempio n. 3
0
    /// <summary>
    /// 同步移动控制轴的值。即水平轴和垂直轴的值。
    /// </summary>
    /// <param name="instant">发生时刻</param>
    /// <param name="h">水平轴的值 Horizontal Axis</param>
    /// <param name="v">垂直轴的值 Vertical Axis</param>
    public static void SyncMobileControlAxes(Unit unit, long instant, int h, int v, Vector3 cameraFwd)
    {
        ProtocolBytes protocol = SF.GetProtocolHead(ProtoName.SyncMobileControlAxes);

        protocol.AddInt((int)instant);              //instant
        protocol.AddByte((byte)unit.attributes.ID); //unit id
        protocol.AddByte(PackHaV(h, v));            //h and v
        AppendVector3(protocol, cameraFwd);         // camera forward

        Client.Instance.Send(protocol);
    }
Esempio n. 4
0
    /// <summary>
    /// Destroy a object.
    /// </summary>
    /// <param name="id">The id of the unit that being destroyed</param>
    public static void DestroyObj(byte id)
    {
        ProtocolBytes protocol = SF.GetProtocolHead(ProtoName.DestroyObj);

        protocol.AddByte(id);
        Client.Instance.Send(protocol);
    }
Esempio n. 5
0
    /// <summary>
    /// 同步鼠标左键松开事件。
    /// </summary>
    /// <param name="instant">发生时刻</param>
    public static void SyncMouseButton0Up(Unit unit, long instant)
    {
        ProtocolBytes protocol = SF.GetProtocolHead(ProtoName.SyncMouseButton0Up); //16 bits

        protocol.AddInt((int)instant);                                             //32 bits
        protocol.AddByte((byte)unit.attributes.ID);;                               //8 bits
        Client.Instance.Send(protocol);
    }
Esempio n. 6
0
    /// <summary>
    /// Send a message to server, which includes the message of unit and applies for permission.
    /// </summary>
    /// <param name="unit">The unit type enum</param>
    /// <param name="isLocal">Is this object local</param>
    /// <param name="position">The position of the unit that would be created at</param>
    /// <param name="rotation">The rotation of the unit</param>
    public static void CreateObject(UnitName unit, Vector3 position, Quaternion rotation)
    {
        ProtocolBytes protocol = SF.GetProtocolHead(ProtoName.CreateObject);

        protocol.AddByte((byte)unit);         //UnitName
        AppendVector3(protocol, position);    //Position
        AppendQuaternion(protocol, rotation); //Rotation
        Client.Instance.Send(protocol);
    }
Esempio n. 7
0
    /// <summary>
    /// 同步单位的魔法值。
    /// </summary>
    /// <param name="instant">时刻,即单位处于该魔法值的时刻</param>
    /// <param name="MP">单位的魔法值</param>
    public static void SyncMP(Unit unit, long instant, float MP)
    {
        //8 bits
        ProtocolBytes protocol = SF.GetProtocolHead(ProtoName.SyncMP);

        //32 bits
        protocol.AddInt((int)instant);
        //8 bits
        protocol.AddByte((byte)unit.attributes.ID);
        //32 bits
        protocol.AddFloat(MP);
        Client.Instance.Send(protocol);
    }
Esempio n. 8
0
    public static void SyncTransform(Unit unit, long instant, Vector3 position, Quaternion rotation, float speed)
    {
        //8 bits
        ProtocolBytes protocol = SF.GetProtocolHead(ProtoName.SyncTransform);

        //32 bits
        protocol.AddInt((int)instant);
        //8 bits
        protocol.AddByte((byte)unit.attributes.ID);
        //96 bits
        AppendVector3(protocol, position);
        //128 bits
        AppendQuaternion(protocol, rotation);
        //32 bits
        protocol.AddFloat(speed);

        Client.Instance.Send(protocol);
    }