コード例 #1
0
 public override void TakeAction()
 {
     if (!ParentBrain.isMobile())
     {
         Pop();
     }
     else
     {
         GameObject gameObject = CellHasFriendly(ParentBrain.pPhysics.CurrentCell.GetCellFromDirection(Dir, true));
         if (gameObject != null && gameObject.HasPart("Brain"))
         {
             Brain part = gameObject.GetPart("Brain") as Brain;
             if (gameObject.IsPlayer() || part.Target != null && part.Target == ParentBrain.Target)
             {
                 return;
             }
         }
         if (CellHasHostile(ParentBrain.pPhysics.CurrentCell.GetCellFromDirection(Dir, true)))
         {
             Think("There's something in my way!");
             FailToParent();
         }
         else
         {
             MoveDirection(Dir);
             Pop();
         }
     }
 }
コード例 #2
0
        public override void TakeAction()
        {
            if (!ParentBrain.isMobile())
            {
                Pop();
                return;
            }
            if (Toward != null && !Toward.IsValid())
            {
                Toward = null;
                Think("I was trying to go toward someone, but they're gone!");
                FailToParent();
                return;
            }
            Cell cellFromDirection = ParentBrain.pPhysics.CurrentCell.GetCellFromDirection(Dir);

            if (cellFromDirection == null)
            {
                Think("I can't move there!");
                FailToParent();
                return;
            }
            if (wandering && cellFromDirection.HasObjectWithTagOrProperty("WanderStopper"))
            {
                Think("I shouldn't wander there!");
                FailToParent();
                return;
            }
            if (careful && cellFromDirection.NavigationWeight(base.ParentObject, bSmart: true) > 0)
            {
                Think("That's too dangerous!");
                FailToParent();
                return;
            }
            GameObject gameObject = CellHasFriendly(cellFromDirection);

            if (gameObject != null && gameObject.HasPart("Brain"))
            {
                Brain brain = gameObject.GetPart("Brain") as Brain;
                if (gameObject.IsPlayer() || (brain.Target != null && brain.Target == ParentBrain.Target))
                {
                    return;
                }
            }
            if (CellHasHostile(cellFromDirection))
            {
                Think("There's something in my way!");
                FailToParent();
            }
            else
            {
                MoveDirection(Dir);
                Pop();
            }
        }
コード例 #3
0
 public override void TakeAction()
 {
     // 1: Don't do anything if the object isn't mobile. (Can't move)
     // 2: Pop? if the ZoneID is NULL?
     // 3: Pop? if the destination Zone is NULL?
     if (!ParentBrain.isMobile())
     {
         FailToParent();
     }
     else if (ParentBrain.pPhysics.CurrentCell.ParentZone.ZoneID == null)
     {
         Pop();
     }
     else if (dZone == null)
     {
         Pop();
     }
     else
     {
         FindPath findPath = new FindPath(
             ParentBrain.pPhysics.CurrentCell.ParentZone.ZoneID,
             ParentBrain.pPhysics.CurrentCell.X,
             ParentBrain.pPhysics.CurrentCell.Y,
             dZone,
             dCx,
             dCy,
             ParentBrain.limitToAquatic(),
             false,
             ParentBrain.ParentObject);
         ParentBrain.ParentObject.UseEnergy(1000);
         if (findPath.bFound)
         {
             findPath.Directions.Reverse();
             int num = 0;
             if (MaxTurns > -1)
             {
                 Pop();
             }
             foreach (string direction in findPath.Directions)
             {
                 PushGoal((GoalHandler) new rr_PublicStep(direction));
                 ++num;
                 if (MaxTurns > -1 && num >= MaxTurns)
                 {
                     break;
                 }
             }
         }
         else
         {
             FailToParent();
         }
     }
 }
