Ejemplo n.º 1
0
    //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);
    }
Ejemplo n.º 2
0
    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;
    }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
 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());
     }
 }
Ejemplo n.º 5
0
        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();
        }
Ejemplo n.º 6
0
 public virtual void BuildInput(ClientInput owner)
 {
     if (Zoomed)
     {
         owner.ViewAngles = Angles.Lerp(owner.LastViewAngles, owner.ViewAngles, 0.2f);
     }
 }
Ejemplo n.º 7
0
 public void Init(bool a_isOwnPlayer)
 {
     if (a_isOwnPlayer)
     {
         m_input = (ClientInput)Object.FindObjectOfType(typeof(ClientInput));
     }
 }
Ejemplo n.º 8
0
    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;
            }
        }
    }
Ejemplo n.º 9
0
        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");
                }
            }
        }
Ejemplo n.º 10
0
    //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;
        }
    }
Ejemplo n.º 11
0
    public static ClientInput Deserialize(byte[] raw)
    {
        ClientInput input = new ClientInput();

        input.DecodeRawDataFromString(System.Text.Encoding.ASCII.GetString(raw));
        return(input);
    }
Ejemplo n.º 12
0
 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);
        }
Ejemplo n.º 14
0
    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;
        }
    }
Ejemplo n.º 15
0
    public static byte[] Serialize(ClientInput ci)
    {
        List <byte> pkt = new List <byte>();

        ci.AddBytesTo(pkt);
        return(pkt.ToArray());
    }
Ejemplo n.º 16
0
 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);
     }
 }
Ejemplo n.º 17
0
 private void ExecuteInpute(ClientInput inputData)
 {
     if (inputData.ClinetID == clientInstance.LocalPort)
     {
         Debug.Log("[YOU]  inputed>" + inputData.ToString());
     }
     else
     {
         Debug.Log("[OTHER]  inputed>" + inputData.ToString());
     }
 }
Ejemplo n.º 18
0
 public void SetInput(int networkId, ClientInput input)
 {
     if (_players == null)
     {
         return;
     }
     if (_players.ContainsKey(networkId))
     {
         _players[networkId].SetInput(input);
     }
 }
Ejemplo n.º 19
0
        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);
        }
Ejemplo n.º 20
0
    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);
    }
Ejemplo n.º 21
0
    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);
        }
    }
Ejemplo n.º 22
0
    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;
    }
Ejemplo n.º 23
0
        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();
        }
Ejemplo n.º 24
0
 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
     });
 }
Ejemplo n.º 25
0
    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();
        }
    }
Ejemplo n.º 26
0
 /// <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();
 }
Ejemplo n.º 27
0
    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);
    }
Ejemplo n.º 28
0
        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));
            }
        }
Ejemplo n.º 29
0
 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();
     }
 }
Ejemplo n.º 30
0
        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());
            }
        }