예제 #1
0
 void removeCargoToSpawnIfAreaIsFull()
 {
     foreach (GameObject CargoArea in CargoAreas)
     {
         GoalAreaController CargoTruck = CargoArea.GetComponent <GoalAreaController>();
         if (CargoTruck.isFull)
         {
             foreach (GameObject Cargo in CargoToSpawn.ToList())
             {
                 if (Cargo.gameObject.name == CargoTruck.CargoTag)
                 {
                     CargoToSpawn.Remove(Cargo);
                 }
             }
         }
     }
 }
예제 #2
0
    public void ResetArea()
    {
        float unclampedRatio = (float)step / (float)stepSaturation;

        currentRatio = Mathf.Clamp(unclampedRatio, 0f, 1f);

        // Update decision requester
        agentPeriod = agent.updateDecionRequest(unclampedRatio);

        foreach (AgentSpawnArea agentSpawnArea in AgentSpawnAreas)
        {
            if (agentSpawnArea.isEasy)
            {
                agentSpawnArea.Probability =
                    agentSpawnArea.startProbability * (1 - currentRatio);
            }
            else
            {
                agentSpawnArea.Probability = agentSpawnArea.startProbability +
                                             (1 - agentSpawnArea.startProbability) * currentRatio;
            }
        }

        float          v       = Random.value;
        float          total_v = 0f;
        AgentSpawnArea chosenAgentSpawnArea = null;

        foreach (AgentSpawnArea agentSpawnArea in AgentSpawnAreas)
        {
            total_v += agentSpawnArea.Probability;
            if (v <= total_v)
            {
                chosenAgentSpawnArea = agentSpawnArea;
                break;
            }
        }

        foreach (GameObject wall in walls)
        {
            wall.SetActive(Random.value < currentRatio);
        }

        int randomSpawnPoint = Random.Range(0, chosenAgentSpawnArea.places.Count);

        agent.transform.position = chosenAgentSpawnArea.places[randomSpawnPoint].position;
        agent.transform.rotation = chosenAgentSpawnArea.places[randomSpawnPoint].rotation;
        if (!chosenAgentSpawnArea.isEasy)
        {
            agent.transform.Rotate(0f, Random.Range(-15 * currentRatio, 15 * currentRatio), 0f);
        }

        freeToLoad = true;
        foreach (GameObject GoalArea in GoalAreas)
        {
            GoalAreaController goalAreaController = GoalArea.GetComponent <GoalAreaController>();
            goalAreaController.resetArea();
        }
        foreach (GameObject CargoArea in CargoAreas)
        {
            CargoSpawnController cargoSpawnController = CargoArea.GetComponent <CargoSpawnController>();
            cargoSpawnController.resetArea();
        }
        spawnedCargoes.Clear();
    }