Esempio n. 1
0
        public void SetGameInput(Gameplay.View.ViewState viewState, ref ClientInputData result)
        {
            Vector3         TargetPos = Vector3.zero;
            Data_PlayerInfo TargetHero;
            InputFlags      inputFlags = 0;// InputReader.ReadInput();

            //var champion = Champions.Champion.GetChampion(API.Instance.ViewState.GetControlledObjectType().ToString(API.GameData));
            //inputFlags |= champion.Combo(out TargetHero, out TargetPos);
            inputFlags = InputReader.ReadInput();
            //CameraSettings cameraSettings = Camera.main.GetComponent<CameraSettings>();
            Vector2 targetPosition  = new Vector2(TargetPos.x, TargetPos.z);
            Vector2 localPosition   = API.Instance.LocalPlayer.PredictedPosition2d(0).ToUnityVector2();
            Vector2 targetDirection = targetPosition - localPosition;
            Single  targetLength    = targetDirection.magnitude;

            if (targetLength == 0)
            {
                targetLength = 1.0f;
            }
            targetDirection.Normalize();
            result = default(ClientInputData);
            //var p = API.Instance.GameClientObject.Get<CollisionLibrary.Pathfinder>("Pathfinding");
            var mousePos   = UIHelper.GetMousePosition();
            var mousePos2d = new Vector2(mousePos.x, mousePos.y);

            result.InputDirection = ClampToMovable(mousePos2d);
            if (API.Instance.LocalPlayer.Team == 2)
            {
                result.InputDirection *= -1;
            }
            result.LocalSpaceInputDirection = MathCore.Vector2.Zero;
            result.AimDirection             = targetDirection.ToGameplayVector2();
            result.AimLength = targetLength;
            ((JSONReaderProfile)InputReader.ActiveDevice.Profile).AimLengthFactor = targetLength;
            result.AimDirectionOffset = targetDirection.ToGameplayVector2();
            //InputManager.Walk(targetDirection.x, targetDirection.y);
            result.AimLengthOffset   = targetLength;
            result.InputFlags        = inputFlags;
            result.HoveredGameObject = GameObjectId.Empty;
            result.InterruptOnMove   = false;
            //result.UseSmartCast = false;
            result.MousePosition = mousePos2d.ToGameplayVector2(); //targetPosition.ToGameplayVector2();
            result.MouseDelta    = new Vector2(Input.GetAxis("mouse x"), Input.GetAxis("mouse y")).ToGameplayVector2();

            var GameToolCamera = MergedUnity.Glue.GUI.GUIGlobals.Glue.Get <GameToolCamera>(MergedUnity.Glue.LoadingState.Ready);

            result.CameraInput = (CameraInput)GlueInstance.Invoke("GetCameraInputs", new object[] { API.Instance.ViewState, GameToolCamera });

            Byte _NumOfInputs = (Byte)GlueInstance.GetField("_NumOfInputs");

            GlueInstance.SetField("_NumOfInputs", ++_NumOfInputs);
            result.NumOfInputs = _NumOfInputs++;
        }
        // POST clients/update
        public HttpResponseMessage Update([FromBody] ClientInputData value)
        {
            if (value == null)
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            clientsService.UpdateClientData(value.Id, new ClientRegistrationInfo()
            {
                LastName    = value.LastName,
                FirstName   = value.FirstName,
                PhoneNumber = value.PhoneNumber
            });

            //// Uncomment if it will need
            //var balance = salesService.SearchBalanceByClientId(value.Id);
            //balancesService.ChangeBalance(balance.Id, value.Amount);

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
        // POST clients/add
        public HttpResponseMessage Add([FromBody] ClientInputData value)
        {
            if (value == null)
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            var clientId = clientsService.RegisterNewClient(new ClientRegistrationInfo()
            {
                LastName    = value.LastName,
                FirstName   = value.FirstName,
                PhoneNumber = value.PhoneNumber
            });

            balancesService.RegisterNewBalance(new BalanceRegistrationInfo()
            {
                Client = clientsService.GetClient(clientId),
                Amount = value.Amount
            });

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
        public string Run(RequestSender requestSender, ILoggerService log)
        {
            string welcome = "  Edit Clients info service.";

            log.Info(welcome);
            Console.WriteLine(welcome); // signal about enter into case

            int    id          = 0;
            string lastName    = string.Empty,
                   firstName   = string.Empty,
                   phoneNumber = string.Empty;

            string inputString = string.Empty;

            while (inputString != "e")
            {
                if (id == 0)
                {
                    Console.Write("   Enter the Id of client: ");
                    inputString = Console.ReadLine();
                    log.Info($"Id of client input: {inputString}");
                    int inputInt;
                    int.TryParse(inputString, out inputInt);
                    if (!StockExchangeValidation.checkId(inputInt))
                    {
                        continue;
                    }
                    id = inputInt;
                }

                if (string.IsNullOrEmpty(lastName))
                {
                    Console.Write("   Enter the Last name of client: ");
                    inputString = Console.ReadLine();
                    log.Info($"Last name input: {inputString}");
                    if (!StockExchangeValidation.checkClientLastName(inputString))
                    {
                        continue;
                    }
                    lastName = inputString;
                }

                if (string.IsNullOrEmpty(firstName))
                {
                    Console.Write("   Enter the First name of client: ");
                    inputString = Console.ReadLine();
                    log.Info($"First name input: {inputString}");
                    if (!StockExchangeValidation.checkClientFirstName(inputString))
                    {
                        continue;
                    }
                    firstName = inputString;
                }

                if (string.IsNullOrEmpty(phoneNumber))
                {
                    Console.Write("   Enter the phone number of client: ");
                    inputString = Console.ReadLine();
                    log.Info($"Phone number input: {inputString}");
                    if (!StockExchangeValidation.checkClientPhoneNumber(inputString))
                    {
                        continue;
                    }
                    phoneNumber = inputString;
                }

                break;
            }

            if (inputString == "e")
            {
                string exitString = "Exit from registration";
                log.Info(exitString);
                return(exitString);
            }

            Console.WriteLine("    Wait a few seconds, please.");

            var clientInputData = new ClientInputData
            {
                Id          = id,
                LastName    = lastName,
                FirstName   = firstName,
                PhoneNumber = phoneNumber
            };

            log.Info($"Created ClientInputData with Id = {id}, LastName = {lastName}, FirstName = { firstName}, PhoneNumber = { phoneNumber}");

            var reqResult = requestSender.EditClient(clientInputData);

            log.Info($"Request result: {reqResult}.");
            if (string.IsNullOrWhiteSpace(reqResult))
            {
                return($"     Client with Id = {id} was changed! Press Enter.");
            }
            return("Error. Client wasn't edited! Press Enter.");
        }
Esempio n. 5
0
        public string EditClient(ClientInputData clientInputData)
        {
            string request = "clients/update";

            return(Post <ClientInputData, string>(request, clientInputData));
        }
Esempio n. 6
0
        public string AddClient(ClientInputData clientInputData)
        {
            string request = "clients/add";

            return(Post <ClientInputData, string>(request, clientInputData));
        }
Esempio n. 7
0
        public string Run(RequestSender requestSender, ILoggerService log)
        {
            string welcome = "  Clients registration service.";

            log.Info(welcome);
            Console.WriteLine(welcome); // signal about enter into case

            string lastName     = string.Empty,
                   firstName    = string.Empty,
                   phoneNumber  = string.Empty;
            decimal moneyAmount = 0;

            string inputString = string.Empty;

            while (inputString != "e")
            {
                if (string.IsNullOrEmpty(lastName))
                {
                    Console.Write("   Enter the Last name of client: ");
                    inputString = Console.ReadLine();
                    log.Info($"Last Name input: {inputString}");
                    if (!StockExchangeValidation.checkClientLastName(inputString))
                    {
                        continue;
                    }
                    lastName = inputString;
                }

                if (string.IsNullOrEmpty(firstName))
                {
                    Console.Write("   Enter the First name of client: ");
                    inputString = Console.ReadLine();
                    log.Info($"First Name input: {inputString}");
                    if (!StockExchangeValidation.checkClientFirstName(inputString))
                    {
                        continue;
                    }
                    firstName = inputString;
                }

                if (string.IsNullOrEmpty(phoneNumber))
                {
                    Console.Write("   Enter the phone number of client: ");
                    inputString = Console.ReadLine();
                    log.Info($"Phone number input: {inputString}");
                    if (!StockExchangeValidation.checkClientPhoneNumber(inputString))
                    {
                        continue;
                    }
                    phoneNumber = inputString;
                }

                if (moneyAmount == 0)
                {
                    Console.Write("   Enter the money amount of client: ");
                    inputString = Console.ReadLine();
                    log.Info($"Money amount input: {inputString}");
                    decimal inputDecimal;
                    decimal.TryParse(inputString, out inputDecimal);
                    if (!StockExchangeValidation.checkClientBalanceAmount(inputDecimal))
                    {
                        continue;
                    }
                    moneyAmount = inputDecimal;
                }

                break;
            }

            if (inputString == "e")
            {
                string exitString = "Exit from registration";
                log.Info(exitString);
                return(exitString);
            }

            Console.WriteLine("    Wait a few seconds, please.");

            var clientInputData = new ClientInputData
            {
                LastName    = lastName,
                FirstName   = firstName,
                PhoneNumber = phoneNumber,
                Amount      = moneyAmount
            };

            log.Info($"Created ClientInputData with LastName = {lastName}, FirstName = { firstName}, PhoneNumber = { phoneNumber}, Amount = { moneyAmount}");

            var reqResult = requestSender.AddClient(clientInputData);

            log.Info($"Request result: {reqResult}.");
            if (string.IsNullOrWhiteSpace(reqResult))
            {
                return("New client was added! Press Enter.");
            }

            return("Error. Client wasn't added! Press Enter.");
        }