Esempio n. 1
0
    public void Execute()
    {
        double         time       = 0;
        bool           found      = false;
        string         path       = SetPath(by, value);
        AltUnityObject altElement = null;

        while (time <= timeout)
        {
            found = false;
            try
            {
                altElement = new FindObject(SocketSettings, by, value, cameraName, enabled).Execute();
                found      = true;
                System.Threading.Thread.Sleep(System.Convert.ToInt32(interval * 1000));
                time += interval;
                System.Diagnostics.Debug.WriteLine("Waiting for element " + path + " to not be present");
            }
            catch (System.Exception)
            {
                break;
            }
        }
        if (found)
        {
            throw new Assets.AltUnityTester.AltUnityDriver.WaitTimeOutException("Element " + path + " still found after " + timeout + " seconds");
        }
    }
Esempio n. 2
0
    public AltUnityObject Execute()
    {
        double         time       = 0;
        AltUnityObject altElement = null;

        while (time < timeout)
        {
            try
            {
                altElement = new FindObject(SocketSettings, by, value, cameraName, enabled).Execute();
                break;
            }
            catch (System.Exception)
            {
                System.Diagnostics.Debug.WriteLine("Waiting for element where name contains " + value + "....");
                System.Threading.Thread.Sleep(System.Convert.ToInt32(interval * 1000));
                time += interval;
            }
        }
        if (altElement != null)
        {
            return(altElement);
        }
        throw new Assets.AltUnityTester.AltUnityDriver.WaitTimeOutException("Element " + value + " not loaded after " + timeout + " seconds");
    }
Esempio n. 3
0
    void Update()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            GameObject closestHost = FindObject.FindNearestAliveHost(mousePositionWorldSpace);

            if (closestHost == null)
            {
                Debug.Log("no host found/all hosts busy");
            }
            else
            {
                closestHost.GetComponent <Host>().DrawAttention(mousePositionWorldSpace);
            }
        }

        if (Input.GetButtonDown("Fire2"))
        {
            GameObject[] hosts = GameObject.FindGameObjectsWithTag("Host");
            foreach (GameObject host in hosts)
            {
                host.GetComponent <Host>().StopDrawingAttention();
            }
        }
    }
Esempio n. 4
0
        /// <summary>
        /// Закрытый метод создания объекта поиска по аттрибуту в определнной группе объектов
        /// </summary>
        /// <param name="objecteId">Id объекта для фильтра значения</param>
        /// <param name="attributeId">значение для поиска</param>
        /// <param name="filterTypes">Фильтр типа(по родительскому каталогу или по Id класса объекта)</param>
        /// <param name="searchConditionType">Параметр условия поиска, значение Enum указывает по какому критерию будет поиск</param>
        /// <param name="searchOperatorType">Оператор операции поиска</param>
        /// <returns>Список объектов FindObject</returns>
        private FindObject MakeFindObject(string objectId, string attributeId, FilterTypes filterTypes, SearchConditionType searchConditionType, SearchOperatorType searchOperatorType)
        {
            var newFindObject = new FindObject();

            var findObject = new FindObject
            {
                Filters = new Filter[]
                {
                    new Filter()
                    {
                        Type  = (int)filterTypes,
                        Value = objectId
                    }
                },

                Conditions = new Condition[]
                {
                    new Condition {
                        Type      = (int?)searchConditionType,
                        Operator  = (int?)searchOperatorType,
                        Attribute = attributeId
                    }
                }
            };

            return(findObject);
        }
Esempio n. 5
0
 public void EndGameIfNoHostsRemain()
 {
     if (FindObject.FindNearestAliveHost(Vector3.zero) == null)
     {
         EndGame();
     }
 }
Esempio n. 6
0
    void Update()
    {
        if (isKilling)
        {
            return;
        }

        if (GameOver.instance.gameOver)
        {
            ccc.ClearDestination();
            return;
        }

        GameObject nearestYellingHost = FindObject.FindNearestYellingHost(transform.position);

        if (nearestYellingHost != null)
        {
            ccc.followObject = nearestYellingHost;
            ccc.isRunning    = true;
            TryKilling(nearestYellingHost);
            return;
        }

        GameObject nearestHost = FindObject.FindNearestAliveHost(transform.position);

        if (nearestHost != null)
        {
            ccc.followObject = nearestHost;
            ccc.isRunning    = false;
            TryKilling(nearestHost);
            return;
        }
    }
