void BuildGoalArea(int teamIndex, int i, int j) { GameObject newGoalAreaObj = InstantiateAtPosition(goalArea, i, j); GoalArea newGoalArea = newGoalAreaObj.GetComponent <GoalArea>(); SpriteRenderer goalAreaRenderer = newGoalAreaObj.GetComponent <SpriteRenderer>(); newGoalArea.teamIndex = teamIndex; if (teamIndex == 0) { goalAreaRenderer.color = new Color(1, 0, 0); } else { goalAreaRenderer.color = new Color(0, 1, 0); } }
// Use this for initialization void Awake() { if (Instance == null) { Instance = this; } else { Destroy(this.gameObject); } GameData = GetComponent <GameData>(); PlayerManager = GetComponent <PlayerManager>(); GoalArea = Instantiate(GameData.GoalAreaPrefab).GetComponent <GoalArea>(); SpawnManager = GetComponent <SpawnManager>(); WardrobeManager = GetComponent <WardrobeManager>(); GameData.currentGameScore.Value = 0f; GameData.currentScoreMultiplier.Value = 0f; PauseGame(); }
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(); }