public static Google.Protobuf.WellKnownTypes.Any InteractionToAny(EventInteractionTick iTick) { WarPb.DecimalVector3 v = new WarPb.DecimalVector3(); v.X = iTick.DV.x.ToString(); v.Y = iTick.DV.y.ToString(); v.Z = iTick.DV.z.ToString(); Google.Protobuf.IMessage action; switch (iTick.T) { case EventInteractionTick.TYPE.MOVE: WarPb.Move move = new WarPb.Move(); move.Uid = 2002; move.Speed = v; action = move; break; case EventInteractionTick.TYPE.SHOOT: WarPb.Shoot shoot = new WarPb.Shoot(); shoot.Uid = 2002; shoot.Super = false; shoot.Point = v; action = shoot; break; default: return(null); } var any = Google.Protobuf.WellKnownTypes.Any.Pack(action); return(any); }
private void handleInteractionTick(EventInteractionTick tick) { WarPb.S_War_Do msg = toProtoDo(tick); //Google.Protobuf.WellKnownTypes.Any any = Google.Protobuf.WellKnownTypes.Any.Pack(msg); //client.SendAsync(new ArraySegment<byte>(any.Value.ToByteArray()), WebSocketMessageType.Binary, true, cancelActionToken); SendMessageAsync(msg); }
private WarPb.S_War_Do toProtoDo(EventInteractionTick tick) { WarPb.S_War_Do msg = new WarPb.S_War_Do(); msg.Id = ID; //msg.Action = global::Google.Protobuf.WellKnownTypes.Any.Pack(action); msg.Action = PBCode.InteractionToAny(tick); return(msg); }
//监听交互tick消息 private void handleInteractionTick(EventInteractionTick iTick) { var any = Net.PBCode.InteractionToAny(iTick); localTick.Actions.Add(any); }