void StartGame(GameObject menu) { _hideTriggerEvent.OnAnimationEnd.RemoveListener(StartGame); _mainMenuCanvas.SetActive(false); _gameFlowManager.StartGame(); _gameMenuManager.InitializeInputHandlers(); }
public void Update() { _UpdateApplicationLifecycle(); if (GameFlowManager.gameStarted) { return; } // Raycast against the location the screen mid-point to search for planes. TrackableHit hit; TrackableHitFlags raycastFilter = TrackableHitFlags.PlaneWithinPolygon | TrackableHitFlags.FeaturePointWithSurfaceNormal; if (Frame.Raycast(Screen.width / 2f, Screen.height / 2f, raycastFilter, out hit)) { if (hit.Trackable is DetectedPlane && (hit.Trackable as DetectedPlane).PlaneType == DetectedPlaneType.HorizontalUpwardFacing) { if (planeDetected == null) { planeDetected = Instantiate(planeDetectedPrefab); planeDetected.transform.position = hit.Pose.position; //planeDetected.transform.Rotate (0, _PrefabRotation, 0, Space.Self); planeDetected.transform.parent = hit.Trackable.CreateAnchor(hit.Pose).transform; } else { planeDetected.transform.position = hit.Pose.position; //planeDetected.transform.rotation = hit.Pose.rotation; //planeDetected.transform.Rotate (0, _PrefabRotation, 0, Space.Self); } } } Touch touch; // If the player has not touched the screen, we are done with this update. if (Input.touchCount < 1 || (touch = Input.GetTouch(0)).phase != TouchPhase.Began) { return; } // Should not handle input if the player is pointing on UI. if (EventSystem.current.IsPointerOverGameObject(touch.fingerId)) { return; } if (Frame.Raycast(touch.position.x, touch.position.y, raycastFilter, out hit)) { if ((hit.Trackable is DetectedPlane) && Vector3.Dot(firstPersonCamera.transform.position - hit.Pose.position, hit.Pose.rotation * Vector3.up) < 0) { Debug.Log("Hit at back of the current DetectedPlane"); } else { if (hit.Trackable is DetectedPlane && (hit.Trackable as DetectedPlane).PlaneType == DetectedPlaneType.HorizontalUpwardFacing) { planeDetected.SetActive(false); tears.SetActive(true); //tears.transform.position = hit.Pose.position; plane = Instantiate(planePrefab); plane.transform.position = hit.Pose.position; //plane.transform.Rotate (0, _PrefabRotation, 0, Space.Self); //gameObject.transform.parent = hit.Trackable.CreateAnchor (hit.Pose).transform; GameFlowManager.tools.Water = plane; GameFlowManager.plane.transform.parent = plane.transform; GameFlowManager.plane.transform.localPosition = Vector3.zero; //plane.GetComponent<DraggableItem>().AddTarget(target); //plane.GetComponent<DraggableItem>().AddResultEvent(resultEvent); StartCoroutine(TriggerPlaneGeneration()); if (!GameFlowManager.gameStarted) { GameFlowManager.StartGame(); } } } } }