void Update() { CursorType cursor = CursorType.Default; if (!EventSystem.current.IsPointerOverGameObject()) { if (CastingSkill) { cursor = CursorType.CastSkill; } Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { int x = (int)hit.point.x; int y = (int)hit.point.z; if (hit.transform.tag == "Map") { if (Input.GetMouseButtonDown(0)) { if (!MapMetrics.InsideMap(y, x)) { if (curRegion != null) { curRegion.Selected = false; } curRegion = null; if (army != null) { DeselectArmy(); } } else { RegionTap(Main.regions[regionIndex[y, x]]); } } if (Input.GetMouseButtonDown(1)) { army?.TryMoveTo(hit.point); ship?.TryMoveTo(hit.point); if (curPort) { curPort.ShipOut(hit.point); } } } State other = null; IFightable target = null; if (hit.transform.tag == "Unit") { Army sel = hit.transform.GetComponent <Army>(); if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) { ArmyTap(sel, Input.GetMouseButtonDown(0)); } other = sel.curOwner; target = sel; if (CastingSkill) { if (CastSkill is IArmyCastable cast) { if (cast.CanCastOnArmy(sel)) { cursor = CursorType.CanCastSkill; } } } else { if (other == curPlayer && sel != army) { cursor = CursorType.Select; } } } if (hit.transform.tag == "Ship") { Ship sel = hit.transform.GetComponent <Ship>(); if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) { ShipTap(sel, Input.GetMouseButtonDown(0)); } other = sel.curOwner; if (CastingSkill) { } else { if (other == curPlayer && sel != ship) { cursor = CursorType.Select; } } } if (hit.transform.tag == "Town") { Region reg = MapMetrics.regions[int.Parse(hit.transform.name)]; highlightRegion = reg; TownTap(reg, Input.GetMouseButtonDown(0), Input.GetMouseButtonDown(1)); reg.bar.Active = true; other = reg.curOwner; target = reg; if (CastingSkill) { if (CastSkill is IRegionCastable cast) { if (cast.CanCastOnRegion(reg)) { cursor = CursorType.CanCastSkill; } } } else { if (other == curPlayer && reg != curRegion) { cursor = CursorType.Select; } } } else { if (highlightRegion != null) { highlightRegion.bar.Active = false; } } if (hit.transform.GetComponent <Port>()) { Port port = hit.transform.GetComponent <Port>(); if (Input.GetMouseButtonDown(0) && port.curOwner == curPlayer && port.Ship) { curPort = port; DeselectShip(); } if (Input.GetMouseButtonDown(1) && ship && port.CanshipOn(ship)) { ship.TryMoveTo(port); } } if (!CastingSkill && target != null && army != null && army.CanAttack(target, TargetType)) { switch (TargetType) { case DamageType.Melee: case DamageType.Charge: cursor = CursorType.MeleeAttack; break; case DamageType.Range: cursor = CursorType.RangeAttack; break; case DamageType.Siege: cursor = CursorType.SiegeAttack; break; } } } } if (curRegion == null) { MenuManager.HiddenProvinceMenu(); } if (cursor != cursorType) { cursorType = cursor; CursorHandler.SetCursor(cursorType); } }