示例#1
0
    public void C2A_AddForceToBall(int sendFrom, Vector3 dir, Vector3 pos, Vector3 velocity)
    {
        var Item  = ProtocolMaker.Mk_C2A_AddForceToBall(sendFrom, dir, pos, velocity);
        var json  = ProtocolMaker.SerializeToJson(Item);
        var bytes = StrToByteArray(json);

        if (stream.CanWrite)
        {
            ClientBaseDebugLog("writed C2A_AddForceToBall");
            stream.Write(bytes, 0, bytes.Length);
        }
    }
示例#2
0
    public void C2A_RequestStartGame()
    {
        var Item  = ProtocolMaker.Mk_C2A_RequestStartGame();
        var json  = ProtocolMaker.SerializeToJson(Item);
        var bytes = StrToByteArray(json);

        if (stream.CanWrite)
        {
            ClientBaseDebugLog("writed C2A_RequestStartGame");
            stream.Write(bytes, 0, bytes.Length);
        }
    }
示例#3
0
    // public void A2C_UpdateLine()
    public void C2A_GameResult(int objectId)
    {
        var Item  = ProtocolMaker.Mk_C2A_GameResult(objectId);
        var json  = ProtocolMaker.SerializeToJson(Item);
        var bytes = StrToByteArray(json);

        if (stream.CanWrite)
        {
            ClientBaseDebugLog("writed C2A_GameResult");
            stream.Write(bytes, 0, bytes.Length);
        }
    }
示例#4
0
    public void C2A_UpdateLine(int sendFrom, LineController line, bool isCreate)
    {
        var Item  = ProtocolMaker.Mk_C2A_UpdateLine(sendFrom, line.lineId, line.transform.position, line.transform.eulerAngles, line.transform.localScale, isCreate);
        var json  = ProtocolMaker.SerializeToJson(Item);
        var bytes = StrToByteArray(json);

        if (stream.CanWrite)
        {
            ClientBaseDebugLog("writed C2A_UpdateLine");
            stream.Write(bytes, 0, bytes.Length);
        }
    }
示例#5
0
    public void A2C_AddForceToBall(ProtocolItem item)
    {
        ClientBaseDebugLog("A2C_AddForceToBall");

        if (item.sendFrom != SelfClientObjectID)
        {
            ClientBaseDebugLog("A2C_AddForceToBall  Excuted!!");
            FieldManager.GetInstance().Ball.SetupRemoteAddForece(
                ProtocolMaker.FormartVector_3ToVector3(item.vectorParam_1),
                ProtocolMaker.FormartVector_3ToVector3(item.vectorParam_2),
                ProtocolMaker.FormartVector_3ToVector3(item.vectorParam_3)
                );
        }
    }
示例#6
0
    public void A2C_UpdateLine(ProtocolItem item)
    {
        ClientBaseDebugLog("A2C_UpdateLine");

        if (item.sendFrom != SelfClientObjectID)
        {
            ClientBaseDebugLog("A2C_UpdateLine  Excuted!!" + item.boolParam);

            if (item.boolParam)
            {
                Debug.LogError("A2C_UpdateLine");
                var id  = item.objectId_1;
                var pos = ProtocolMaker.FormartVector_3ToVector3(item.vectorParam_1);
                var dir = ProtocolMaker.FormartVector_3ToVector3(item.vectorParam_2);
                var scl = ProtocolMaker.FormartVector_3ToVector3(item.vectorParam_3);
                FieldManager.GetInstance().OnRemoteLineCreated(id, pos, dir, scl);
            }
            else
            {
                Debug.LogError("OnRemoteLineDead");
                FieldManager.GetInstance().OnRemoteLineDead(item.objectId_1);
            }
        }
    }
示例#7
0
    // クライアントからメッセージ受信
    protected override void OnMessage(string msg, TcpClient client)
    {
        //base.OnMessage(msg, client);

        // -------------------------------------------------------------
        // あとは送られてきたメッセージによって何かしたいことを書く
        // -------------------------------------------------------------
        ProtocolItem item = null;

        try
        {
            item = ProtocolMaker.MakeToJson(msg);
        }
        catch
        {
            Debug.LogError("ProtocolMaker.MakeToJson(msg); failed" + msg);
        }

        ServerDebugLog("OnMessage : " + item.msgType.ToString() + " From " + item.sendFrom);

        switch (item.msgType)
        {
        case ProtocolType.C2A_RegisterHost:
            hostObjectId = GetClientObjectId(client);
            var host_logined = ProtocolMaker.Mk_A2C_UpdateClientInfo(hostObjectId.Value, -1);
            msg = ProtocolMaker.SerializeToJson(host_logined);
            SendMessageToClientAll(msg);
            break;

        case ProtocolType.C2A_RegisterClient:
            guestObjectId = GetClientObjectId(client);
            var guest_logined = ProtocolMaker.Mk_A2C_UpdateClientInfo(hostObjectId.Value, guestObjectId.Value);
            msg = ProtocolMaker.SerializeToJson(guest_logined);
            SendMessageToClientAll(msg);
            break;

        case ProtocolType.C2A_RequestStartGame:
            var game_start = ProtocolMaker.Mk_A2C_ResponseStartGame();
            msg = ProtocolMaker.SerializeToJson(game_start);
            SendMessageToClientAll(msg);
            break;

        case ProtocolType.C2A_AddForceToBall:
            var add_forec = ProtocolMaker.Mk_A2C_AddForceToBall(item);
            msg = ProtocolMaker.SerializeToJson(add_forec);
            SendMessageToClientAll(msg);
            break;

        case ProtocolType.C2A_UpdateLine:
            var update_line = ProtocolMaker.Mk_A2C_UpdateLine(item);
            msg = ProtocolMaker.SerializeToJson(update_line);
            SendMessageToClientAll(msg);
            break;


        case ProtocolType.C2A_GameResult:
            var result = ProtocolMaker.Mk_A2C_GameResult(item);
            msg = ProtocolMaker.SerializeToJson(result);
            SendMessageToClientAll(msg);
            break;

        default:
            // クライアントに受領メッセージを返す
            SendMessageToClientAll(msg);
            break;
        }
    }