Exemple #1
0
 IEnumerator FSM() //This is the state machine
 {
     while (true)
     {
         yield return(StartCoroutine(CurrentState.ToString()));
     }
 }
Exemple #2
0
    private void Update()
    {
                #if UNITY_IOS
        if (enableInput)
        {
            if (Input.touchCount > 0)
            {
                Touch         myTouch = Input.touches[0];
                TouchableTile tile;
                bool          foundTile = CheckForTile(myTouch, out tile);

                touchPhaseText.text = "Touch Phase: " + myTouch.phase.ToString();

                // Need a wall tile at start of touch
                if (foundTile)
                {
                    if (myTouch.phase == TouchPhase.Began && currentTouchState == TouchState.NoTouch)
                    {
                        // Can we start a touch sequence
                        if (tile.CommenceTouch())
                        {
                            currentTouchState = TouchState.PathStarted;
                            touchedTiles.Clear();
                            touchedTiles.Add(tile);
                            tile.UpdateOutline(true);
                            //						tile.OnTouch();
                        }
                    }
                    else if ((myTouch.phase == TouchPhase.Moved || myTouch.phase == TouchPhase.Ended) && currentTouchState == TouchState.PathStarted)
                    {
                        // We're drawing a line
                        touchedTiles.Add(tile);
                        tile.UpdateOutline(true);
                        if (tile.FinishTouch())
                        {
                            // This completes the sequence
                            foreach (TouchableTile degradeTile in touchedTiles)
                            {
                                degradeTile.OnTouch();
                                degradeTile.UpdateOutline(false);
                            }
                            touchedTiles.Clear();
                        }
                    }
                    boardPositionText.text = currentTouchState.ToString();


                    /**				if (myTouch.phase == TouchPhase.Ended && foundTile)
                     *                              {
                     *                                              touchPositionText.text = "Got it";
                     *                                              tile.OnTouch();
                     *                                      } else {
                     *                                              touchPositionText.text = "No tiles at position";
                     *                              } */
                }
            }
        }
                #endif
    }