コード例 #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);
        }
コード例 #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;
            }
        }
コード例 #3
0
 public void ChangeJob(UnitJob job)
 {
     StopCurrentState();
     PushNewStateHandler(new ChangeJobState(unit, job));
 }