Example #1
0
    void OnEnable()
    {
        var recognizer = new TKSwipeRecognizer();

        recognizer.gestureRecognizedEvent += PlayerBehavoir.MoveBalls;
        TouchKit.addGestureRecognizer(recognizer); //TO DO ADD SIMPLE TOUCH RECIGNIZER
    }
    // Use this for initialization
    void Start()
    {
        bagHandler = GetComponent <BagHandler>();

//        // when using in conjunction with a pinch or rotation recognizer setting the min touches to 2 smoothes movement greatly
//        if( Application.platform == RuntimePlatform.IPhonePlayer ) {
//            recognizer.minimumNumberOfTouches = 2;
//        }

        // continuous gestures have a complete event so that we know when they are done recognizing
        swipeRecognizer.gestureRecognizedEvent += swipeGestureDetected;
        TouchKit.addGestureRecognizer(swipeRecognizer);

        twoTapRecognizer.numberOfTouchesRequired = 2;
        twoTapRecognizer.gestureRecognizedEvent += twoTapDetected;
        TouchKit.addGestureRecognizer(twoTapRecognizer);

/*
 #if UNITY_IOS
 *      Input.simulateMouseWithTouches = false;
 #endif
 #if UNITY_IOS || UNITY_ANDROID
 *      tapRecognizer.numberOfTouchesRequired = 1;
 *      tapRecognizer.gestureRecognizedEvent += tapDetected;
 *      TouchKit.addGestureRecognizer(tapRecognizer);
 #endif
 */

        continousHoldRecognizer.gestureHoldingEvent      += touchHoldActive;
        continousHoldRecognizer.gestureHoldingEventEnded += touchHoldEnded;
        TouchKit.addGestureRecognizer(continousHoldRecognizer);

        StartCoroutine(preloadGameObjects());
    }
Example #3
0
    private void Inputinit()
    {
        var recognizerTap = new TKTapRecognizer();

        // we can limit recognition to a specific Rect, in this case the bottom-left corner of the screen
        recognizerTap.boundaryFrame = new TKRect(0, 0, Screen.width, Screen.height);

        // we can also set the number of touches required for the gesture
        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            recognizerTap.numberOfTouchesRequired = 2;
        }

        recognizerTap.gestureRecognizedEvent += Tap_gestureRecognizedEvent;
        TouchKit.addGestureRecognizer(recognizerTap);



        var recognizerSwipe = new TKSwipeRecognizer();

        recognizerSwipe.timeToSwipe = 0;
        recognizerSwipe.SetMinimumDistance(0.5f);
        //recognizerTap.addAngleRecogizedEvents (Recognizer_gestureRecognizedEvent, new Vector2(1,1), 45);

        recognizerSwipe.gestureRecognizedEvent += Swipe_gestureRecognizedEvent;
        TouchKit.addGestureRecognizer(recognizerSwipe);
    }
