示例#1
0
    public void Clone_produces_different_backing_arrays(int playerCount)
    {
        var matchInput = InputUtility.RandomInput(playerCount);
        var clone      = matchInput.Clone();

        Assert.AreNotSame(matchInput.PlayerInputs, clone.PlayerInputs);
    }
示例#2
0
 /// <summary>
 /// Event-hanler for click event of update menu item of customer menu
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void updateToolStripMenuItem_Click(object sender, EventArgs e)
 {
     // Perform updation only when some customers already present.
     if (lstCustomers.Items.Count != 0)
     {
         int index = lstCustomers.SelectedIndex;
         //if no index is selected show error
         if (index == -1)
         {
             MessageBox.Show("Please select an index", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         string       str         = lstCustomers.SelectedItem.ToString();
         CustomerForm frmCustomer = new CustomerForm("Update Customer Info", InputUtility.GetWords(str));
         customerMngr.Customers = storedCustomers;
         customerMngr.Names     = storeNames;
         //if the customer clicks on OK button of the customer form then continue with the updation
         if (frmCustomer.ShowDialog() == DialogResult.OK)
         {
             customerMngr.ChangeCustomer(frmCustomer.CustomerData, lstCustomers.SelectedIndex);
             storedCustomers = customerMngr.Customers;
             storeNames      = customerMngr.Names;
             //update the customer list
             ChangedCustomerList();
         }
     }
     else
     {
         //if listbox is empty show error
         ShowError();
         return;
     }
 }
示例#3
0
    public void Predict_forces_invalid_inputs_to_be_valid(int playerCount)
    {
        var src = InputUtility.RandomInput(playerCount);

        src.Predict();
        Assert.IsTrue(src.IsValid);
    }
示例#4
0
        public void DoClickSelected()
        {
            Selectable[] selectables = m_selectables;
            int          num         = selectables.Length;

            if (num == 0)
            {
                return;
            }
            Selectable val;

            while (true)
            {
                if (m_selectedIndex < num)
                {
                    val = selectables[m_selectedIndex];
                    if (val != m_pseudo)
                    {
                        break;
                    }
                    SelectNext();
                    continue;
                }
                return;
            }
            InputUtility.SimulateClickOn(val);
        }
示例#5
0
    public void Clone_produces_equal_inputs(int playerCount)
    {
        var matchInput = InputUtility.RandomInput(playerCount);
        var clone      = matchInput.Clone();

        Assert.AreEqual(matchInput, clone);
    }
示例#6
0
        /// <summary>
        /// Validates the firstname, lastname and telephone numbers.
        /// </summary>
        /// <returns>returns true if all the three fields are validated, false
        /// otherwise</returns>
        private bool ValidateInputFields()
        {
            //calls checkstring method of inpututility class
            if (!InputUtility.CheckString(txtCustomerFirstName.Text))
            {
                MessageBox.Show("First name cannot be empty", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                lblFirstName.Text = "First Name*";
                return(false);
            }
            if (!InputUtility.CheckString(txtCustomerLastName.Text))
            {
                MessageBox.Show("Last name cannot be empty", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                lblLastName.Text = "Last Name*";
                return(false);
            }
            //validation for phone numbers
            if (!ValidationForPhoneNumbers())
            {
                return(false);
            }
            //to validate email
            if (!ValidateEmail())
            {
                MessageBox.Show("Enter a valid E-mail address", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                lblLastName.Text = "Email*";
                return(false);
            }

            return(true);
        }
示例#7
0
        private void Add_Click(object sender, EventArgs e)
        {
            string   name        = TextBoxName.Text;
            Category category    = InputUtility.GetCategory(ComboBoxCategory.Text);
            double   amount      = Convert.ToDouble(TextBoxAmount.Text);
            Currency currency    = InputUtility.GetCurrency(ComboBoxCurrency.Text);
            DateTime occuredTime = OccuredTimePicker.Value;
            string   note        = TextBoxNote.Text;

            if (note == null)
            {
                note = "None";
            }
            string content = TextBoxContent.Text;

            if (content == null)
            {
                content = "None";
            }

            AccountItem item = new AccountItem(name, category, amount, currency, occuredTime, content, note);

            account.AddItem(item);
            DataInputAccess.WriteAccountItems(account);
            All.Items.Add(item);
        }
示例#8
0
        private void ChooseProduct(IStorage myStorage)
        {
            Console.WriteLine("Please,type number of product You want to buy:");
            int choice = InputUtility.GetInputFromUser();
            var supplierProductList = myStorage.GetItemsThatCanBePurshed();

            if (choice < 0 || choice > supplierProductList.Count())
            {
                Console.WriteLine("There's no item with such number, try again");
                return;
            }

            var rand  = new Random();
            var piece = new Glassware
            {
                Name      = supplierProductList[choice].Name,
                Volume    = supplierProductList[choice].Volume,
                Price     = supplierProductList[choice].Price,
                Id        = Guid.NewGuid(),
                Condition = "New",
                Quality   = 100,
                IsClean   = true
            };

            myStorage.AddItem(piece);
            Console.WriteLine($"Item {piece.Name} was added!");
        }
示例#9
0
        protected override void Update()
        {
            base.Update();

            if (_RotationPerSecond != Vector3.zero)
            {
                transform.Rotate(_RotationPerSecond * Time.deltaTime);
            }

            if (mCurrentEffect != null && mCurrentEffectStartTime > 0 && mCurrentEffect._MaxDuration > 0 && ((Time.realtimeSinceStartup - mCurrentEffectStartTime) > mCurrentEffect._MaxDuration))
            {
                ApplyEffect(null);
            }

            if (mIsAttachedToPointer)
            {
                Vector2?pointerPosition = InputUtility.GetFingerOrMousePos(mFingerIDAttachedTo);
                if (pointerPosition.HasValue)
                {
                    transform.position = ScreenToUIPoint(pointerPosition.Value) + mPointerAttachOffset;
                }
            }

            if (mIsPressed && mIsHovering && pInteractableInHierarchy && pEventTarget != null)
            {
                pEventTarget.TriggerOnPressRepeated(this);
            }
        }
示例#10
0
    private void Update()
    {
        if (InputUtility.DidTouchBegin())
        {
            var ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            m_plane.Raycast(ray, out float enter);

            var intersect = ray.GetPoint(enter);
            Debug.DrawLine(ray.origin, intersect, Color.green, 15f);

            if (Physics.RaycastNonAlloc(ray, m_raycastHits, Mathf.Infinity, m_layerMask) > 0)
            {
                var raycastHitLocation = m_raycastHits[0].collider.bounds.min;

                m_interactiveObject = m_raycastHits[0].collider.GetComponent <InteractiveObject>();

                if (m_interactiveObject != null)
                {
                    Vector3 position = new Vector3(raycastHitLocation.x, HEIGHT_OFFSET, raycastHitLocation.z);
                    RegisterEvent(m_interactiveObject.gameEventType, position);
                }
            }

            m_interactiveObject?.BeginInteraction(this);
        }
        else if (InputUtility.DidTouchEnd())
        {
            m_interactiveObject?.ReleaseInteraction();
        }
    }
示例#11
0
        void LateUpdate()
        {
            float radiansPerSecond = math.radians(degreesPerSecond);

            float horizontal = InputUtility.GetCameraHorizontalInput();
            float vertical   = InputUtility.GetCameraVerticalInput();

            if (math.abs(horizontal) >= 0.2f)
            {
                RotateOffset(Time.deltaTime * horizontal * radiansPerSecond, Vector3.up);
            }

            if (math.abs(vertical) >= 0.2f)
            {
                float angleAt           = math.abs(math.asin(transform.forward.y));
                float maximumAngle      = math.radians(maximumYawAngle);
                float angleDeltaDesired = Time.deltaTime * vertical * radiansPerSecond;
                float angleDeltaClamped =
                    CalculateAngleDelta(angleDeltaDesired,
                                        maximumAngle - angleAt);

                RotateOffset(angleDeltaClamped, transform.right);
            }

            Vector3 cameraPosition = TargetPosition + offset;

            if (cameraPosition.y <= minimumHeight)
            {
                cameraPosition.y = minimumHeight;
            }

            transform.position = Vector3.Slerp(transform.position, cameraPosition, smoothFactor);

            transform.LookAt(TargetPosition);
        }
        void FixedUpdate()
        {
            InputUtility.Reset();
            BeforeInputUpdate?.Invoke();

            UnityEngine.InputSystem.InputSystem.Update();

            AfterInputUpdate?.Invoke();
        }
示例#13
0
    void Update()
    {
        HasInfos has_info = InputUtility.GetElementTouched <HasInfos>();

        if (has_info == null)
        {
            canvas_group.alpha = 0;
            return;
        }


        if (InputUtility.DidMouseMove)
        {
            delay_start_time = System.DateTime.Now;
        }

        float target_alpha = 0;

        if ((System.DateTime.Now - delay_start_time).TotalSeconds >= delay)
        {
            target_alpha = 1;
        }

        canvas_group.alpha = Mathf.Lerp(canvas_group.alpha, target_alpha, Time.deltaTime * 10);


        name_text.text = has_info.Name;

        List <string> lines = new List <string>();

        foreach (Info info in has_info.Infos)
        {
            lines.Add(info.name + " : " + info.description);
        }

        info_text.text     = lines.Aggregate((a, b) => a + "\n" + b);
        info_text.fontSize = (int)(name_text.fontSize * 0.5f);

        float additional_width = lines.Max(line => line.Length) * 0.378f *
                                 info_text.fontSize * 0.5f;

        additional_width = Mathf.Max(additional_width,
                                     name_text.text.Length * 0.4f *
                                     name_text.fontSize * 0.5f);

        float additional_height = lines.Count() * 0.59f *
                                  info_text.fontSize * 0.5f;

        (transform as RectTransform).sizeDelta =
            new Vector2(base_width + additional_width,
                        base_height + additional_height);

        info_container.sizeDelta = new Vector2(additional_width, additional_height);

        transform.position = Input.mousePosition;
    }
示例#14
0
 public void MatchInput_prodcues_proper_valid_masks(int playerCount)
 {
     for (var i = 0; i < 1000; i++)
     {
         byte mask  = (byte)(Mathf.FloorToInt(Random.value) & ~(1 << playerCount));
         var  input = InputUtility.RandomInput(playerCount);
         InputUtility.ForceValid(ref input, mask);
         Assert.AreEqual(mask, input.CreateValidMask());
     }
 }
示例#15
0
 void Update()
 {
     if (InputUtility.GetMouseButtonDown(0, needIgnoreList))
     {
         if (_popMenu.gameObject.activeSelf)
         {
             _playTweeen.Play(true);
         }
     }
 }
示例#16
0
    public void OnPressedCrouch()
    {
        var dataComp = _entManager.GetComponentData <InputDataComponent>(Utility.SystemEntity);

        if (false == InputUtility.HasState(dataComp, InputUtility.crouch))
        {
            dataComp.state |= InputUtility.crouch;
            _entManager.SetComponentData(Utility.SystemEntity, dataComp);
        }
    }
 private void Awake()
 {
     Input = new GameInput();
     Input.Enable();
     playerInput = GetComponent <PlayerInput>();
     if (Utility.GetGenericPlatform(Application.platform) == GenericPlatform.Mobile)
     {
         playerInput.enabled = false;
     }
     InputUtility.Init(Input);
 }
示例#18
0
        public void Run(IStorage storage, ISupplier supplier)
        {
            while (true)
            {
                Welcome();
                int userInput = InputUtility.GetInputFromUser();

                switch (userInput)
                {
                case 1:
                {
                    DisplayStorage(storage);
                    Console.ReadKey();
                }
                break;

                case 2:
                {
                    DisplayListOfProducts(storage);
                    ChooseProduct(storage);
                    Console.ReadKey();
                }
                break;

                case 3:
                {
                    ///validation
                    DisplayStorage(storage);
                    ThrowOutProduct(storage);
                    Console.ReadLine();
                }
                break;

                case 4:
                {
                    var laboratory = new ChemicalLaboratory(qualityControl, itemMaintainer, qualityChanger, conditionChanger);
                    Console.WriteLine("This is Your chemical laboratory, here You can:");
                    var labMenu = new LabMenu(laboratory, storage);
                    labMenu.Run();
                }
                break;

                default:
                {
                    Console.WriteLine("Wrong choice!");
                    Console.ReadKey();
                    break;
                }
                }
                Console.Clear();
            }
        }
示例#19
0
        protected virtual void UpdateInputMoveAxis(float fHorizontal, float fVertical)
        {
            if (actorData == null)
            {
                return;
            }

            var hInput = m_hActorData.m_hInputData;

            InputUtility.CalculateAxis(ref hInput.m_fHorizontal, fHorizontal, m_fSensitivity, m_fGravity, Time.deltaTime);
            InputUtility.CalculateAxis(ref hInput.m_fVertical, fVertical, m_fSensitivity, m_fGravity, Time.deltaTime);
            m_hActorData.m_hInputData = hInput;
        }
示例#20
0
        public void DoClickSelected()
        {
            List <Button> buttons = m_buttons;

            if (buttons.Count != 0)
            {
                Button val = buttons[m_selectedIndex];
                if (val.get_gameObject() == EventSystem.get_current().get_currentSelectedGameObject())
                {
                    InputUtility.SimulateClickOn(val);
                }
            }
        }
    public override bool AimModeTick(ref Vector2 aimPosition, string axis, GameObject target = null)
    {
        // Turn mouse cursor to desired sprite
        // True when we decide on a location
        if (InputUtility.GetAxisDown(axis, true))
        {
            aimPosition = Input.mousePosition;
            return(true);
        }

        // false if we haven't decided on a location yet
        return(false);
    }
    public void Append_updates_CurrentInput(int playerCount)
    {
        var latestInput  = InputUtility.RandomInput(playerCount);
        var inputHistory = new InputHistory <MatchInput>(latestInput);

        Assert.That(inputHistory.Current.Input, Is.EqualTo(latestInput));
        for (var i = 0; i < 20; i++)
        {
            latestInput = InputUtility.RandomInput(playerCount);
            inputHistory.Append(latestInput);
            Assert.That(inputHistory.Current.Input, Is.EqualTo(latestInput));
        }
        AssertHistoryMaintainsOrder(inputHistory);
    }
示例#23
0
 /// <summary>
 /// Depending on user selected stations filter the results
 /// and show them in listbox
 /// </summary>
 private void FilterResults()
 {
     lstSelectedTime.Items.Clear();
     foreach (string str in details)
     {
         string[] fromString = InputUtility.GetWords(str);
         if (fromString[1] == fromStation && fromString[2] == toStation)
         {
             lstSelectedTime.Items.Add(str);
         }
     }
     //add the results to the listboxdetails for the use in main menu
     listBoxDetails.AddRange(lstSelectedTime.Items);
 }
示例#24
0
 /// <summary>
 /// Event-handler for click event of submittt button. Here every calculation is performed and
 /// the result for one reservations will be showed in the labels and the all the reservations are stored
 /// in the Reservations tab.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     //if no customers are present prompt to add one
     if (cmbCustomer.Items.Count == 0)
     {
         MessageBox.Show("No Customers are registerd, add customers first.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     //to check whether the user has provided all the input or not, if provided continue
     if (ValidInput())
     {
         //Show the Select time form by passing the type of form selected by the user, title and from and to stations
         frmSelectTime = new SelectTimeForm(cmbTranportation.SelectedIndex + 1, SelectTitle(), cmbFrom.SelectedItem.ToString(), cmbTo.SelectedItem.ToString());
         //if no matching transport between selected locations are found show the message
         if (frmSelectTime.ListBoxDetails.Count == 0)
         {
             MessageBox.Show("No transport available", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
             frmSelectTime.Close(); //do not show the selectTime form
         }
         else
         {
             //if some transports are available then continue
             if (frmSelectTime.ShowDialog() == DialogResult.OK)
             {
                 //store the values of reservations in the labels
                 lblCustomerName.Text = cmbCustomer.SelectedItem.ToString();
                 string[] str = InputUtility.GetWords(lstCustomers.Items[cmbCustomer.SelectedIndex].ToString());
                 lblCustomerPhone.Text   = str[2];
                 lblReservationUpto.Text = frmSelectTime.Detail;
                 string[] str1  = InputUtility.GetWords(frmSelectTime.Detail);
                 string   price = str1[4];
                 //calculate the total Price
                 lblPrice.Text        = GetPrice(price).ToString("#.##");
                 lblTotalTickets.Text = (numericInfants.Value + numericChildren.Value + numericAdults.Value).ToString();
                 //shwo the controls to confrim or cancel the reservations
                 btnSubmit.Enabled  = false;
                 btnConfirm.Enabled = true;
                 btnCancel.Enabled  = true;
             }
             else
             {
                 //to empty labels which save the reservation details
                 EmptyReservationLabels();
             }
         }
         //re-initialize all fields
         InitializeGUI();
     }
 }
    public void Append_increments_CurrentTimestep(int playerCount)
    {
        var inputHistory = new InputHistory <MatchInput>(InputUtility.RandomInput(playerCount), 20);

        Assert.That(inputHistory.Current.Timestep, Is.EqualTo(20));
        inputHistory.Append(InputUtility.RandomInput(playerCount));
        Assert.That(inputHistory.Current.Timestep, Is.EqualTo(21));
        inputHistory.Append(InputUtility.RandomInput(playerCount));
        Assert.That(inputHistory.Current.Timestep, Is.EqualTo(22));
        inputHistory.Append(InputUtility.RandomInput(playerCount));
        Assert.That(inputHistory.Current.Timestep, Is.EqualTo(23));
        inputHistory.Append(InputUtility.RandomInput(playerCount));
        Assert.That(inputHistory.Current.Timestep, Is.EqualTo(24));
        AssertHistoryMaintainsOrder(inputHistory);
    }
    public void Append_increments_Count(int playerCount)
    {
        var inputHistory = new InputHistory <MatchInput>(InputUtility.RandomInput(playerCount));

        Assert.That(inputHistory.Count, Is.EqualTo(1));
        inputHistory.Append(InputUtility.RandomInput(playerCount));
        Assert.That(inputHistory.Count, Is.EqualTo(2));
        inputHistory.Append(InputUtility.RandomInput(playerCount));
        Assert.That(inputHistory.Count, Is.EqualTo(3));
        inputHistory.Append(InputUtility.RandomInput(playerCount));
        Assert.That(inputHistory.Count, Is.EqualTo(4));
        inputHistory.Append(InputUtility.RandomInput(playerCount));
        Assert.That(inputHistory.Count, Is.EqualTo(5));
        AssertHistoryMaintainsOrder(inputHistory);
    }
    public void Append_does_not_update_Oldest(int playerCount)
    {
        var firstInput   = InputUtility.RandomInput(playerCount);
        var inputHistory = new InputHistory <MatchInput>(firstInput, 42);

        Assert.That(inputHistory.Oldest.Timestep, Is.EqualTo(42));
        Assert.That(inputHistory.Oldest.Input, Is.EqualTo(firstInput));
        for (var i = 0; i < 20; i++)
        {
            inputHistory.Append(InputUtility.RandomInput(playerCount));
            Assert.That(inputHistory.Oldest.Input, Is.EqualTo(firstInput));
            Assert.That(inputHistory.Oldest.Timestep, Is.EqualTo(42));
        }
        AssertHistoryMaintainsOrder(inputHistory);
    }
示例#28
0
        /// <summary>
        /// If atleast one phone number is provided, converts the value to long
        /// by calling GetLong method of InputUtility
        /// </summary>
        /// <param name="phone">string value of the user input for phone number</param>
        /// <returns>true if conversion is successful</returns>
        private bool ValidatePhoneNumber(string phone)
        {
            long number;
            bool isValid = InputUtility.GetLong(phone, out number);

            if (isValid)
            {
                return(true);
            }
            else
            {
                MessageBox.Show("Invalid Phone Format", "Info!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
        }
示例#29
0
        /// <summary>
        /// validation for price field
        /// </summary>
        /// <param name="ticketPrice"></param>
        /// <returns>a integer having ticket price</returns>
        private bool ValidatePrice(out int ticketPrice)
        {
            string str     = txtPrice.Text;
            bool   isValid = InputUtility.GetInteger(str, out ticketPrice);

            if (isValid)
            {
                return(true);
            }
            else
            {
                MessageBox.Show("Please enter valid price", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
示例#30
0
        /// <summary>
        /// UIを選択しているときの処理
        /// </summary>
        /// <param name="eventData"></param>
        void IUpdateSelectedHandler.OnUpdateSelected(BaseEventData eventData)
        {
            if (!_isAlter || !UnityEngine.Input.anyKeyDown)
            {
                return;
            }

            KeyCode newCode;

            if (InputUtility.CheckKeyPressed(out newCode))
            {
                _alterHandler.AlterKey(this, newCode);
                EndAlterKey(false);
            }
        }