Exemplo n.º 1
0
    void Update()
    {
        switch (state)
        {
        case PuzzleState.Setup:
            life       = DataObject.GetLife();
            stageLevel = 1;
            stageExp   = 0;
            ChangeState();
            break;

        case PuzzleState.Load:
            currentScore = 0;
            globeManager.NewGlobeGenerate();
            ChangeState();
            break;

        case PuzzleState.Wait:
        case PuzzleState.Touch:
            globeManager.CheckTouch();
            break;

        case PuzzleState.End:
            globeManager.GlobeDelete();
            CheckScore();
            SetTarget();
            ChangeState();
            break;

        case PuzzleState.GameOver:
            if (UnityTouch.GetPhase() == UnityTouchPhase.Began)
            {
                SceneManager.LoadScene("title");
            }
            break;
        }
    }
Exemplo n.º 2
0
    public void CheckTouch()
    {
        Vector3 p_pos = UnityTouch.GetPosition();              // ピクセル座標
        Vector2 u_pos = main_camera.ScreenToWorldPoint(p_pos); // Unity座標

        UnityTouchPhase phase = UnityTouch.GetPhase();

        if (phase == UnityTouchPhase.None)
        {
            return;
        }
        else if (phase == UnityTouchPhase.Began)
        {
            if (Mathf.Abs(u_pos.x) >= 2.7f || Mathf.Abs(u_pos.y) >= 3.3f)
            {
                puzzleManager.ChangeState(PuzzleState.Wait);
                return;
            }
            puzzleManager.ChangeState();
        }
        else if (phase == UnityTouchPhase.Ended)
        {
            puzzleManager.ChangeState();
            return;
        }

        if (puzzleManager.GetState() == PuzzleState.Touch)
        {
            if (Mathf.Abs(u_pos.x) >= 2.7f || Mathf.Abs(u_pos.y) >= 3.3f)
            {
                puzzleManager.ChangeState();
                return;
            }
        }

        for (int i = 0; i < 9; ++i)
        {
            for (int j = 0; j < 9; ++j)
            {
                GlobeObject g_obj = globeArray[i, j].Object.SafeGetComponent <GlobeObject>();
                if (g_obj.IsTouch(u_pos))
                {
                    // 既にタッチしたGlobeの処理
                    if (globeArray[i, j].IsTouch)
                    {
                        // 直前に触れたGlobeは処理しない
                        if (touchedStack.Count != 0 && touchedStack.Peek() == new Vector2(i, j))
                        {
                            return;
                        }
                        else
                        {
                            puzzleManager.ChangeState();
                            return;
                        }
                    }
                    g_obj.DoTouch();            // Globeの色を変える
                    globeArray[i, j].DoTouch(); // IsTouch = true
                    touchedStack.Push(new Vector2(i, j));
                }
            }
        }
    }