Example #1
0
 private void Handle(MsgFire pckt)
 {
     if (this.State == KnownClientState.InGame)
     {
         OnFire(pckt.X, pckt.Y);
     }
 }
Example #2
0
    //开火协议
    public static void MsgFire(ClientState c, MsgBase msgBase)
    {
        MsgFire msg    = (MsgFire)msgBase;
        Player  player = c.player;

        if (player == null)
        {
            return;
        }
        //room
        Room room = RoomManager.GetRoom(player.roomId);

        if (room == null)
        {
            return;
        }
        //status
        if (room.status != Room.Status.FIGHT)
        {
            return;
        }
        //广播
        msg.id = player.id;
        room.Broadcast(msg);
    }
Example #3
0
    private void FireUpdate()
    {
        if (IsDie())
        {
            return;
        }
        if (!Input.GetKey(KeyCode.Space))
        {
            return;
        }

        if (Time.time - lastFireTime < fireCd)
        {
            return;;
        }

        Bullet  bullet = Fire();
        MsgFire msg    = new MsgFire();

        msg.x  = bullet.transform.position.x;
        msg.y  = bullet.transform.position.y;
        msg.z  = bullet.transform.position.z;
        msg.ex = bullet.transform.eulerAngles.x;
        msg.ey = bullet.transform.eulerAngles.y;
        msg.ez = bullet.transform.eulerAngles.z;
    }
Example #4
0
    //开火
    public void SyncFire(MsgFire msg)
    {
        Bullet bullet = Fire();
        //更新坐标
        Vector3 pos = new Vector3(msg.x, msg.y, msg.z);
        Vector3 rot = new Vector3(msg.ex, msg.ey, msg.ez);

        bullet.transform.position    = pos;
        bullet.transform.eulerAngles = rot;
    }
Example #5
0
    //收到开火协议
    public static void OnMsgFire(MsgBase msgBase)
    {
        MsgFire msg = (MsgFire)msgBase;

        //不同步自己
        if (msg.id == GameMain.id)
        {
            return;
        }
        //查找坦克
        SyncTank tank = (SyncTank)GetTank(msg.id);

        if (tank == null)
        {
            return;
        }
        //开火
        tank.SyncFire(msg);
    }
Example #6
0
    private static void OnMsgFire(MsgBase msgBase)
    {
        MsgFire msg = (MsgFire)msgBase;

        if (msg.id == GameMain.id)
        {
            return;
        }

        // 找坦克
        SyncTank tank = (SyncTank)GetTank(msg.id);

        if (tank == null)
        {
            return;
        }

        // 同步
        tank.SyncFire(msg);
    }
Example #7
0
 private void Handle(MsgFire pckt)
 {
     OnOpponentFire(pckt.X, pckt.Y, pckt.Dead);
 }