void Update() { if (mDialogueController.GetComponent <DialogueController>().DialogueGoing) { mTileSelector.SetActive(false); return; } // If we're planning an action or the movement stage is happening, return if (mActionComponent.mPlanningAction || mFlowController.mInMotion) { if (mFlowController.mInMotion) { DeleteDrawnObjects(); } mTileSelector.SetActive(false); return; } // Check to see if we won the mission if (mFlowController.CheckWinner() == 1) { mDialogueController.GetComponent <DialogueController>().WonMission(); } mTileSelector.SetActive(true); // Move the tile selector to the mouse position Vector3Int MouseCellPos = mMouseLocation.GetMouseCellPosition(); if (mLastPos != MouseCellPos) { mTileSelector.transform.position = MouseCellPos; mLastPos = MouseCellPos; // If we're simply moving the mouse around, make sure to clean up any drawn objects if (mSelectedCharacter == null) { DeleteDrawnObjects(); mPassiveText.GetComponentInChildren <Text>().text = ""; mActionComponent.Hovering(false); } } // When our cursor moves, check what units we're colliding with Collider2D[] mColliders; if ((mColliders = Physics2D.OverlapCircleAll(mMouseLocation.GetMouseWorldPosition(), 0f)).Length > 0) { foreach (var collider in mColliders) { if (collider.tag == "MAP") { return; } // If mouse collided with a friendly unit, start building its movement stack if (collider.tag == "FriendlyUnit") { mPassiveText.GetComponentInChildren <Text>().text = collider.gameObject.GetComponent <CharacterStats>().GetCharacterPassive(); // New command to move a unit if (Input.GetMouseButtonDown(0) && !collider.GetComponent <Movement>().mLocked) { mSelectedCharacter = collider.gameObject; mDrawnObjects.Add(Instantiate(GreenTile, MouseCellPos, new Quaternion())); mMovementStack.Add(MouseCellPos); StartCoroutine(DrawingMachine()); } // Hovering over a unit, draw its movement if it's locked if (collider.gameObject.GetComponent <Movement>().mLocked&& mDrawnObjects.Count == 0) { DrawMovementColors(collider.gameObject.GetComponent <Movement>().GetMovementStack()); mActionComponent.mAction = collider.gameObject.GetComponent <Movement>().mAction; mActionComponent.mTurnText = collider.gameObject.GetComponent <Movement>().mTurnText; mActionComponent.Hovering(true, collider.gameObject); } } collider.gameObject.GetComponent <CharacterStats>().UI_SetStats(); } } }