Esempio n. 7
0
        public void Select()
        {
            FindObject fo    = new FindObject(tracking, rtb.SelectionStart, rtb.SelectionStart + rtb.SelectionLength);
            ASTVisitor visit = new ASTVisitor(fo.Visitor);

            this.ASTRoot.visit(visit);
            model.ChangeObject(fo.FoundObject);
        }
Esempio n. 8
0
        /// <summary>
        /// Метод работы с Api
        /// </summary>
        /// <param name="findObject">объект поиска</param>
        /// <param name="address">адрес сервиса</param>
        /// <returns></returns>
        private async Task <List <Result> > Request(FindObject findObject, string address)
        {
            List <Result> results = new List <Result>();
            var           json    = await webApiService.FindItemAsync(address, findObject);

            foreach (var item in json["Result"])
            {
                results.Add(ResultObjectMapping(item));
            }
            return(results);
        }
Esempio n. 9
0
    private void buildMap()
    {
        FindObject findObject = new FindObject();


        for (int a = 0; a < map.GetLength(0); a++)          //Build tunnels & rooms
        {
            GameObject currentModel = transform.gameObject; // this is needed to prevent unity from creating an empty gameobject which would be visible in hierarchy

            if (findObject.FindObjectByCode(allTunnels, map[a, 0]) != null)
            {
                currentModel = findObject.FindObjectByCode(allTunnels, map[a, 0]);
            }
            else if (findObject.FindObjectByCode(allRooms, map[a, 0]) != null)
            {
                currentModel = findObject.FindObjectByCode(allRooms, map[a, 0]);
            }

            GameObject modelClone = Instantiate(currentModel, new Vector3(castInto.stringToInt(map[a, 1]), 0.0f, castInto.stringToInt(map[a, 3])), Quaternion.Euler(0.0f, castInto.stringToInt(map[a, 4]), 0.0f)) as GameObject;
            modelClone.transform.parent = tunnelsContainer.transform;
        }
        for (int a = 0; a < placeables.GetLength(0); a++) //Build placeables
        {
            GameObject currentModel = findObject.FindObjectByCode(allPlaceables, placeables[a, 0]);
            GameObject modelClone   = Instantiate(currentModel, new Vector3(castInto.stringToFloat(placeables[a, 1]), castInto.stringToFloat(placeables[a, 2]), castInto.stringToFloat(placeables[a, 3])), Quaternion.Euler(0.0f, castInto.stringToInt(placeables[a, 4]), 0.0f)) as GameObject;
            modelClone.transform.parent = placeablesContainer.transform;

            // Adding camera
            if (currentModel.GetComponent <Model>().name == "Player")
            {
                if (gameType == "cardboard")
                {
                    gameCamera = cardBoard;
                    gameCamera.transform.position = currentModel.transform.position;
                    gameCamera.transform.rotation = transform.rotation;
                    //GameObject carboardClone = Instantiate(cardBoard, currentModel.transform.position, transform.rotation) as GameObject;
                }
                else if (gameType == "standalone")
                {
                    gameCamera = pcCamera;
                    gameCamera.transform.position = currentModel.transform.position;
                    gameCamera.transform.rotation = transform.rotation;
                    //GameObject pcCameraClone = Instantiate(pcCamera, currentModel.transform.position, transform.rotation) as GameObject;
                }
            }
        }

        isReady = true;
    }
Esempio n. 10
0
        /// <summary>
        /// Закрытый метод создания объекта поиска по фильтру объекта
        /// </summary>
        /// <param name="objectId">Значение для поиска по объекту</param>
        /// <param name="filterTypes">Тип фильтра</param>
        /// <returns>Список объектов FindObject</returns>
        private FindObject MakeFindObject(string objectId, FilterTypes filterTypes)
        {
            var findObject = new FindObject
            {
                Filters = new Filter[] {
                    new Filter
                    {
                        Type  = (int)filterTypes,
                        Value = objectId
                    }
                }
            };

            return(findObject);
        }
