Example #1
0
        public ManufacturerPage OpenRandomManufacturerPage(PageBase currentPage)
        {
            // Open brand menu
            var menuItems = currentPage.Menu.OpenMenu("Бренды");

            _wait.Until(ExpectedConditions.ElementIsVisible(
                            By.CssSelector("li.megamenu-parent-block a.megamenu-parent-img img[title=\"Swiss Military\"]")));

            // Click on Swiss Military image
            randomSelector.Select(menuItems).Title.Click();

            return(ManufacturerPage.WaitForPage(_driver));
        }
Example #2
0
        static void Main(string[] args)
        {
            List <string> stringList = new List <string>
            {
                "Bike", "Train", "Boat", "Feet"
            };

            List <Person> personList = new List <Person> {
                new Person("Ted"),
                new Person("Ira"),
                new Person("Ada"),
                new Person("Lea")
            };

            List <int> intList = new List <int> {
                5, 10, 15, 20
            };

            RandomSelector <string> stringSelector = new RandomSelector <string>(stringList);
            RandomSelector <Person> personSelector = new RandomSelector <Person>(personList);
            RandomSelector <int>    intSelector    = new RandomSelector <int>(intList);

            string choice = "";

            while (choice != "q")
            {
                Console.WriteLine("Random string: " + stringSelector.Select().ToString());
                Console.WriteLine("Random person: " + personSelector.Select().ToString());
                Console.WriteLine("Random integer: " + intSelector.Select().ToString());
                Console.Write("Again? Enter to continue, q to quit: ");
                choice = Console.ReadLine();
            }
        }
Example #3
0
        public void ZeroSizeUtilityListSelectTest()
        {
            var uList = new List <Utility>();
            var s     = new RandomSelector();

            Assert.That(s.Select(uList), Is.EqualTo(-1));
        }
Example #4
0
        public void SelectTest([Range(-1, 21, 1)] int selIdx)
        {
            var rn = new MockRandom();

            rn.IntValue = selIdx;
            var uList = SelectorTestsHelper.CreateRandomUtilityList(20);
            var s     = new RandomSelector(rn);

            var aIdx = s.Select(uList);
            var cIdx = selIdx.Clamp(0, 19);

            Assert.That(aIdx, Is.EqualTo(cIdx));
        }
Example #5
0
    public override string Update()
    {
        enemyAnimator.speed = TimeManager.Instance.TimeFactor * enemy.UnitTimeFactor;


        if (!enemy.GuardZone.Contains(enemy.currentTarget) || !IsPlayerInSight(enemy.currentTarget, enemy[StatisticType.SightRange]))
        {
            return(state_onTargetLoss);
        }


        if (Time.time >= t_wait)
        {
            return(states_attacks[behaviorSelector.Select()[0]]);
        }


        return(Name);
    }
Example #6
0
    public override string Update()
    {
        if ((t_wait += TimeManager.Instance.ScaledDeltaTime) >= waitTime)
        {
            if (!IsPlayerInSight(enemy.currentTarget, enemy[StatisticType.SightRange]))
            {
                enemy.currentTarget = FindAvailableTarget();

                if (!enemy.currentTarget)
                {
                    return(state_onTargetLoss);
                }
            }


            if (!enemy.GuardZone.Contains(enemy.currentTarget))
            {
                return(states_attacks[0]);
            }


            Vector3 v = enemy.currentTarget.transform.position - enemy.transform.position;
            float   d = v.magnitude;
            float   t = Time.time;


            if (d < enemy.NearRange) // Prioritize on keeping a good distance
            {
                Vector3 u = (Vector3)enemy.GuardZone.center - enemy.transform.position;

                enemyRigidbody.velocity = backingSpeed * ((-v.normalized + u.normalized) / 2).normalized;
            }
            else
            {
                enemy.Turn();


                if (d < enemy.NearRange + 0.5f) // Always fire before getting too close or far
                {
                    return(states_attacks[0]);
                }
                else if (d <= enemy.FarRange)
                {
                    if (t >= t_ready)
                    {
                        switch (behaviorSelector.Select()[0])
                        {
                        case 0:     // Fire
                            return(states_attacks[0]);


                        case 1:     // Chase
                            enemyRigidbody.velocity = chasingSpeed * v.normalized;
                            t_ready = t + chasingDuration;
                            break;


                        case 2:     // Stay
                            enemyRigidbody.velocity = Vector2.zero;
                            t_ready = t + stayDuration;
                            break;
                        }
                    }
                }
                else
                {
                    enemyRigidbody.velocity = chasingSpeed * v.normalized;
                }
            }


            t_wait -= waitTime;
        }


        return(Name);
    }
Example #7
0
        public void GivenASetOfItems_Select_ReturnsAllOfThem()
        {
            var results = _sut.Select(_engineers);

            Assert.Equal(_engineers, results.OrderBy(e => e.Id));
        }