//采集玩家的下一个操作帧 void capture_player_opts() { NextFrameOpts next_frame = new NextFrameOpts(); next_frame.frameid = this.sync_frameid + 1; next_frame.zid = ugames.Instance.zid; next_frame.matchid = ugames.Instance.matchid; next_frame.seatid = ugames.Instance.self_seatid; //遥杆 OptionEvent opt_stick = new OptionEvent(); opt_stick.seatid = ugames.Instance.self_seatid; opt_stick.opttype = (int)OptType.JoyStick; //Debug.Log(this.stick.dir.y + " ---dirx--- " + this.stick.dir.x); opt_stick.x = (int)(this.stick.dir.x * (1 << 16)); opt_stick.y = (int)(this.stick.dir.y * (1 << 16)); //Debug.Log(opt_stick.y + " ---ed---- " + opt_stick.x); //opt_stick.x = (int)this.stick.dir.x; //opt_stick.y = (int)this.stick.dir.y; next_frame.opts.Add(opt_stick); //end //攻击 //end //发送给服务器 logic_service.Instance.send_next_frame_opts(next_frame); //end }
private void capture_player_opts() { NextFrameOpts next_frame = new NextFrameOpts(); ugame ugame_instance = ugame.Instance; next_frame.next_frameid = this.sync_frameid + 1; next_frame.matchid = ugame_instance.matchid; next_frame.zid = ugame_instance.zid; next_frame.seatid = ugame_instance.self_seatid; //攻击 if (this.ui_attack.attack_type != (int)OptType.Invalid) // 有攻击按钮按下了; { OptionEvent opt_attack = new OptionEvent(); opt_attack.seatid = ugame.Instance.self_seatid; opt_attack.opt_type = this.ui_attack.attack_type; next_frame.next_opts.Add(opt_attack); } else { // 摇杆 OptionEvent opt_stick = new OptionEvent(); opt_stick.seatid = ugame.Instance.self_seatid; opt_stick.opt_type = (int)OptType.JoyStick; opt_stick.x = (int)(this.stick.dir.x * (1 << 16)); // 16.16 opt_stick.y = (int)(this.stick.dir.y * (1 << 16)); // 16.16 next_frame.next_opts.Add(opt_stick); // end } //发送给服务器 logic_service_proxy.Instance.send_next_frame_opts(next_frame); //end }
private void CapturePlayerOpts() { NextFrameOpts nextFrameOpts = new NextFrameOpts(); nextFrameOpts.frameid = this._syncFrameID + 1; nextFrameOpts.zid = UGame.Instance.zid; nextFrameOpts.matchid = UGame.Instance.matchid; nextFrameOpts.seatid = UGame.Instance.selfSeatid; if (this.uiAttack.attackType != (int)OptType.Invalid) {//有攻击按钮按下了 //攻击操作收集 OptionEvent optAttack = new OptionEvent(); optAttack.seatid = UGame.Instance.selfSeatid; optAttack.opt_type = this.uiAttack.attackType; nextFrameOpts.opts.Add(optAttack); } else { //摇杆操作收集 OptionEvent optStick = new OptionEvent(); optStick.seatid = UGame.Instance.selfSeatid; optStick.opt_type = (int)OptType.JoyStick; optStick.x = (int)(this.stick.TouchDir.x * (1 << 16)); //定点数 optStick.y = (int)(this.stick.TouchDir.y * (1 << 16)); //定点数 nextFrameOpts.opts.Add(optStick); } //发送给服务器 LogicServiceProxy.Instance.SendNextFrameOpts(nextFrameOpts); }
/// <summary> /// 客户端发送给服务器 同步玩家帧信息,如 player.syncFrameId /// </summary> public void OnNextFrameEvent(NextFrameOpts _nextFrameOpts) { int seatId = _nextFrameOpts.SeatId; //同步player信息 GamePlayerInfo player = players.Find(p => p.SeatId == seatId); if (player == null) { return; } //同步客户端已同步帧id if (player.SyncFrameId < _nextFrameOpts.FrameId - 1) { player.SetSyncFrameId(_nextFrameOpts.FrameId - 1); } //客户端发送的帧id未达到最新帧,丢弃 if (_nextFrameOpts.FrameId != frameId) { return; } nextFrameOpt.SetFrameId(_nextFrameOpts.FrameId); for (int i = 0; i < _nextFrameOpts.optsCount; i++) { //Console.WriteLine("收到:..." + _nextFrameOpts.GetOpts(i).SeatId); nextFrameOpt.AddOpts(_nextFrameOpts.GetOpts(i)); } }
public override bool HandleMessage() { NextFrameOpts msg = GetParam <NextFrameOpts>(0); Program.OnNextFrameEvent(msg); return(true); }
/// <summary> /// 收集下一帧操作并发送到服务器 /// </summary> private void CollectNextFrameOpts() { var nfo = new NextFrameOpts { frameid = this.sync_frameid + 1, zoneid = NetInfo.zoneId, roomid = NetInfo.roomid, seatid = NetInfo.seatid, }; #region 采集操作 //遥感 var stick = new OptionEvent { seatid = NetInfo.seatid, optype = (int)OptType.JoyStick, x = (int)(this._joystick.TouchDir.x * (1 << 16)), y = (int)(this._joystick.TouchDir.y * (1 << 16)), }; nfo.opts.Add(stick); //攻击 //技能 #endregion LogicServiceProxy.Instance.SendNextFrameOpts(nfo); }
public void SendNextFrameOpts(NextFrameOpts nfo) { NetworkMgr.Instance.UdpSendProtobufCmd( (int)ServiceType.Logic, (int)LogicCmd.eNextFrameOpts, nfo); }
public static PacketDistributed CreatePacket(MessageID packetID) { PacketDistributed packet = null; switch (packetID) { case MessageID.GCErrorBack: { packet = new GCErrorBack(); } break; case MessageID.CGheartbeatClientSend: { packet = new CGheartbeatClientSend(); } break; case MessageID.GCheartbeatServerBack: { packet = new GCheartbeatServerBack(); } break; case MessageID.GCServerMsg: { packet = new GCServerMsg(); } break; case MessageID.OptionEvent: { packet = new OptionEvent(); } break; case MessageID.FrameOpts: { packet = new FrameOpts(); } break; case MessageID.LogicFrame: { packet = new LogicFrame(); } break; case MessageID.NextFrameOpts: { packet = new NextFrameOpts(); } break; case MessageID.GamePlayerInfo: { packet = new GamePlayerInfo(); } break; case MessageID.EnterGame: { packet = new EnterGame(); } break; } if (null != packet) { packet.packetID = packetID; } //netActionTime = DateTime.Now.ToFileTimeUtc(); return(packet); }
public void send_next_frame_opts(NextFrameOpts next_frame) { network.Instance.udp_send_protobuf_cmd((int)Stype.Logic, (int)Cmd.eNextFrameOpts, next_frame); }
public void SendNextFrameOpts(NextFrameOpts nextFrameOpts) { network.Instance.UdpSendProtobufCmd((int)Stype.Logic, (int)Cmd .eNextFrameOpts, nextFrameOpts); }
public static void Execute(object p) { NextFrameOpts msg = p as NextFrameOpts; NetMsgManager.Instance.HandleMessage(MessageID.NextFrameOpts, msg); }
public static void OnNextFrameEvent(NextFrameOpts opts) { battleMgr.OnNextFrameEvent(opts); }