示例#1
0
 public void Reset()
 {
     BoardWord[] componentsInChildren = wordPod.gameObject.GetComponentsInChildren <BoardWord>();
     for (int i = 0; i < componentsInChildren.Length; i++)
     {
         UnityEngine.Object.Destroy(componentsInChildren[i].gameObject);
     }
     fill.gameObject.SetActive(value: false);
     icon.gameObject.SetActive(value: false);
     wordText.Reset();
     wordText.ResetText();
     wordText.CalculateFill();
     levelWidth           = 0;
     levelHeight          = 0;
     levelScale           = 0f;
     isWordPodScaleUpdate = false;
     wordPodScaleCurrent  = 0f;
     wordPodScaleTarget   = 0f;
     isEnabled            = false;
     IsWordValid          = false;
     Result         = WordCheckResult.None;
     isReset        = true;
     selectedX      = int.MinValue;
     selectedY      = int.MinValue;
     selectedLetter = null;
     selectedIndex  = 0;
     shineDelay     = UnityEngine.Random.Range(5, 10);
     CancelInvoke("EnableInvoke");
     CancelInvoke("ShowFillInvoke");
     CancelInvoke("HideFillInvoke");
     CancelInvoke("ShowIconInvoke");
     CancelInvoke("HideIconInvoke");
     CancelInvoke("ShowWordsInvoke");
     CancelInvoke("HideWordsInvoke");
     CancelInvoke("TipInvoke");
 }
示例#2
0
 private void Update()
 {
     if (isEnabled && !IsWordValid && (!ELSingleton <TutorialWindow> .Instance.isActiveAndEnabled || !ELSingleton <TutorialWindow> .Instance.isPointerDown))
     {
         bool    flag     = false;
         bool    flag2    = false;
         bool    flag3    = false;
         Vector3 position = Vector3.zero;
         if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.Android)
         {
             if (UnityEngine.Input.touchCount > 0)
             {
                 flag     = (UnityEngine.Input.GetTouch(0).phase == TouchPhase.Began);
                 flag2    = (UnityEngine.Input.GetTouch(0).phase == TouchPhase.Moved);
                 flag3    = (UnityEngine.Input.GetTouch(0).phase == TouchPhase.Ended);
                 position = UnityEngine.Input.GetTouch(0).position;
             }
         }
         else
         {
             flag     = Input.GetMouseButtonDown(0);
             flag2    = (Input.GetMouseButton(0) && (UnityEngine.Input.GetAxis("Mouse X") != 0f || UnityEngine.Input.GetAxis("Mouse Y") != 0f));
             flag3    = Input.GetMouseButtonUp(0);
             position = UnityEngine.Input.mousePosition;
         }
         if (flag | flag2)
         {
             RaycastHit2D[] array = Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(position), Camera.main.transform.forward);
             for (int i = 0; i < array.Length; i++)
             {
                 if (array[i].collider != null)
                 {
                     if (isReset)
                     {
                         wordText.ResetText();
                         wordText.CalculateFill();
                         wordText.Idle();
                         isReset        = false;
                         selectedX      = int.MinValue;
                         selectedY      = int.MinValue;
                         selectedLetter = null;
                         selectedIndex  = 0;
                     }
                     BoardLetter component = array[i].collider.GetComponent <BoardLetter>();
                     if (component != null && component.IsAvailable && ((selectedX == int.MinValue && selectedY == int.MinValue) || (selectedX == component.X && (selectedY == component.Y + 1 || selectedY == component.Y - 1)) || (selectedY == component.Y && (selectedX == component.X + 1 || selectedX == component.X - 1))) && !component.IsSelected && !component.IsMarked && wordText.Text.Length < 8)
                     {
                         wordText.Text += component.Letter;
                         wordText.CalculateFill();
                         component.Select(selectedIndex, (selectedX == component.X - 1) ? BoardLetter.SelectorDirection.Left : ((selectedX == component.X + 1) ? BoardLetter.SelectorDirection.Right : ((selectedY == component.Y - 1) ? BoardLetter.SelectorDirection.Up : ((selectedY == component.Y + 1) ? BoardLetter.SelectorDirection.Down : BoardLetter.SelectorDirection.None))));
                         selectedX      = component.X;
                         selectedY      = component.Y;
                         selectedLetter = component;
                         selectedIndex++;
                     }
                     else if (component != null && ((selectedX == component.X && (selectedY == component.Y + 1 || selectedY == component.Y - 1)) || (selectedY == component.Y && (selectedX == component.X + 1 || selectedX == component.X - 1))) && component.IsSelected && !component.IsMarked && component.SelectedIndex == selectedIndex - 2 && selectedLetter != null)
                     {
                         wordText.Text = wordText.Text.Substring(0, wordText.Text.Length - 1);
                         wordText.CalculateFill();
                         selectedLetter.UnSelect(aIsSound: true);
                         selectedX      = component.X;
                         selectedY      = component.Y;
                         selectedLetter = component;
                         selectedIndex--;
                     }
                 }
             }
             if (array.Length == 0)
             {
                 flag3 = true;
             }
             ELSingleton <TutorialWindow> .Instance.Hide();
         }
         if (!isReset && flag3)
         {
             IsWordValid = true;
             isReset     = true;
         }
     }
     if (shineDelay <= 0f)
     {
         shineDelay = UnityEngine.Random.Range(5, 10);
         BoardLetter[] componentsInChildren = base.gameObject.GetComponentsInChildren <BoardLetter>();
         int           num = UnityEngine.Random.Range(1, 6);
         for (int j = 0; j < num; j++)
         {
             int num2 = UnityEngine.Random.Range(0, componentsInChildren.Length);
             componentsInChildren[num2].Shine((float)j * 0.2f);
         }
     }
     else
     {
         shineDelay -= Time.deltaTime;
     }
     if (!isWordPodScaleUpdate)
     {
         return;
     }
     if (wordPodScaleCurrent <= wordPodScaleTarget)
     {
         wordPodScaleCurrent += 1f * Time.deltaTime;
         if (wordPodScaleCurrent > wordPodScaleTarget)
         {
             wordPodScaleCurrent  = wordPodScaleTarget;
             isWordPodScaleUpdate = false;
         }
     }
     else if (wordPodScaleCurrent > wordPodScaleTarget)
     {
         wordPodScaleCurrent -= 1f * Time.deltaTime;
         if (wordPodScaleCurrent < wordPodScaleTarget)
         {
             wordPodScaleCurrent  = wordPodScaleTarget;
             isWordPodScaleUpdate = false;
         }
     }
     wordPod.transform.localScale    = new Vector3(wordPodScaleCurrent, wordPodScaleCurrent, 1f);
     wordPod.transform.localPosition = new Vector3((float)(-(levelWidth - 60)) * wordPodScaleCurrent * 0.5f, (float)(levelHeight - 60) * wordPodScaleCurrent * 0.5f, 0f);
 }