예제 #1
0
파일: Ant.cs 프로젝트: brandonphelps/Cally
        private Job assignJob()
        {
            Job temp = new Job();
            int food_ants = 0;
            int water_ants = 0;
            int stick_ants = 0;
            int idle_ants = 0;

            foreach(Ant bob in anthill.antz)
            {
                if(bob.getJob().getName() == "Idle")
                {
                    idle_ants++;
                }
                else if(bob.getJob().getName() == "Food")
                {
                    food_ants++;
                }
                else if(bob.getJob().getName() == "Water")
                {
                    water_ants++;
                }
                else if(bob.getJob().getName() == "Sticks")
                {
                    stick_ants++;
                }
            }

            if(food_ants < anthill.getNumFoodAnts())
            {
                temp = new Job("Food");
            }

            return temp;
        }
예제 #2
0
파일: Ant.cs 프로젝트: brandonphelps/Cally
 public void run()
 {
     if(current_job.getName() == "Idle")
     {
         current_job = assignJob();
     }
     doJob();
 }
예제 #3
0
파일: Ant.cs 프로젝트: brandonphelps/Cally
        public Ant(int x, int y, AntHill a)
            : base(x,y, "Ant")
        {
            hasFood = false;
            status = "";
            anthill = a;
            ant_id = init_id++;
            nearestFood = null;

            hasObjects = false;

            current_job = new Job();
        }
예제 #4
0
파일: Ant.cs 프로젝트: brandonphelps/Cally
 private void doJob()
 {
     if(current_job.getName() == "Food")
     {
         if(hasFood)
         {
             moveTo(anthill.getX(), anthill.getY());
             status = "Moving to anthill";
             if(atLoc(anthill.getX(), anthill.getY()))
             {
                 hasFood = false;
                 anthill.incFood(food_capacity);
                 current_job = new Job();
                 status = "";
             }
         }
         else
         {
             findnearestfood();
             status = "Moving to nearest food";
             nearestFood = findnearestfood();
             moveTo(nearestFood.getX(), nearestFood.getY());
         }
         if(atLoc(nearestFood.getX(), nearestFood.getY()) && !hasFood)
         {
             gatherFood();
         }
     }
 }