Example #4
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        showDebug = EditorGUILayout.Foldout(showDebug, status);
        if (showDebug)
        {
            TouchKit touchKit = (TouchKit)target;
            touchKit.drawDebugBoundaryFrames = EditorGUILayout.Toggle("Draw boundary frames", touchKit.drawDebugBoundaryFrames);
            touchKit.drawTouches             = EditorGUILayout.Toggle("Draw touches", touchKit.drawTouches);
            touchKit.simulateTouches         = EditorGUILayout.Toggle("Simulate touches", touchKit.simulateTouches);

            GUI.enabled = touchKit.simulateTouches;
            if (GUI.enabled || true)
            {
                var helpText = "Touches can be simulated in the editor or on the desktop with mouse clicks.";
                if (touchKit.simulateMultitouch)
                {
                    helpText += "\nTo simulate a two-finger gesture, press and hold the left alt key and move your mouse around. Shift the touches by additionally holding down left shift.";
                }

                EditorGUILayout.HelpBox(helpText, MessageType.Info, true);
            }

            touchKit.simulateMultitouch = EditorGUILayout.Toggle("Simulate multitouch", touchKit.simulateMultitouch);
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
Example #5
0
        // Use this for initialization
        void Start()
        {
            TKSwipeRecognizer recognizer = new TKSwipeRecognizer(TKSwipeDirection.All);

            recognizer.gestureRecognizedEvent += (r) => {
                //Ação desejada no swipe vem aqui
                Debug.Log(r);
                swipeText.text = r.completedSwipeDirection.ToString();
                Color color = Color.black;
                switch (r.completedSwipeDirection)
                {
                case TKSwipeDirection.Down:
                    color = Color.green;
                    break;

                case TKSwipeDirection.Up:
                    color = Color.blue;
                    break;

                case TKSwipeDirection.Left:
                    color = Color.magenta;
                    break;

                case TKSwipeDirection.Right:
                    color = Color.yellow;
                    break;

                default:
                    break;
                }
                background.color = color;
            };

            TouchKit.addGestureRecognizer(recognizer);
        }
	// Use this for initialization
	void Start () {
		var swipeRecognizer = new TKSwipeRecognizer(TKSwipeDirection.All,minimumSwipeDistance,allowedSwipeVariance);
		swipeRecognizer.timeToSwipe = timeToSwipe;
		swipeRecognizer.gestureRecognizedEvent += (r) =>
        {

            if (r.completedSwipeDirection == TKSwipeDirection.Left )
			{
				swipe ("left", r.startPoint);
			
			}
			if (r.completedSwipeDirection == TKSwipeDirection.Right)
			{ 
				swipe ("right", r.startPoint);

			}
			if (r.completedSwipeDirection == TKSwipeDirection.Up)
			{
				swipe ("up", r.startPoint);

			}
			if (r.completedSwipeDirection == TKSwipeDirection.Down )
			{
                swipe("down", r.startPoint);

			}
		};
		TouchKit.addGestureRecognizer(swipeRecognizer);
	}
Example #7
0
    void setupRecognizers()
    {
        // left button
        _leftRecognizer = new TKAnyTouchRecognizer(new TKRect(0f, 0f, buttonWidth, buttonHeight));
        TouchKit.addGestureRecognizer(_leftRecognizer);


        // right button
        _rightRecognizer = new TKAnyTouchRecognizer(new TKRect(buttonWidth + 1f, 0f, buttonWidth, buttonHeight));
        TouchKit.addGestureRecognizer(_rightRecognizer);


        // up button. we place it 70% of the way up the other two buttons allowing some overlap
        _upRecognizer = new TKAnyTouchRecognizer(new TKRect(0f, buttonHeight * 0.7f, buttonWidth * 2f + 1f, 20f));
        TouchKit.addGestureRecognizer(_upRecognizer);


        // attack button. we use the onSelectedEvent here because we only want to know the exact frame it was pressed
        _attackRecognizer = new TKButtonRecognizer(new TKRect(TouchKit.instance.designTimeResolution.x - buttonWidth * 2f, 0, buttonWidth, buttonHeight), 0f);
        _attackRecognizer.onSelectedEvent += (r) =>
        {
            attackDown = true;
        };
        TouchKit.addGestureRecognizer(_attackRecognizer);


        // jump button
        _jumpRecognizer = new TKButtonRecognizer(new TKRect(TouchKit.instance.designTimeResolution.x - buttonWidth, 0, buttonWidth, buttonHeight), 0f);
        TouchKit.addGestureRecognizer(_jumpRecognizer);
    }
Example #8
0
 void Start()
 {
     swipeRecognizer.gestureRecognizedEvent += (r) =>
     {
         updateDirection();
     };
     TouchKit.addGestureRecognizer(swipeRecognizer);
 }
Example #9
0
    private void Start()
    {
        var recognizer = new TKSwipeRecognizer(swipeMinMax.x, swipeMinMax.y);

        recognizer.gestureRecognizedEvent += (r) =>
        {
            Debug.Log("swipe recognizer fired: " + r);
        };
        TouchKit.addGestureRecognizer(recognizer);
    }
Example #10
0
        private void OnDestroy()
        {
            if (_swipeRecognizer == null || _tapRecognizer == null)
            {
                return;
            }

            TouchKit.removeGestureRecognizer(_swipeRecognizer);
            TouchKit.removeGestureRecognizer(_tapRecognizer);
        }
Example #11
0
    public void InitTouchControl()
    {
        var recognizer = new TKPanRecognizer();

        //recognizer.boundaryFrame = new TKRect(50f, 0,public GameObject ColorPicker;
        //public Material ColorPickerMaterial; 100f, 100f);

        // when using in conjunction with a pinch or rotation recognizer setting the min touches to 2 smoothes movement greatly
        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            recognizer.minimumNumberOfTouches = 2;
        }

        recognizer.gestureRecognizedEvent += (r) =>
        {
            //Camera.main.transform.position -= new Vector3(recognizer.deltaTranslation.x, recognizer.deltaTranslation.y) / 100;
            //Debug.Log("pan recognizer fired: " + r);
            //Debug.Log(recognizer.touchLocation());
            //Debug.Log(recognizer.state);
            if (!EventSystem.current.IsPointerOverGameObject() || true)
            {
                if (IsDrawing == false)
                {
                    clone     = (GameObject)Instantiate(LineObject);
                    clone.tag = "ARLines";
                    clone.GetComponent <LineRenderer>().material = CurrentMaterial;
                    clone.transform.parent = DrawSpace.transform;

                    line = clone.GetComponent <LineRenderer>();
                    //line.material.color = Color.white;
                    line.startWidth = LineWidth;
                    line.endWidth   = LineWidth;
                    LineDividNumber = 0;
                    IsDrawing       = true;
                }
                else
                {
                    LineDividNumber++;
                    line.positionCount = LineDividNumber;
                    Vector2 touchLocation = recognizer.touchLocation();
                    line.SetPosition(LineDividNumber - 1, TargetCamera.ScreenToWorldPoint(new Vector3(touchLocation.x, touchLocation.y, DrawOffset)));
                }
            }
        };

        // continuous gestures have a complete event so that we know when they are done recognizing
        recognizer.gestureCompleteEvent += r =>
        {
            Debug.Log("pan gesture complete");
            IsDrawing = false;
        };
        TouchKit.addGestureRecognizer(recognizer);
    }