コード例 #4
0
        public override void TakeAction()
        {
            if (!ParentBrain.isMobile())
            {
                FailToParent();
                return;
            }
            if (ParentBrain.pPhysics.CurrentCell.ParentZone.ZoneID == null)
            {
                Pop();
                return;
            }
            if (dZone == null)
            {
                Pop();
                return;
            }
            Cell     currentCell = base.ParentObject.CurrentCell;
            FindPath findPath    = new FindPath(currentCell.ParentZone.ZoneID, currentCell.X, currentCell.Y, dZone, dCx, dCy, ParentBrain.limitToAquatic(), false, ParentBrain.ParentObject, careful);

            ParentBrain.ParentObject.UseEnergy(1000);
            if (findPath.bFound)
            {
                findPath.Directions.Reverse();
                int num = findPath.Directions.Count;
                if (oneShort)
                {
                    num--;
                }
                if (MaxTurns > -1)
                {
                    Pop();
                    if (num > MaxTurns)
                    {
                        num = MaxTurns;
                    }
                }
                for (int i = 0; i < num; i++)
                {
                    PushGoal(new acegiak_Step(findPath.Directions[i], careful, overridesCombat, wandering));
                }
            }
            else
            {
                FailToParent();
            }
        }
コード例 #5
0
        public override bool Finished()
        {
            if (!ParentBrain.isMobile())
            {
                return(true);
            }
            Cell currentCell = base.ParentObject.CurrentCell;

            if (currentCell != null)
            {
                if (currentCell.X == dCx && currentCell.Y == dCy)
                {
                    return(true);
                }
                if (oneShort && currentCell.DistanceTo(dCx, dCy) <= 1)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #6
0
        private bool CellHasHostile(Cell TargetCell)
        {
            if (TargetCell == null)
            {
                return(false);
            }
            bool flag = false;

            foreach (GameObject GO in TargetCell.GetObjectsWithPart("Combat"))
            {
                if ((GO.IsPlayer() || GO.Blueprint != ParentBrain.ParentObject.Blueprint) && (ParentBrain.IsHostileTowards(GO) && ParentBrain.ParentObject.SamePhaseAs(GO)))
                {
                    flag = true;
                }
            }
            return(flag);
        }
コード例 #7
0
 private GameObject CellHasFriendly(Cell TargetCell)
 {
     if (TargetCell == null)
     {
         return(null);
     }
     foreach (GameObject GO in TargetCell.GetObjectsWithPart("Combat"))
     {
         if (ParentBrain != null && GO != ParentBrain.Target)
         {
             bool flag = true;
             if ((GO.IsPlayer() || GO.Blueprint != ParentBrain.ParentObject.Blueprint) && !ParentBrain.IsHostileTowards(GO))
             {
                 flag = false;
             }
             if (flag)
             {
                 return(GO);
             }
         }
     }
     return(null);
 }
コード例 #8
0
        public override bool Finished()
        {
            Cell myCell = ParentBrain.pPhysics.CurrentCell;

            return(!ParentBrain.isMobile() || myCell.X == dCx && myCell.Y == dCy);
        }
コード例 #9
0
        private bool CellHasHostile(Cell TargetCell)
        {
            if (TargetCell == null)
            {
                return(false);
            }
            bool result = false;

            foreach (GameObject item in TargetCell.LoopObjectsWithPart("Combat"))
            {
                if ((item.IsPlayer() || item.Blueprint != ParentBrain.ParentObject.Blueprint) && ParentBrain.IsHostileTowards(item) && ParentBrain.ParentObject.PhaseAndFlightMatches(item))
                {
                    result = true;
                }
            }
            return(result);
        }
コード例 #10
0
        private GameObject CellHasFriendly(Cell TargetCell)
        {
            if (TargetCell == null)
            {
                return(null);
            }
            bool flag = false;

            foreach (GameObject item in TargetCell.LoopObjectsWithPart("Combat"))
            {
                if (ParentBrain != null && item != ParentBrain.Target)
                {
                    flag = true;
                    if ((item.IsPlayer() || item.Blueprint != ParentBrain.ParentObject.Blueprint) && !ParentBrain.IsHostileTowards(item))
                    {
                        flag = false;
                    }
                    if (flag)
                    {
                        return(item);
                    }
                }
            }
            return(null);
        }