Esempio n. 11
0
    /**** 유니티 함수 ****/


    private void Awake()
    {
        inGameCanvas = GameObject.Find("InGameObject");                                // 캔버스 설정

        animator = GetComponent <Animator>();                                          // 애니메이터 설정

        findObject    = GetComponent <FindObject>();                                   // 탐지 오브젝트 설정
        timeBar       = GetComponent <TimeBar>();                                      // 타임바 설정
        playerCamera  = GameObject.Find("PlayerCamera").GetComponent <PlayerCamera>(); // 카메라 설정
        playerState   = GetComponent <PlayerState>();                                  // 플레이어 상태 설정
        boxPlayerMove = GetComponent <PlayerMove>();                                   //플레이어 이동 스크립트


        OriginalCameraPosition = Vector3.zero;

        // 애니메이션 포톤 뷰 설정
        gameObject.GetComponent <PhotonAnimatorView>().SetParameterSynchronized("InteractionType", PhotonAnimatorView.ParameterType.Int, PhotonAnimatorView.SynchronizeType.Discrete);
    }
Esempio n. 12
0
        /// <summary>
        /// Закрытый метод создания объекта поиска по имени объекта
        /// </summary>
        /// <param name="searchConditionType">Параметр условия поиска, значение Enum указывает по какому критерию будет поиск</param>
        /// <param name="searchOperatorType">Оператор операции поиска</param>
        /// <param name="name">Имя объекта</param>
        /// <returns>Список объектов FindObject</returns>
        private FindObject MakeFindObject(SearchConditionType searchConditionType, SearchOperatorType searchOperatorType, string name)
        {
            var searchOperatorTypeInt  = (int?)searchOperatorType;
            var searchConditionTypeInt = (int?)searchConditionType;
            var findObject             = new FindObject
            {
                Conditions = new Condition[]
                {
                    new Condition {
                        Type     = searchConditionTypeInt,
                        Operator = searchOperatorTypeInt,
                        Value    = name
                    }
                },
                Filters = new Filter[]
                {}
            };

            return(findObject);
        }
Esempio n. 13
0
        /// <summary>
        /// Закрытый метод создания объекта поиска по атрибуту объекта
        /// </summary>
        /// <param name="attributeId">значение для поиска</param>
        /// <param name="searchConditionType">Параметр условия поиска, значение Enum указывает по какому критерию будет поиск</param>
        /// <param name="searchOperatorType">Оператор операции поиска</param>
        /// <returns>Список объектов FindObject</returns>
        private FindObject MakeFindObject(string attributeId, SearchConditionType searchConditionType, SearchOperatorType searchOperatorType)
        {
            var searchOperatorTypeInt  = (int?)searchOperatorType;
            var searchConditionTypeInt = (int?)searchConditionType;
            var findObject             = new FindObject
            {
                Conditions = new Condition[]
                {
                    new Condition {
                        Type      = searchConditionTypeInt,
                        Operator  = searchOperatorTypeInt,
                        Attribute = attributeId
                    }
                },
                Filters = new Filter[]
                {}
            };

            return(findObject);
        }
Esempio n. 14
0
        public async Task <dynamic> FindItemAsync(string addressString, FindObject findObject, int skip = 0, int take = 20)
        {
            using (var client = await GetClientAsync())
            {
                client.DefaultRequestHeaders.Add("X-HTTP-Method-Override", "GET");
                var content      = Newtonsoft.Json.JsonConvert.SerializeObject(findObject);
                var payload      = GetStringContent(content);
                var httpResponse = await client.PostAsync($"{addressString}?skip={skip}&take={take}", payload);

                if (httpResponse.IsSuccessStatusCode)
                {
                    var responseContent = await httpResponse.Content.ReadAsStringAsync();

                    var dynamicJson = JsonConvert.DeserializeObject <dynamic>(responseContent);
                    logger.Debug($"Запрос успешно отправлен {httpResponse.StatusCode}");
                    return(dynamicJson);
                }
                logger.Error($"на сервере произошла ошибка {httpResponse.StatusCode} - {httpResponse.ReasonPhrase}");
                return(null);
            }
        }
