private void Update()
 {
     if (isSeekMode)
     {
         seekTimer -= Time.deltaTime;
         if (seekTimer <= 0f)
         {
             seekTarget.position = cellGrid.GetRandomCell(0).transform.position + new Vector3(0f, 0.5f, 0f);
             seekTimer           = timeTillSeekTargetChange;
         }
     }
     else if (isFleeMode)
     {
         fleeTimer -= Time.deltaTime;
         if (fleeTimer <= 0f)
         {
             fleeTarget.position = GetRandomLocation(1f, 23f, 1f, 23f);
             fleeTimer           = timeTillFleeTargetChange;
         }
     }
     else if (isPursuitMode)
     {
         pursuitTimer -= Time.deltaTime;
         if (pursuitTimer <= 0f)
         {
             AssignPursuitTarget();
             pursuitTimer = timeTillPursuitTargetChange;
         }
     }
     else if (isArrivalAndAvoidanceMode)
     {
         arrivalTimer -= Time.deltaTime;
         if (arrivalTimer < 0f)
         {
             AssignArrivalTarget();
             arrivalTimer = timeTillArrivalTargetChange;
         }
     }
     else if (isLeaderFollowingMode)
     {
         leaderSeekTimer -= Time.deltaTime;
         if (leaderSeekTimer < 0f)
         {
             leader.targetTransform    = leaderSeekTarget;
             leaderSeekTarget.position = cellGrid.GetRandomCell(0).transform.position + new Vector3(0f, 0.5f, 0f);
             leaderSeekTimer           = timeTillLeaderSeekTargetChange;
         }
     }
 }
    private void PlaceFoodOnRandomCell(Food food)
    {
        bool isLocationValid = false;

        while (!isLocationValid)
        {
            Cell possibleCell = cellGrid.GetRandomCell(0);
            if (possibleCell.Feature == null)
            {
                isLocationValid = true;
                food.PlaceOnGrid(possibleCell);
            }
            else
            {
                Debug.Log("Cannot place plant on existing feature");
            }
        }
    }
Exemplo n.º 3
0
    public void CreateAgents(int numAgents)
    {
        bool isAbleToPlace;

        for (int i = 0; i < numAgents; i++)
        {
            Agent newAgent = pooledAgents.GetPoolObject();

            isAbleToPlace = false;
            while (isAbleToPlace == false)
            {
                isAbleToPlace = newAgent.PlaceOnGrid(cellGrid.GetRandomCell(0));
            }

            agents.Add(newAgent);
        }

        agentCountText.text = agents.Count.ToString();
    }