public static void PlaceObstacle(string obstacleName, Vector3 position, Vector3 angles) { Phases.CurrentSubPhase.IsReadyForCommands = false; ChosenObstacle = ObstaclesManager.GetObstacleByName(obstacleName); ChosenObstacle.ObstacleGO.transform.position = position; ChosenObstacle.ObstacleGO.transform.eulerAngles = angles; Board.ToggleOffTheBoardHolder(false); ChosenObstacle.ObstacleGO.transform.parent = Board.BoardTransform; ChosenObstacle.IsPlaced = true; ChosenObstacle = null; IsEnteredPlacementZone = false; IsEnteredPlaymat = false; MovementTemplates.ReturnRangeRulerR1(); MovementTemplates.ReturnRangeRulerR2(); if (ObstaclesManager.GetPlacedObstaclesCount() < 6) { Phases.CurrentSubPhase.Next(); } else { FinishSubPhase(); } }
private void TryToSelectObstacle() { if (!EventSystem.current.IsPointerOverGameObject()) { if (Input.GetKeyUp(KeyCode.Mouse0)) { RaycastHit hitInfo = new RaycastHit(); if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo)) { if (hitInfo.transform.tag.StartsWith("Asteroid")) { GameObject obstacleGO = hitInfo.transform.parent.gameObject; GenericObstacle clickedObstacle = ObstaclesManager.GetObstacleByName(obstacleGO.name); if (!clickedObstacle.IsPlaced) { SelectObstacle(clickedObstacle); } } } } } }
private void TryToSelectObstacle() { if (!EventSystem.current.IsPointerOverGameObject() && (Input.touchCount == 0 || !EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))) { // On touch devices, select on down instead of up event so drag can begin immediately if (Input.GetKeyUp(KeyCode.Mouse0) || (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began)) { RaycastHit hitInfo = new RaycastHit(); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); bool castHit = Physics.Raycast(ray, out hitInfo); // If an asteroid wasn't found and we're on touch, see if the user tapped right next to an asteroid // Since the asteroid can be small, they can be hard to touch and this helps with that if (CameraScript.InputTouchIsEnabled && (!castHit || !hitInfo.transform.tag.StartsWith("Asteroid"))) { castHit = Physics.SphereCast(ray, 0.1f, out hitInfo, 10f); } // Select the obstacle found if it's valid if (castHit && hitInfo.transform.tag.StartsWith("Asteroid")) { GameObject obstacleGO = hitInfo.transform.parent.gameObject; GenericObstacle clickedObstacle = ObstaclesManager.GetObstacleByName(obstacleGO.name); if (!clickedObstacle.IsPlaced) { SelectObstacle(clickedObstacle); } } } } }
public static void ConfirmSelectionOfObstacle(string obstacleName) { GenericObstacle obstacle = ObstaclesManager.GetObstacleByName(obstacleName); SelectTargetAction(obstacle); }