// sets the unit's movement path void Update_UnitMovement() { if (Input.GetMouseButtonUp(1) || SelectedUnit == null) { Debug.Log("End Unit Movement"); //copy over pathfinding before exiting if (SelectedUnit != null) { SelectedUnit.SetHexPath(hexPath); StartCoroutine(hexMap.DoUnitMoves(SelectedUnit)); } Update_CurrentFunc = CancelUpdateFunc; return; } // // we have a selected unit // // pass pathfinding data for potential unit path if (hexUnderMouse != null && (hexPath == null || hexUnderMouse != lastHexUnderMouse)) { hexPath = QPath.QPath.FindPath <Hex>( hexMap, SelectedUnit, SelectedUnit.Hex, hexUnderMouse, Hex.CostEstimate); } }
void Update_UnitMovement() { if (Input.GetMouseButtonUp(1) || SelectedUnit == null) { Util.WriteDebugLog(string.Format("Complete Unit movements"), GameManager.LogLevel_Info, GameManager.instance.debug, GameManager.instance.LogLevel); //Todo copy pathfinding path to units movement queue if (SelectedUnit != null) { SelectedUnit.SetHexPath(hexPath); //TODO: tell unit and or hexmap to process unit movement StartCoroutine(hexMap.DoUnitMoves(SelectedUnit)); } Cancel(); return; } // We have a selected unit // Look at hex under mouse // is this a different hex than before? or we don't alredy have a path if (hexPath == null || hexUnderMouse != hexLastUnderMouse) { // Do a pathfinding search to that hex hexPath = QPath.QPath.FindPath <Hex>( hexMap, SelectedUnit, SelectedUnit.Hex, hexUnderMouse, Hex.CostEstimate ); } }