Exemple #1
0
        /// <summary>
        /// Moves this unit group according to the given pattern.
        /// </summary>
        /// <param name="pattern">The pattern to use when calculating where the units should go.</param>
        public void MoveTo(UnitGroupPattern pattern)
        {
            LinkedList<Point> points = pattern.ApplyPattern();
            int count = 0;
            foreach (Unit unit in units)
            {
                // This part is used for checking whether an Engineer should stop constructing or not.
                if (unit.type == Unit.Type.Engineer)
                {
                    Engineer temp = (Engineer)unit;

                    if (temp.constructing != null)
                    {
                        if (temp.constructing.state == Building.State.Constructing)
                        {
                            temp.constructing.state = Building.State.Interrupted;
                        }
                        else if (temp.constructing.state == Building.State.Repairing)
                        {
                            temp.constructing.state = Building.State.Finished;
                        }

                        temp.constructing.constructedBy = null;
                        temp.constructing = null;
                    }
                }
                // </check>

                Point farthestPoint = GetClosestPoint(unit, points);
                unit.MoveToQueue(farthestPoint);
                points.Remove(farthestPoint);
                count++;
            }
        }
Exemple #2
0
 /// <summary>
 /// Moves this unit group according to the given pattern.
 /// </summary>
 /// <param name="pattern">The pattern to use when calculating where the units should go.</param>
 public void Assault(UnitGroupPattern pattern)
 {
     MoveTo(pattern);
     for (int i = 0; i < units.Count(); i++)
     {
         Unit unit = units.ElementAt(i);
         unit.SetAssaultLocation(pattern.location);
         unit.SetJob(Unit.Job.Attacking);
     }
 }
Exemple #3
0
 /// <summary>
 /// Moves this unit group according to the given pattern.
 /// </summary>
 /// <param name="pattern">The pattern to use when calculating where the units should go.</param>
 public void MoveTo(UnitGroupPattern pattern)
 {
     LinkedList<Point> points = pattern.ApplyPattern();
     int count = 0;
     foreach (Unit unit in units)
     {
         Point farthestPoint = GetClosestPoint(unit, points);
         unit.MoveToQueue(farthestPoint);
         points.Remove(farthestPoint);
         count++;
     }
 }