/// <summary> /// Returns a region based on card info. /// </summary> private RectTransform SelectRegion(Card card) { DropRegion dropRegion = card.GetCardInfo().DropRegion; switch (dropRegion) { case DropRegion.WholeMap: return(null); case DropRegion.EnemyHalf: return(_enemyHalf); case DropRegion.EnemySpawn: return(_enemySpawn); case DropRegion.AllyHalf: return(_allyHalf); case DropRegion.AllySpawn: return(_allySpawn); default: return(null); } }
/// <summary> /// Given the <see cref="DropRegion"/>, returns a node closest to given world position. /// </summary> public Vector2Int ScreenToNodePos(Vector3 position, bool isHost, DropRegion dropRegion) { switch (dropRegion) { case DropRegion.WholeMap: return(GetClosestNode_WholeMap(position)); case DropRegion.EnemyHalf: return(GetClosestNode_HalfMap(position, !isHost)); case DropRegion.EnemySpawn: return(GetClosestNode_Spawn(position, !isHost)); case DropRegion.AllyHalf: return(GetClosestNode_HalfMap(position, isHost)); case DropRegion.AllySpawn: return(GetClosestNode_Spawn(position, isHost)); default: break; } Debug.LogError("Drop region " + dropRegion + " was not handled"); return(new Vector2Int()); }
/// <summary> /// Invoked on every update when this object is visible. /// Sends a raycast to determine current poiner position on the battlefield. /// </summary> public virtual void UpdatePosition(DropRegion dropRegion, LayerMask mask) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity, mask)) { Vector2Int nodePosition = Scene02BattleController.Instance.ScreenToNodePos(hit.point, _isHost, dropRegion); Node node = Scene02BattleController.Instance.Nodes[nodePosition.x, nodePosition.y]; transform.position = node.transform.position; } }
/// <summary> /// Invoked on every update when this object is visible. /// Sends a raycast to determine current poiner position on the battlefield. /// </summary> public virtual void UpdatePosition(DropRegion dropRegion, LayerMask mask) { bool isHost = MatchCommunicationManager.Instance.IsHost; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity, mask)) { Vector2Int nodePosition = GameManager.Instance.ScreenToNodePos(hit.point, isHost, dropRegion); Node node = GameManager.Instance.Nodes[nodePosition.x, nodePosition.y]; transform.position = node.transform.position; } }
public static void setGameObjects(GameObject codeBox, GameObject questionTextBox, GameObject statusMessageBox, GameObject checkButton, GameObject yesButton, GameObject noButton, GameObject continueButton, DropRegion dropRegion, AudioSource correctSound, AudioSource incorrectSound) { Question.codeBox = codeBox; Question.questionTextBox = questionTextBox; Question.statusText = statusMessageBox; Question.checkButton = checkButton; Question.yesButton = yesButton; Question.noButton = noButton; Question.continueButton = continueButton; Question.dropRegion = dropRegion; Question.correctSound = correctSound; Question.incorrectSound = incorrectSound; }