示例#1
0
    void Update()
    {
        if (playerid == localplayerid && Input.GetButton("Fire1") && Time.time > nextFire)
        {
            nextFire = Time.time + fireRate;
            Message shootcmd = new Message();
            shootcmd.id   = localplayerid;
            shootcmd.type = 2;
            m_sender.Send(shootcmd);
        }

        Message cmd = new Message();

        //从队列中获取命令,执行
        while (CheckAndGetMsg(ref cmd))
        {
            switch (cmd.type)
            {
            case 1:
                Move(cmd.h, cmd.v);
                break;

            case 2:
                Shoot();
                break;
            }
        }
    }