Example #1
0
        public static List <Vector3Int> GetClosestMachines(Vector3Int position, Players.Player owner, int maxDistance)
        {
            var closest = int.MaxValue;
            var retVal  = new List <Vector3Int>();

            foreach (var machine in Machines[owner])
            {
                var dis = Math.RoundToInt(Vector3.Distance(machine.Key.Vector, position.Vector));

                if (dis <= maxDistance && dis <= closest)
                {
                    retVal.Add(machine.Key);
                }
            }

            return(retVal);
        }
Example #2
0
        public static List <Vector3Int> GetClosestObjective(Vector3Int position, Colony owner, int maxDistance, string category)
        {
            var closest = int.MaxValue;
            var retVal  = new List <Vector3Int>();

            if (Objectives.ContainsKey(owner) && Objectives[owner].ContainsKey(category))
            {
                foreach (var machine in Objectives[owner][category])
                {
                    var dis = Math.RoundToInt(UnityEngine.Vector3.Distance(machine.Key.Vector, position.Vector));

                    if (dis <= maxDistance && dis <= closest)
                    {
                        retVal.Add(machine.Key);
                    }
                }
            }

            return(retVal);
        }