Example #1
0
    //fire2按钮
    public void OnFire2Btn()
    {
        var         cmd = new CmdInputAction(MsgInsideDef.MsgInputAction, agent.GetConnectID(), InputType.Fire2, MsgBroadcastType.Broadcast);
        WritePacket wp  = cmd.Packet();

        wp.WriteFloat32(5.8f);
        cmd.Send(agent);
    }
Example #2
0
    public void OnStartGame()
    {
        if (!isStart && agent.GetIds().Count >= MinPlayerCount)
        {
            var         cmd = new CmdInputAction(MsgInsideDef.MsgInputAction, agent.GetConnectID(), InputType.ButtonA, MsgBroadcastType.BroadcastNot);
            WritePacket wp  = cmd.Packet();
            cmd.Send(agent);

            Debug.Log("Click startGame");
        }
        else
        {
            Debug.Log("Player Count: " + agent.GetIds().Count);
        }
    }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        if (isStart && Input.GetMouseButtonDown(0))
        {
            Debug.Log("鼠标左键点击");
            var         cmd = new CmdInputAction(MsgInsideDef.MsgInputAction, agent.GetConnectID(), InputType.ButtonC, MsgBroadcastType.Broadcast);
            WritePacket wp  = cmd.Packet();
            wp.WriteInt32(isMain?1:0);
            cmd.Send(agent);
        }

        if (Input.GetMouseButtonDown(1))
        {
            blue.GetComponent <Rigidbody>().AddForce(0, 500, 0);
            Debug.Log("右键点击");
        }
    }
Example #4
0
    /// <summary>
    /// 动作回调
    /// </summary>

    public void OnAction(long id, byte action, ReadPacket rp)
    {
        switch (action)
        {
        case InputType.ButtonA:
            var         cmd = new CmdInputAction(MsgInsideDef.MsgInputAction, agent.GetConnectID(), InputType.ButtonD, MsgBroadcastType.Peer, id);
            WritePacket wp  = cmd.Packet();
            cmd.Send(agent);
            isStart = true;
            startGame.gameObject.SetActive(false);
            break;

        case InputType.ButtonC:
            Debug.Log("ButtonC");
            int isM = rp.ReadInt32();
            if (isM == 1)
            {
                blue.GetComponent <Rigidbody>().AddForce(0, 500, 0);
            }
            else
            {
                red.GetComponent <Rigidbody>().AddForce(0, 500, 0);
            }
            break;

        case InputType.ButtonD:
            isStart = true;
            isMain  = true;
            startGame.gameObject.SetActive(false);
            break;

        case InputType.Fire2:
            Debug.Log("收到动作命令, ID: " + id + " 动作: " + action + " 附加数据: " + rp.ReadFloat32());
            break;

        default:
            Debug.Log("收到动作命令, ID: " + id + " 动作: " + action);
            break;
        }
    }
Example #5
0
    //fire1按钮
    public void OnFire1Btn()
    {
        var cmd = new CmdInputAction(MsgInsideDef.MsgInputAction, agent.GetConnectID(), InputType.Fire1, MsgBroadcastType.Broadcast);

        cmd.Send(agent);
    }