Example #12
0
    void Start()
    {
        _statsDetail = FindObjectOfType <StatsDetail>();
        var recognizer = new TKPanRecognizer();

        recognizer.gestureRecognizedEvent += (r) =>
        {
            transform.Rotate(transform.up, -0.1f * recognizer.deltaTranslation.x);
            _statsDetail.transform.localScale = Vector3.zero;
        };
        TouchKit.addGestureRecognizer(recognizer);
    }
Example #13
0
    void Start()
    {
        var recognizer = new TKPinchRecognizer();

        recognizer.gestureRecognizedEvent += (r) =>
        {
            Vector3 newScale = transform.localScale + Vector3.one * recognizer.deltaScale;
            if (newScale.x > min && newScale.x < max)
            {
                transform.localScale = newScale;
            }
        };
        TouchKit.addGestureRecognizer(recognizer);
    }
        public TouchKitInputSystem()
        {
            panRecognizer      = new TKPanRecognizer();
            pinchRecognizer    = new TKPinchRecognizer();
            rotationRecognizer = new TKRotationRecognizer();

            panRecognizer.gestureRecognizedEvent      += OnPan;
            pinchRecognizer.gestureRecognizedEvent    += OnPinch;
            rotationRecognizer.gestureRecognizedEvent += OnRotation;

            TouchKit.addGestureRecognizer(panRecognizer);
            TouchKit.addGestureRecognizer(pinchRecognizer);
            TouchKit.addGestureRecognizer(rotationRecognizer);
        }
Example #15
0
    public void update()
    {
        // reset our state
        leftDown = upDown = rightDown = attackDown = jumpDown = false;

        // first update our touches then use our recognizers to set our state
        TouchKit.updateTouches();

        leftDown  = _leftRecognizer.state == TKGestureRecognizerState.RecognizedAndStillRecognizing;
        rightDown = _rightRecognizer.state == TKGestureRecognizerState.RecognizedAndStillRecognizing;
        upDown    = _upRecognizer.state == TKGestureRecognizerState.RecognizedAndStillRecognizing;

        jumpDown = _jumpRecognizer.state == TKGestureRecognizerState.RecognizedAndStillRecognizing;
    }
