private void OnRightClick() { GameObject hittedObj = GameObjectUnderMouse(); int hittedObjLayer = hittedObj.layer; if (hittedObjLayer == layerMaskToLayer(TerrainLayerMask)) { ClearDeadUnits(); SortByDistance(endDragRayHit.point); for (int i = 0; i < SelectedUnits.Count; i++) { if (SelectedUnits[i].IsTaskAvailable <GoToTask>()) { GoToTask goToTask = SelectedUnits[i].ChangeTask <GoToTask>(); goToTask.StartTask(endDragRayHit.point); } } } else if (hittedObjLayer == layerMaskToLayer(EnemyUnitsLayerMask) || hittedObjLayer == layerMaskToLayer(EnemyBuildingLayerMask)) { ClearDeadUnits(); SortByDistance(hittedObj.transform.position); for (int i = 0; i < SelectedUnits.Count; i++) { if (SelectedUnits[i].IsTaskAvailable <AttackTask>()) { AttackTask attackTask = SelectedUnits[i].ChangeTask <AttackTask>(); attackTask.StartTask(hittedObj.transform); } } } }
public void StartTask(Transform unitToFollow) { base.StartTask(); TargetToFollow = unitToFollow; goToTask.StartTask(unitToFollow.position, transform.localScale.magnitude); }