//For virtual game server void HandleClientInput(Pack pack) { ClientInput input = ProtoBuf.Serializer.Deserialize <ClientInput>(new MemoryStream(pack.buffer)); VirtualGameServer.Instance.AddInput(input); //Debug.Log("Handle input, " + (InputDirection)input.dir + " " + (Command)input.cmd); }
public override void BuildInput(ClientInput input) { base.BuildInput(input); var player = Player.Local; if (player == null) { return; } if ((Math.Abs(input.AnalogLook.pitch) + Math.Abs(input.AnalogLook.yaw)) > 0.0f) { if (!orbitEnabled) { orbitAngles = Rot.Angles(); orbitAngles = orbitAngles.Normal; orbitYawRot = Rotation.From(0.0f, orbitAngles.yaw, 0.0f); orbitPitchRot = Rotation.From(orbitAngles.pitch, 0.0f, 0.0f); } orbitEnabled = true; orbitTimer = Time.Now + OrbitCooldown; orbitAngles.yaw += input.AnalogLook.yaw; orbitAngles.pitch += input.AnalogLook.pitch; orbitAngles = orbitAngles.Normal; orbitAngles.pitch = orbitAngles.pitch.Clamp(MinOrbitPitch, MaxOrbitPitch); } input.ViewAngles = orbitAngles.WithYaw(orbitAngles.yaw - player.WorldRot.Yaw()); input.ViewAngles = input.ViewAngles.Normal; }
public async Task <Client> CreateClient(ClientInput model) { try{ var newClient = new Client { Name = model.Name, Email = model.Email, Telephone = model.Telephone }; await context.Clients.AddAsync(newClient); await context.SaveChangesAsync(); await CreateExtraData(newClient); return(newClient); }catch (Exception error) { log.LogError("Ocorreu o seguinte erro ao cadastrar um novo cliente na base de dados:"); log.LogError(error.Message); if (error.InnerException != null) { log.LogError(error.InnerException.Message); } log.LogError(JsonConvert.SerializeObject(model)); throw error; } }
public IActionResult Post(ClientInput clientInput) { try { BackwardChaining algorithm = new BackwardChaining(clientInput); res = algorithm.response; if (res.result.status == "Achieved") { try { GetPassAllURLAsync(); return(Ok(JsonConvert.SerializeObject(res))); } catch (Exception ex) { return(Ok(JsonConvert.SerializeObject(res))); } } else { return(Ok(JsonConvert.SerializeObject(res))); } } catch (Exception) { return(NotFound()); } }
public async Task AddOrUpdateWithSecret(ClientInput value, String secret) { var clientSecret = HashExtensions.Sha256(secret); var existing = await SelectFullEntity().Where(i => i.ClientId == value.ClientId).FirstOrDefaultAsync(); if (existing == null) { var entity = mapper.Map <Client>(value); entity.ClientSecrets = new List <ClientSecret>() { new ClientSecret() { Secret = clientSecret, } }; configDb.Clients.Add(entity); } else { mapper.Map <ClientInput, Client>(value, existing); existing.ClientSecrets.Clear(); existing.ClientSecrets.Add(new ClientSecret() { Secret = clientSecret }); configDb.Clients.Update(existing); } await configDb.SaveChangesAsync(); }
public virtual void BuildInput(ClientInput owner) { if (Zoomed) { owner.ViewAngles = Angles.Lerp(owner.LastViewAngles, owner.ViewAngles, 0.2f); } }
public void Init(bool a_isOwnPlayer) { if (a_isOwnPlayer) { m_input = (ClientInput)Object.FindObjectOfType(typeof(ClientInput)); } }
public void AddInput(ClientInput input) { //Logger.Log(string.Format("Handle input, {0} {1} running:{2}", // (InputDirection)input.dir, (Command)input.cmd, running)); if (!running) { return; } ClientInput lastInput = null; if (!lastInputs.TryGetValue(input.acc_id, out lastInput)) { lastInput = input; lastInputs.Add(lastInput.acc_id, lastInput); } else { if (input.dir != 0) { lastInput.dir = input.dir; } if (input.cmd != 0) { lastInput.cmd = input.cmd; } } }
public ForwardChaining(ClientInput _clientInput) { this.clientInput = _clientInput; response = new Response { information = _clientInput }; if (clientInput.facts.Contains(clientInput.goal)) { response.result.status = "achieved"; response.protocol.Add(new Protocol() { goal = clientInput.goal, information = "Goal is among current facts" }); } else { state = ForwardChainingAlgorithm(); if (state) { response.result.status = "achieved"; foreach (string item in root) { response.result.Kelias.Add(item); } } else { response.result.status = "Can't achieve "; response.result.Kelias.Add("Goal is unreachable"); } } }
//Used by clients to set individual input values public void Set(ClientInput input, object setting) { uint uinput = (uint)input; switch (input) { case ClientInput.MOUSE_POS: Vector3 p = (Vector3)setting; //Debug.Log( "Setting Mouse Pos: "+mousePosition + " / "+p ); if (Vector3.Distance(mousePosition, p) > 0.01f) { mousePosition = p; dirtFlags |= uinput; } break; default: //only apply change is different, and store dirty on flags if ((buttonState & uinput) > 0 != (bool)setting) { if ((bool)setting) { //Debug.Log("Down for "+input.ToString()); buttonState |= uinput; } else { //Debug.Log("Up for "+input.ToString() + " - " + ( buttonState & uinput ) + " - " + (bool)setting ); buttonState &= ~uinput; } dirtFlags |= uinput; } break; } }
public static ClientInput Deserialize(byte[] raw) { ClientInput input = new ClientInput(); input.DecodeRawDataFromString(System.Text.Encoding.ASCII.GetString(raw)); return(input); }
public void CacheClientInput(ClientInput ci) { lock (userCommandBufferList) { userCommandBufferList.AddRange(ServerUserCommand.CreaetUserCommands(this, ci)); } }
private static ClientInput ConvertSettingsToPermissions(ClientInput c) { if (c.Type == OpenIddictConstants.ClientTypes.Confidential) { c.Permissions.Remove(OpenIddictConstants.GrantTypes.AuthorizationCode); c.Permissions.Remove(OpenIddictConstants.ResponseTypes.Code); c.Permissions.Remove(OpenIddictConstants.GrantTypes.Implicit); c.Permissions.Add(OpenIddictConstants.GrantTypes.ClientCredentials); c.Permissions.Add(OpenIddictConstants.ResponseTypes.Token); } if (c.Type == OpenIddictConstants.ClientTypes.Public) { c.Permissions.Remove(OpenIddictConstants.GrantTypes.ClientCredentials); c.Permissions.Remove(OpenIddictConstants.ResponseTypes.Token); } if (c.RequirePkce) { c.Permissions.Add(OpenIddictConstants.GrantTypes.AuthorizationCode); c.Permissions.Add(OpenIddictConstants.ResponseTypes.Code); c.Permissions.Remove(OpenIddictConstants.GrantTypes.Implicit); } else { c.Permissions.Remove(OpenIddictConstants.GrantTypes.AuthorizationCode); c.Permissions.Remove(OpenIddictConstants.ResponseTypes.Code); c.Permissions.Add(OpenIddictConstants.GrantTypes.Implicit); } return(c); }
void ProcessPlayerInput(ClientInput input, PlayerInfo info) { Direction dir = Direction.None; Command cmd = Command.None; if (input != null) { dir = (Direction)input.dir; cmd = (Command)input.cmd; } //Logger.Log("ProcessPlayerInput " + info.ID + " " + dir + " " + cmd); info.moveCtrl.dir = dir; switch (cmd) { case Command.Action1: info.state = 1; break; case Command.Action2: info.state = 2; break; case Command.Action3: info.state = 3; break; case Command.None: info.state = 0; break; } }
public static byte[] Serialize(ClientInput ci) { List <byte> pkt = new List <byte>(); ci.AddBytesTo(pkt); return(pkt.ToArray()); }
public void ProcessTurn(FrameInfo turn) { foreach (var info in playerInfos) { List <ClientInput> inputs = turn.info; ClientInput input = inputs.Find(i => i.acc_id == info.Value.ID); ProcessPlayerInput(input, info.Value); } }
private void ExecuteInpute(ClientInput inputData) { if (inputData.ClinetID == clientInstance.LocalPort) { Debug.Log("[YOU] inputed>" + inputData.ToString()); } else { Debug.Log("[OTHER] inputed>" + inputData.ToString()); } }
public void SetInput(int networkId, ClientInput input) { if (_players == null) { return; } if (_players.ContainsKey(networkId)) { _players[networkId].SetInput(input); } }
private bool SetClient() { ClientInput ci = new ClientInput(); ci.ClientInputSubstitution(ip, port); ci.ShowDialog(); string a = ci.IP.Replace(" ", ""); ip = a; port = ci.Port; return(ci.trueclose); }
public static List <ServerUserCommand> CreaetUserCommands(Player player, ClientInput ci) { List <ServerUserCommand> ret = new List <ServerUserCommand>(); float currTime = StopWacthTime.Time; foreach (InputEvent ie in ci.inputEvents) { ret.Add(new ServerUserCommand(player, currTime + ie.deltaTime, ie)); } return(ret); }
public static void SendInput(Direction dir, Command cmd) { ClientInput input = new ClientInput(); input.dir = (uint)dir; input.cmd = (uint)cmd; input.acc_id = GameSystem.Instance.AccountID; if (conn != null) { conn.SendPack(0, input, MsgID.ClientInputID); } }
public void Deserialize(NetDataReader reader) { byte[] raw = new byte[reader.AvailableBytes]; reader.GetBytes(raw, reader.AvailableBytes); ClientInput inputBuf = Deserialize(raw); this.ClinetID = inputBuf.ClinetID; this.Axis0_X = inputBuf.Axis0_X; this.Axis0_Y = inputBuf.Axis0_Y; this.Axis1_X = inputBuf.Axis1_X; this.Axis1_Y = inputBuf.Axis1_Y; this.ToogledBtn = inputBuf.ToogledBtn; }
public async Task Update(int id, ClientInput value) { var client = await GetFullClientEntity(id); if (client == null) { throw new InvalidOperationException($"Cannot find client with id '{id}'."); } mapper.Map <ClientInput, Client>(value, client); configDb.Clients.Update(client); await configDb.SaveChangesAsync(); }
private void OnClientInput(ClientInput input, NetPeer peer) { _world.SetInput(peer.GetUId(), new ClientInput() { MaxX = input.MaxX, MaxY = input.MaxY, MinX = input.MinX, MinY = input.MinY, MoveX = input.MoveX, MoveY = input.MoveY, Rise = input.Rise, ViewRange = input.ViewRange }); }
private static void OnRecieve() { byte[] sizeInfo = new byte[4]; byte[] recievedBuffer = new byte[1024]; int totalRead = 0; int currentRead = 0; try { currentRead = totalRead = clientSocket.Receive(sizeInfo); if (totalRead <= 0) { Debug.Log("[Client] You are not connected to the server"); } else { while (totalRead < sizeInfo.Length && currentRead > 0) { currentRead = clientSocket.Receive(sizeInfo, totalRead, sizeInfo.Length - totalRead, SocketFlags.None); totalRead += currentRead; } int messageSize = 0; messageSize |= sizeInfo[0]; messageSize |= (sizeInfo[1] << 08); messageSize |= (sizeInfo[2] << 16); messageSize |= (sizeInfo[3] << 24); byte[] data = new byte[messageSize]; totalRead = 0; currentRead = totalRead = clientSocket.Receive(data, totalRead, data.Length - totalRead, SocketFlags.None); while (totalRead < messageSize && currentRead > 0) { currentRead = clientSocket.Receive(data, totalRead, data.Length - totalRead, SocketFlags.None); totalRead += totalRead; } ClientInput.HandleNetworkInformation(data); } } catch (Exception e) { Debug.Log(e.Message); clientSocket.Close(); } }
/// <summary> /// Create a new instance of the game engine using the specified window /// as the canvas and a class that extends GameUpdater as the Updater /// </summary> /// <param name="w">The Canvas Window</param> /// <param name="up">The GameUpdater to use</param> public GameEngine(Window w, GameUpdater up) { win = w; gu = up; er = new RenderEngine(w, 11293560973); ci = new ClientInput(w); win.MouseDown += new MouseButtonEventHandler(onClick); win.Closed += new EventHandler(onClose); runTime = Client.getClient(); dt.Tick += new EventHandler(onUpdate); dt.Interval = new TimeSpan(0, 0, 0, 0, gu.getTick()); dt.IsEnabled = true; dt.Start(); }
public static void SendInput(InputDirection dir, Command cmd) { if (GameSystem.Instance.mNetworkManager.m_gameConn == null) { return; } ClientInput input = new ClientInput(); input.acc_id = MainPlayer.Instance.AccountID; input.dir = (uint)dir; input.cmd = (uint)cmd; GameSystem.Instance.mNetworkManager.m_gameConn.SendPack <ClientInput>(0, input, MsgID.ClientInputID); //Debug.Log("SendInput " + dir + " " + cmd); }
public async Task <IActionResult> Post([FromBody] ClientInput clientInput) { try { var client = await _clientAppService .InsertAsync(clientInput) .ConfigureAwait(false); return(Created("", client)); } catch (ArgumentException arg) { return(BadRequest(arg.Message)); } }
private void ClientTick() { ci = AIInputHandler.GetClientInput(); if (ci.inputEvents.Count > 0) { // Network Tick NetworkTick.tickSeq++; ci.UpdateStatistics(NetworkTick.tickSeq, statisticsModule.tickAck, statisticsModule.GetTimeSpentIdleInTicks()); Send(ClientPktSerializer.Serialize(ci)); statisticsModule.RecordSentPacket(); // Clear the list of events. ci.inputEvents.Clear(); PacketStartTime.ResetStopWatch(); } }
public async Task <ActionResult <Client> > CreateClient([FromBody] ClientInput input) { try{ input.Validate(); if (input.Invalid) { return(UnprocessableEntity(input.Notifications)); } var result = await clienteService.CreateClient(input); return(Ok(result)); }catch { return(BadRequest()); } }