Example #16
0
        protected void Awake()
        {
            this.m_unityEventSystem = base.GetComponent <EventSystem>();
            this.m_usesTouch        = this.UnityEventSystem.currentInputModule is TouchInputModule;
            float num = (Screen.dpi != 0f) ? Screen.dpi : 72f;

            this.m_unityEventSystem.pixelDragThreshold = Mathf.FloorToInt(num * 0.1f);
            this.TouchKit = base.gameObject.AddComponent <TouchKit>();
            this.TouchKit.autoScaleRectsAndDistances = true;
            this.TouchKit.shouldAutoUpdateTouches    = true;
            this.TouchKit.maxTouchesToProcess        = 1;
            this.TouchKit.drawDebugBoundaryFrames    = !ConfigApp.ProductionBuild;
            this.TouchKit.drawTouches        = !ConfigApp.ProductionBuild;
            this.TouchKit.simulateTouches    = Application.isEditor;
            this.TouchKit.simulateMultitouch = Application.isEditor;
            TKSwipeRecognizer recognizer = new TKSwipeRecognizer(0.2f);

            recognizer.gestureRecognizedEvent += delegate(TKSwipeRecognizer r) {
                if (this.InputEnabled && (PlayerView.Binder.EventBus != null))
                {
                    PlayerView.Binder.EventBus.GestureSwipeRecognized(r);
                }
            };
            TouchKit.addGestureRecognizer(recognizer);
            TKPanRecognizer recognizer2 = new TKPanRecognizer(0.05f);

            recognizer2.gestureRecognizedEvent += delegate(TKPanRecognizer r) {
                if (this.InputEnabled && (PlayerView.Binder.EventBus != null))
                {
                    PlayerView.Binder.EventBus.GesturePanRecognized(r);
                }
            };
            recognizer2.gestureCompleteEvent += delegate(TKPanRecognizer r) {
                if (this.InputEnabled && (PlayerView.Binder.EventBus != null))
                {
                    PlayerView.Binder.EventBus.GesturePanCompleted(r);
                }
            };
            TouchKit.addGestureRecognizer(recognizer2);
            TKTapRecognizer recognizer3 = new TKTapRecognizer(0.4f, 0.5f);

            recognizer3.gestureRecognizedEvent += delegate(TKTapRecognizer r) {
                if (this.InputEnabled && (PlayerView.Binder.EventBus != null))
                {
                    PlayerView.Binder.EventBus.GestureTapRecognized(r);
                }
            };
            TouchKit.addGestureRecognizer(recognizer3);
        }
Example #17
0
    void addTapGesture()
    {
        TKTapRecognizer tapRecognizer = new TKTapRecognizer();

        tapRecognizer.gestureRecognizedEvent += (r) =>
        {
            //Debug.Log("tap recognizer fired: " + r);
            //print("Location of tap" + r.startTouchLocation());
            _initialPosition = GetCurrentMousePosition(r.startTouchLocation()).GetValueOrDefault();
            //print("vertex count is " + _vertextCount);
            _lineRenderer.SetPosition(_vertextCount - 1, _initialPosition); //1 -> initial pos
            _lineRenderer.SetVertexCount(++_vertextCount);                  //count = 2
            isTapped = !isTapped;
        };
        TouchKit.addGestureRecognizer(tapRecognizer);
    }
    // Use this for initialization
    void Start()
    {
        var recognizer = new TKSwipeRecognizer(.1f);

        // recognizer.timeToSwipe = .1f;
        recognizer.gestureRecognizedEvent += (r) =>
        {
            TKSwipeDirection sdir = r.completedSwipeDirection;
            // Debug.Log( r.swipeVelocity );
            // Debug.Log( r.startPoint );
            // Debug.Log( r.endPoint );
            // Debug.Log( "=====" );
            Events.instance.Raise(new SwipeEvent(sdir, r.swipeVelocity));
        };
        TouchKit.addGestureRecognizer(recognizer);
    }
