Beispiel #1
0
        protected override void DoTaskInternal( RTSUnitAI.Task task )
        {
            if( task.Type != Task.Types.ProductUnit )
                ControlledObject.StopProductUnit();

            base.DoTaskInternal( task );

            if( task.Type == Task.Types.ProductUnit )
            {
                ControlledObject.StartProductUnit( (RTSUnitType)task.EntityType );
            }
        }
Beispiel #2
0
        bool DoPathFind()
        {
            Dynamic targetObj = null;

            {
                //not true because use Intellect
                RTSUnitAI ai = Intellect as RTSUnitAI;
                if (ai != null)
                {
                    targetObj = ai.CurrentTask.Entity;
                }
            }

            GridPathFindSystem.Instance.RemoveObjectFromMotionMap(this);

            Bounds bounds = PhysicsModel.GetGlobalBounds();

            float radius     = Type.Radius;
            Rect  targetRect = new Rect(MovePosition.ToVec2() - new Vec2(radius, radius),
                                        MovePosition.ToVec2() + new Vec2(radius, radius));

            if (targetObj != null && targetObj != this)
            {
                GridPathFindSystem.Instance.RemoveObjectFromMotionMap(targetObj);
            }

            GridPathFindSystem.Instance.DoTempClearMotionMap(targetRect);

            const int maxFieldsDistance = 1000;
            const int maxFieldsToCheck  = 100000;

            bool found = GridPathFindSystem.Instance.DoFind(Type.Radius * 2 * 1.1f, Position.ToVec2(),
                                                            MovePosition.ToVec2(), maxFieldsDistance, maxFieldsToCheck, true, false, path);

            GridPathFindSystem.Instance.RestoreAllTempClearedMotionMap();

            if (targetObj != null && targetObj != this)
            {
                GridPathFindSystem.Instance.AddObjectToMotionMap(targetObj);
            }

            GridPathFindSystem.Instance.AddObjectToMotionMap(this);

            return(found);
        }
Beispiel #3
0
 bool IsEnableTaskTypeInTasks( List<RTSUnitAI.UserControlPanelTask> tasks, RTSUnitAI.Task.Types taskType )
 {
     if( tasks == null )
         return false;
     foreach( RTSUnitAI.UserControlPanelTask task in tasks )
         if( task.Task.Type == taskType && task.Enable )
             return true;
     return false;
 }