private bool TryGetJobFromType(UnitJobType jobType, out UnitJob result) { result = null; foreach (var job in jobs) { if (job.jobType != jobType) { continue; } result = job; return(true); } return(false); }
public ChangeJobState(Unit unit, UnitJob job) { this.unit = unit; this.job = job; var buildings = unit.UnitTeam.GetBuildingsOfType(job.buildingNeeded); var distance = float.MaxValue; foreach (var building in buildings) { // FIXME: Direct distance w/o pathfinding. var d = Vector3.Distance(unit.transform.position, building.entrance.position); if (d >= distance) { continue; } distance = d; targetBuilding = building; } }
public void ChangeJob(UnitJob job) { StopCurrentState(); PushNewStateHandler(new ChangeJobState(unit, job)); }