Example #19
0
    void addTapGesture()
    {
        TKTapRecognizer tapRecognizer = new TKTapRecognizer();

        tapRecognizer.gestureRecognizedEvent += (r) =>
        {
            //Debug.Log ("tap recognizer fired: " + r);
            if (gameObject.activeInHierarchy)
            {
                if (gameObject.GetComponent <BoxCollider> ().bounds.Contains(transform.TransformPoint(GetCurrentMousePosition(r.startTouchLocation()).GetValueOrDefault())))
                {
                    if (!isDrawing)
                    {
                        didDraw     = false;
                        isDrawing   = true;
                        _initialPos = GetCurrentMousePosition(r.startTouchLocation()).GetValueOrDefault();
                        instantiateNode(_initialPos);
                    }
                    else
                    {
                        didDraw = true;
                        float newXpos = wallList.Last().transform.position.x + wallList.Last().transform.localScale.x *Mathf.Cos(_xRotation * Mathf.PI / 180f);
                        float newYpos = wallList.Last().transform.position.y + wallList.Last().transform.localScale.x *Mathf.Sin(_xRotation * Mathf.PI / 180f);

                        newXpos = Mathf.Round(newXpos * 100) / 100f;
                        newYpos = Mathf.Round(newYpos * 100) / 100f;

                        Vector3 newPos = new Vector3(newXpos, newYpos, 0);
                        _initialPos = newPos;
                        setPreviousWallEndNode();
                        handleOverlap(wallList.Last());
                    }

                    instantiateWall(_initialPos);
                }
                else
                {
                    removeDrawingWall();
                }
            }
        };


        TouchKit.addGestureRecognizer(tapRecognizer);
    }
Example #20
0
    private void Start()
    {
        foreach (OnlineMapsMarker3D marker in markers3D.Where(m => !m.inited))
        {
            marker.control = this;
            marker.Init(transform);
        }
        UpdateMarkers3D();

        var recognizer = new TKRotationRecognizer();

        recognizer.gestureRecognizedEvent += (r) =>
        {
            cameraRotation.y -= recognizer.deltaRotation * cameraSpeed.x;
            Debug.Log("rotation recognizer fired: " + r);
        };
        TouchKit.addGestureRecognizer(recognizer);
    }
