private void UnMouseover(GameObject gameObject) { MouseOverObjectResponse toolMouseOverer = new MouseOverObjectResponse(); if (gameObject.tag == "Unit") { toolMouseOverer.ClearMouseover(MouseoveredUnit.gameObject); MouseoveredUnit = null; } if (gameObject.tag == "Tile") { foreach (UnitScript unit in coloredUnits) { toolMouseOverer.PaintObject(unit.gameObject, Color.white); } coloredUnits.Clear(); toolMouseOverer.ClearMouseover(mouseoveredTile.gameObject); mouseoveredTile = null; } if (gameObject.layer == 11) { toolMouseOverer.ClearMouseover(mouseoveredDestructible); mouseoveredDestructible = null; } }
private void Mouseover(GameObject mouseOveredObject) { MouseOverObjectResponse toolMouseOverer = new MouseOverObjectResponse(); if (mouseOveredObject.tag == "Unit") { if (MouseoveredUnit != null) { toolMouseOverer.ClearMouseover(MouseoveredUnit.gameObject); } MouseoveredUnit = mouseOveredObject.GetComponent <UnitScript>(); toolMouseOverer.Mouseover(MouseoveredUnit.gameObject); } if (mouseOveredObject.tag == "Tile") { Tile oldTile = mouseoveredTile; if (mouseoveredTile != null) { UnMouseover(mouseoveredTile.gameObject); } if (mouseoveredTile != null) { toolMouseOverer.ClearMouseover(mouseoveredTile.gameObject); } mouseoveredTile = mouseOveredObject.GetComponent <Tile>(); toolMouseOverer.Mouseover(mouseoveredTile.gameObject); if (SelectedUnit != null && GameStateManager.Instance.GameState == GameStates.MoveState && MovementQuestions.Instance.CanUnitMoveAtAll(SelectedUnit.GetComponent <UnitMovement>())) { if (mouseoveredTile.theColor == Color.red) { foreach (Tile neighbour in mouseoveredTile.GetNeighbours()) { if (neighbour.myUnit != null && neighbour.myUnit.PlayerID != SelectedUnit.PlayerID) { toolMouseOverer.PaintObject(neighbour.myUnit.gameObject, Color.red); coloredUnits.Add(neighbour.myUnit); } } } if (mouseoveredTile.theColor == Color.cyan && SelectedUnit.isRanged && SelectedUnit.GetComponent <ShootingScript>().CanShoot) { foreach (UnitScript enemy in FindObjectsOfType <UnitScript>()) { if (ShootingScript.WouldItBePossibleToShoot(SelectedUnit.GetComponent <ShootingScript>(), mouseoveredTile.transform.position, enemy.transform.position).Key&& enemy.PlayerID != SelectedUnit.PlayerID) { toolMouseOverer.PaintObject(enemy.gameObject, Color.red); coloredUnits.Add(enemy); } } } if (mouseoveredTile.theColor == Color.white && mouseoveredTile != SelectedUnit.myTile) { PathCreator.Instance.ClearPath(); } } MovementSystem.Instance.CheckForAddingSteps(SelectedUnit, oldTile, mouseoveredTile); } if (mouseOveredObject.layer == 11) { toolMouseOverer.ClearMouseover(mouseoveredDestructible); mouseoveredDestructible = mouseOveredObject; toolMouseOverer.Mouseover(mouseoveredDestructible); } }