Ejemplo n.º 1
0
        private void CreateText(SearchObjectData searchObjectData)
        {
            DestroyText();

            GameObject searchTextGameObject = Instantiate <GameObject>(engine.GetService <IResourceService>().GetCachedPrefab("search_text"));

            searchTextGameObject.transform.SetParent(transform, false);
            searchTextGameObject.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
            searchText = searchTextGameObject.GetComponent <SearchText>();
            searchText.Setup(searchObjectData);
        }
Ejemplo n.º 2
0
 public void Setup()
 {
     if (isEmpty)
     {
         var searchManager     = FindObjectOfType <SearchManager>();
         SearchObjectData data = null;
         if (searchManager.TryActivateNext(out data))
         {
             CreateText(data);
         }
     }
 }
Ejemplo n.º 3
0
        //private void ActivateGroup(int maxObjectCount) {

        //    //StartCoroutine(CorActivate());
        //}

        //private bool isActivationNotStarted = true;

        //private System.Collections.IEnumerator CorActivate() {
        //    yield return new WaitUntil(() => isActivationNotStarted);
        //    StartCoroutine(ActivateIndices());
        //}

        public bool TryActivateNext(out SearchObjectData data)
        {
            data = null;
            if (notFoundedObjects.Count > 0)
            {
                data = notFoundedObjects[0];
                notFoundedObjects.RemoveAt(0);
                activeObjects.Add(data);
                ActivateObject(data);
                Debug.Log($"Activated {data.id}");
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
        public void Setup(SearchObjectData data)
        {
            this.searchObjectData = data;
            Clear();
            var resourceService = engine.GetService <IResourceService>();

            string targetText = resourceService.GetString(data.textId);

            if (ravenhillGameModeService.HasShuffleWordsDebuff(ravenhillGameModeService.searchSession.roomId))
            {
                Debug.Log($"Apply debuff to words");
                targetText = ravenhillGameModeService.ShufffleWord(targetText);
            }
            text.text = targetText;
        }
Ejemplo n.º 5
0
 private void OnSearchTextStroked(SearchText searchText, SearchObjectData data)
 {
     if (!isEmpty)
     {
         if (this.searchText == searchText)
         {
             DestroyText();
             var searchManager      = FindObjectOfType <SearchManager>();
             SearchObjectData sdata = null;
             if (searchManager.TryActivateNext(out sdata))
             {
                 CreateText(sdata);
             }
         }
     }
 }
Ejemplo n.º 6
0
        //private void OnSearchTextStroked(SearchText searchText, SearchObjectData data) {
        //    var slot = FindSlot(data);
        //    slot?.DestroyText();
        //}

        private void OnSearchObjectCollected(SearchObjectData data, ISearchableObject searchable)
        {
            var slot = FindSlot(data);

            slot?.Stroke();
        }
Ejemplo n.º 7
0
 private SearchTextSlot FindSlot(SearchObjectData searchObjectData)
 {
     return(slots.FirstOrDefault(slot => slot.searchObjectDataId == searchObjectData.id));
 }
Ejemplo n.º 8
0
 public static void OnSearchObjectCollected(SearchObjectData searchObjectData, ISearchableObject targetSearchableObject)
 {
     SearchObjectCollected?.Invoke(searchObjectData, targetSearchableObject);
 }
Ejemplo n.º 9
0
 public static void OnSearchObjectActivated(SearchObjectData data, BaseSearchableObject searchableObject)
 {
     SearchObjectActivated?.Invoke(data, searchableObject);
 }
Ejemplo n.º 10
0
 public static void OnSearchTextStroked(SearchText searchText, SearchObjectData searchObjectData)
 {
     SearchTextStroked?.Invoke(searchText, searchObjectData);
 }
Ejemplo n.º 11
0
        //private System.Collections.IEnumerator ActivateIndices() {
        //    isActivationNotStarted = false;
        //    int numberToActivate = maxActiveObjects - activeObjects.Count;
        //    int notFoundedCount = notFoundedObjects.Count;

        //    for(int i = 0; i < Mathf.Min(numberToActivate, notFoundedCount); i++ ) {

        //        yield return new WaitUntil(() => {
        //            var sobj = viewService.GetView(RavenhillViewType.search_pan);
        //            if(sobj) {
        //                var searchPan = sobj.GetComponentInChildren<SearchPan>();
        //                if(searchPan ) {
        //                    return searchPan.HasEmptySlot;
        //                }
        //            }
        //            return false;
        //        });

        //        SearchObjectData firstData = notFoundedObjects[0];
        //        notFoundedObjects.RemoveAt(0);
        //        activeObjects.Add(firstData);
        //        ActivateObject(firstData);
        //    }
        //    isActivationNotStarted = true;
        //}

        private void ActivateObject(SearchObjectData data)
        {
            var targetObject = currentSearchObjects.FirstOrDefault(sObj => sObj.id == data.id);

            targetObject?.Activate(data);
        }
Ejemplo n.º 12
0
 public abstract void Activate(SearchObjectData data);