Esempio n. 15
0
    void Update()
    {
        if (!isShut)
        {
            GameObject nearestHost = FindObject.FindNearestAliveHost(transform.position);
            if (nearestHost != null && (nearestHost.transform.position - transform.position).magnitude < trapRadius)
            {
                nearestHost.GetComponent <Host>().Die();
                SnapShut();
                return;
            }

            GameObject nearestMIB = FindObject.FindNearestAliveMIB(transform.position);
            if (nearestMIB != null && (nearestMIB.transform.position - transform.position).magnitude < trapRadius)
            {
                nearestMIB.GetComponent <MIB>().Die();
                SnapShut();
                return;
            }
        }
    }
Esempio n. 16
0
    public AltUnityObject Execute()
    {
        string         path       = SetPath(by, value);
        double         time       = 0;
        AltUnityObject altElement = null;

        while (time < timeout)
        {
            try
            {
                altElement = new FindObject(SocketSettings, by, value, cameraName, enabled).Execute();
                if (altElement.GetText().Equals(text))
                {
                    break;
                }
                throw new System.Exception("Not the wanted text");
            }
            catch (Assets.AltUnityTester.AltUnityDriver.NotFoundException)
            {
                System.Threading.Thread.Sleep(System.Convert.ToInt32(interval * 1000));
                time += interval;
                System.Diagnostics.Debug.WriteLine("Object " + path + " not found");
            }
            catch (System.Exception)
            {
                System.Threading.Thread.Sleep(System.Convert.ToInt32(interval * 1000));
                time += interval;
                System.Diagnostics.Debug.WriteLine("Waiting for element " + path + " to have text " + text);
            }
        }
        if (altElement != null && altElement.GetText().Equals(text))
        {
            return(altElement);
        }
        throw new Assets.AltUnityTester.AltUnityDriver.WaitTimeOutException("Element with text: " + text + " not loaded after " + timeout + " seconds");
    }
Esempio n. 17
0
        /// <summary>
        /// Looks for an object that isn't moving (meaning the player isn't moving)
        /// </summary>
        /// <param name="stationaryObject">color filter used to locate the stationary object</param>
        /// <param name="foundObject">returns the Blob if it is found or null if not found</param>
        /// <param name="tolerance">maximum allowed distance in pixels between subsequent object locations</param>
        /// <param name="maxWaitTime">time to wait before gving up</param>
        /// <param name="minimumSize">minimum required size of the object in pixels</param>
        /// <param name="findObject">custom method to locate the object</param>
        /// <param name="verificationPasses">number of times to verify the position of the object after finding it</param>
        /// <returns>True if the object is found</returns>
        internal bool LocateStationaryObject(ColorFilter stationaryObject, out Blob foundObject, double tolerance, int maxWaitTime, int minimumSize = 1, int maximumSize = int.MaxValue, FindObject findObject = null, int verificationPasses = 1)
        {
            findObject = findObject ?? LocateObject;

            foundObject = null;
            Point?    lastPosition    = null;
            int       effectivePasses = 0;
            int       totalPasses     = 0;
            Stopwatch giveUpWatch     = new Stopwatch();

            giveUpWatch.Start();

            while (giveUpWatch.ElapsedMilliseconds < maxWaitTime || totalPasses <= verificationPasses)
            {
                if (BotProgram.StopFlag)
                {
                    return(false);
                }

                Blob objectBlob = null;
                findObject(stationaryObject, out objectBlob, minimumSize, maximumSize);

                if (objectBlob != null)
                {
                    if (Geometry.DistanceBetweenPoints(objectBlob.Center, lastPosition) <= tolerance)
                    {
                        effectivePasses++;
                    }
                    else
                    {
                        effectivePasses = 0;
                        lastPosition    = objectBlob.Center;
                    }

                    if (effectivePasses >= verificationPasses)
                    {
                        foundObject = objectBlob;
                        return(true);
                    }
                }
                else
                {
                    lastPosition = null;
                }
                totalPasses++;
            }

            return(false);
        }