public override void Activate()
        {
            Status = Goal_Status.ACTIVE;
            RemoveAllSubGoals();

            foreach (var item in World.Instance.Entities)
                if (item.GetType() == targetType)
                {
                    target = item;
                    continue;
                }
            if (target != null)
                AddSubGoal(new SeekToPosition(Owner, target.Position));
        }
示例#2
0
        public override void Activate()
        {
            Status = Goal_Status.ACTIVE;
            RemoveAllSubGoals();

            foreach (var item in World.Instance.Entities)
            {
                if (item.GetType() == foodSource)
                {
                    foodEntity = item;
                    continue;
                }
            }

            if (foodEntity != null)
                AddSubGoal(new SeekToPosition(Owner, foodEntity.Position));
        }
示例#3
0
 private void FindNearestWatersource()
 {
     waterEntity = null;
     double nearestTree = double.MaxValue;
     foreach (var item in World.Instance.Entities)
     {
         if (item.GetType() == typeof(WaterEntity))
         {
             var distance = (Math.Pow(Owner.Position.x - item.Position.x, 2) + Math.Pow(Owner.Position.y - item.Position.y, 2));
             if (distance < nearestTree)
             {
                 nearestTree = distance;
                 waterEntity = (WaterEntity)item;
             }
         }
     }
     if (waterEntity != null)
         AddSubGoal(new Seek(Owner, waterEntity.Position));
 }
示例#4
0
        public override void Activate()
        {
            Status = Goal_Status.ACTIVE;
            RemoveAllSubGoals();

            foreach (var item in World.Instance.Entities)
            {
                if (item.GetType() == waterSource)
                {
                    waterEntity = item;
                    continue;
                }
            }

            if (waterEntity != null)
                AddSubGoal(new SeekToPosition(Owner, waterEntity.Position));
            if (subGoals.Count == 0)
                Terminate();
        }
示例#5
0
        public override Goal_Status Process()
        {
            ActivateIfInactive();
            if (subGoals.Count == 0 || subGoals.Last().isComplete())
            {
                if (Owner.Carnivore)
                {
                    MovingEntity nearbyEntity = GetNearbyEntity();
                    if (nearbyEntity == null)
                        FindNearestWatersource();
                    else
                    {
                        FinalFoodEntity = nearbyEntity;
                        FinalFoodFoundGoal = new Seek(Owner, nearbyEntity.Position);
                        AddSubGoal(FinalFoodFoundGoal);
                    }
                }
                else
                {
                    TreeEntity nearbyTree = FindNeartestTree();
                    if (nearbyTree == null)
                        FindNearestWatersource();
                    else
                    {
                        FinalFoodEntity = nearbyTree;
                        FinalFoodFoundGoal = new Seek(Owner, nearbyTree.Position);
                        AddSubGoal(FinalFoodFoundGoal);
                    }
                }
            }
            else if (subGoals.Count > 0)
            {
                if (Owner.Carnivore)
                {
                    MovingEntity nearbyEntity = GetNearbyEntity();
                    if (nearbyEntity != null)
                    {
                        FinalFoodEntity = nearbyEntity;
                        FinalFoodFoundGoal = new Seek(Owner, nearbyEntity.Position);
                        AddSubGoal(FinalFoodFoundGoal);
                    }
                }
                else
                {
                    TreeEntity nearbyTree = FindNeartestTree();
                    if (nearbyTree != null)
                    {
                        FinalFoodEntity = nearbyTree;
                        FinalFoodFoundGoal = new Seek(Owner, nearbyTree.Position);
                        AddSubGoal(FinalFoodFoundGoal);
                    }
                }
            }
            else
            {
                FindNearestWatersource();
            }

            if(FinalFoodFoundGoal != null)
            {
                if (!Owner.Carnivore)
                {
                    var hungerDesire = FuzzyImplementation.Instance.GetDesirabilityHungerAndHealth((int)Owner.Hunger, (int)Owner.Health);
                    if (hungerDesire < 50)
                        Terminate();
                }

                double distance = (Math.Pow(Owner.Position.y - FinalFoodEntity.Position.y, 2) + Math.Pow(Owner.Position.y - FinalFoodEntity.Position.y, 2));

                if (distance < base.Owner.ViewDistance || FinalFoodFoundGoal.isComplete())
                    Terminate();
            }

            return ProcessSubgoals();
        }
示例#6
0
 public void AddDeadEntity(BaseEntity be)
 {
     this.deadEntities.Add(be);
 }