Example #21
0
        private void Start()
        {
            // Add event handlers for swiping the screen
            _swipeRecognizer = new TKSwipeRecognizer(MinSwipeDistanceCm)
            {
                minimumNumberOfTouches = 1,
                maximumNumberOfTouches = 10,
                timeToSwipe            = 1f
            };

            _swipeRecognizer.gestureRecognizedEvent += OnSwipe;
            TouchKit.addGestureRecognizer(_swipeRecognizer);

            // Add an event handler for tapping the screen
            _tapRecognizer = new TKTapRecognizer();
            _tapRecognizer.gestureRecognizedEvent += OnTap;
            TouchKit.addGestureRecognizer(_tapRecognizer);
        }
    private void Start()
    {
        TouchKit.instance.designTimeResolution = new Vector2(800, 480);
        Debug.Log(Camera.main);

        TKAnyTouchRecognizer tapLeft = new TKAnyTouchRecognizer(new TKRect(0, 0, xBorderLeftRight, 480));

        tapLeft.onEnteredEvent += TapLeft_onEnteredEvent;
        tapLeft.onExitedEvent  += TapLeft_onExitedEvent;

        TKAnyTouchRecognizer tapRight = new TKAnyTouchRecognizer(new TKRect(xBorderLeftRight, 0, xBorderRightGesture - xBorderLeftRight, 480));

        tapRight.onEnteredEvent += TapRight_onEnteredEvent;
        tapRight.onExitedEvent  += TapRight_onExitedEvent;

        TKSwipeRecognizer swipeDash = new TKSwipeRecognizer(1);

        swipeDash.boundaryFrame                  = new TKRect(xBorderRightGesture, 0, 800 - xBorderRightGesture, 480);
        swipeDash.gestureRecognizedEvent        += SwipeDash_gestureRecognizedEvent;
        swipeDash.timeToSwipe                    = 0;
        swipeDash.TrackTouchesStartedOutOfBounds = true;

        TKLongPressRecognizer block = new TKLongPressRecognizer(1, 4, 1);

        block.boundaryFrame = new TKRect(xBorderRightGesture, 0, 800 - xBorderRightGesture, 480);
        block.cancelAfterRecognitionWhenOutOfBounds = true;
        block.ignoreMovementAfterRecognition        = true;
        block.gestureRecognizedEvent += Block_gestureRecognizedEvent;
        block.gestureCompleteEvent   += Block_gestureCompleteEvent;

        TKTapRecognizer jump = new TKTapRecognizer();

        jump.boundaryFrame           = new TKRect(xBorderRightGesture, yBorderJumpGesture, 800 - xBorderRightGesture, 480 - yBorderJumpGesture);
        jump.gestureRecognizedEvent += Jump_gestureRecognizedEvent;

        TouchKit.addGestureRecognizer(tapRight);
        TouchKit.addGestureRecognizer(tapLeft);
        TouchKit.addGestureRecognizer(swipeDash);
        TouchKit.addGestureRecognizer(block);
        TouchKit.addGestureRecognizer(jump);

        playerMotor.motorInput = this;
        health.OnDeath        += Health_OnDeath;
    }
    void addPanGestureRecognizer()
    {
        panRecognizer = new TKPanRecognizer();
        panRecognizer.gestureRecognizedEvent += (r) =>
        {
            //print("Touch delta is " + r.deltaTranslation.y);
            //print("Touch delta cm is " + r.deltaTranslationCm);
            print("Scale" + transform.localScale.y + 0.1f * r.deltaTranslation.y);
            float yScale = Mathf.Max(transform.localScale.y + 0.1f * r.deltaTranslation.y, 1.0f);
            transform.localScale = new Vector3(transform.localScale.x, yScale, 0);
            //Debug.Log(r);
        };

        panRecognizer.gestureCompleteEvent += r =>
        {
            Debug.Log("pan gesture complete");
        };

        TouchKit.addGestureRecognizer(panRecognizer);
    }
 private void OnEnable()
 {
     rotationRecognizer = new TKRotationRecognizer();
     rotationRecognizer.gestureRecognizedEvent += (r) =>
     {
         float rotaionValue = -(r.deltaRotation * 2.0f);
         if (rotationX)
         {
             transform.Rotate(rotaionValue, 0, 0);
         }
         else if (rotationY)
         {
             transform.Rotate(0, rotaionValue, 0);
         }
         else if (rotationZ)
         {
             transform.Rotate(0, 0, rotaionValue);
         }
     };
     TouchKit.addGestureRecognizer(rotationRecognizer);
 }
Example #25
0
        void InitializeRecognizers()
        {
            swipeRecognizer = new TKSwipeRecognizer();
            swipeRecognizer.gestureRecognizedEvent += OnSwipeRecognized;
            TouchKit.addGestureRecognizer(swipeRecognizer);

            tapRecognizer = new TKTapRecognizer();
            tapRecognizer.gestureRecognizedEvent += OnTapRecognized;
            TouchKit.addGestureRecognizer(tapRecognizer);

            pinchRecognizer = new TKPinchRecognizer();
            pinchRecognizer.gestureRecognizedEvent += OnPinchRecognized;
            TouchKit.addGestureRecognizer(pinchRecognizer);

            longPressRecognizer = new TKLongPressRecognizer();
            longPressRecognizer.gestureRecognizedEvent += OnLongTapRecognized;
            longPressRecognizer.gestureCompleteEvent   += OnLongTapFinished;
            TouchKit.addGestureRecognizer(longPressRecognizer);

            Debug.Log("recognizers successfully initialized");
        }
Example #26
0
        private void Start()
        {
            var panRecognizer = new TKPanRecognizer();

            panRecognizer.gestureRecognizedEvent += OnPan;
            panRecognizer.gestureCompleteEvent   += OnPanComplete;
            TouchKit.addGestureRecognizer(panRecognizer);

            var tapRecognizer = new TKTapRecognizer();

            tapRecognizer.gestureRecognizedEvent += OnTap;
            TouchKit.addGestureRecognizer(tapRecognizer);

            // Start with the saved start level
            _selectedLevel = Levels.CurrentLevelNum;

            GenerateLevelsList();

            if (_levels[_selectedLevel] == null)
            {
                Debug.LogError($"Failed to start at level ({_selectedLevel})");
                return;
            }

            var puzzleState = _levels[_selectedLevel].GetComponent <PuzzleState>();
            var puzzleScale = _levels[_selectedLevel].GetComponent <PuzzleScale>();

            puzzleState.BoardEnabled = true;
            puzzleScale.PuzzleInit  += OnPuzzleInit;
            _levels[_selectedLevel].GetComponent <BoardAction>().PuzzleWin += OnPuzzleWin;
            puzzleState.LevelStateChanged += OnLevelStateChanged;

            var bounds = _levelBounds[_selectedLevel];
            var mid    = (bounds.Item1 + bounds.Item2) / 2f;

            transform.position = Vector3.up * mid;

            puzzleState.Init(_selectedLevel);
        }
