Beispiel #1
0
        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);
        }
Beispiel #2
0
        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;
            }
        }
Beispiel #3
0
 public void ChangeJob(UnitJob job)
 {
     StopCurrentState();
     PushNewStateHandler(new ChangeJobState(unit, job));
 }