Example #27
0
    // Start is called before the first frame update
    void Start()
    {
        _mainCamera = Camera.main;

        var recognizer = new TKPanRecognizer();

        // when using in conjunction with a pinch or rotation recognizer setting the min touches to 2 smoothes movement greatly
        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            recognizer.minimumNumberOfTouches = 2;
        }

        recognizer.gestureRecognizedEvent += (r) =>
        {
            Vector3 forward = Vector3.ProjectOnPlane(_mainCamera.transform.forward, Vector3.up) * recognizer.deltaTranslation.y;
            Vector3 right   = Vector3.ProjectOnPlane(_mainCamera.transform.right, Vector3.up) * recognizer.deltaTranslation.x;
            Vector3 newPos  = (forward + right) / 1000;
            transform.position += newPos;
        };

        TouchKit.addGestureRecognizer(recognizer);
    }
    void Start()
    {
        Application.targetFrameRate = 60;
        currentStickerParent        = futureWorldStickerParent;
        currentStickerPicker        = futureWorldStickerPicker;
        currentPostProcessVolume    = normalPostProcessVolume;
        currentOverlay = futureWorldOverlay;
        screenCenter   = new Vector3(Screen.width / 2, Screen.height / 2, 0);
        var pinchRecognizer = new TKPinchRecognizer();

        pinchRecognizer.gestureRecognizedEvent += OnPinchRecognized;
        pinchRecognizer.gestureCompleteEvent   += OnGestureComplete;
        TouchKit.addGestureRecognizer(pinchRecognizer);
        var rotationRecognizer = new TKRotationRecognizer();

        rotationRecognizer.gestureRecognizedEvent += OnRotationRecognized;
        TouchKit.addGestureRecognizer(rotationRecognizer);
        var tapRecognizer = new TKTapRecognizer();

        tapRecognizer.gestureRecognizedEvent += OnTapRecognized;
        TouchKit.addGestureRecognizer(tapRecognizer);
        SetupShowMainTableTweens();
    }
Example #29
0
    // Use this for initialization
    void Start()
    {
        instance = this;
        print("GameManager instance change, Showcase mode is " + (instance.mainMenuMode ? "on" : "off"));

        if (!mainMenuMode)
        {
            GameLevel = 1;

            EndDayManager.AddExpense(ExpenseType.Maintenance, Departments.Start, maintenanceCost);

            Cash = startingMoney;

            rt.gestureRecognizedEvent += (i) =>
            {
                if (!EndDayManager.IsPanelOpen)
                {
                    cameraPivot.Rotate(Vector3.up, -rt.deltaRotation * rotateSensitivity, Space.World);
                }
            };

            pr.gestureRecognizedEvent += (i) =>
            {
                if (!EndDayManager.IsPanelOpen)
                {
                    Camera.main.transform.Translate(Vector3.forward * 2 * pr.deltaScale * pinchSensitivity);
                }
            };
            TouchKit.addGestureRecognizer(rt);
            TouchKit.addGestureRecognizer(pr);

            DaytimeManager.OnDayEnd += DaytimeManager_OnDayEnd;
            EventManager.RunStartEvent();

            gameFaderAnim.Play("FadeOut");
        }
    }
Example #30
0
 private void OnApplicationQuit()
 {
     _instance = null;
     Destroy(gameObject);
 }
Example #31
0
 private void OnApplicationQuit()
 {
     _instance = null;
 }
Example #32
0
	private void OnApplicationQuit()
	{
		_instance = null;
		Destroy( gameObject );
	}