void DoPlacePheromoneInteraction(Vector3 cursorPosition) { // If the shift key is not hold, perform standard pheromone placement. if (!Input.GetButton("Fire3")) { // If possible, place / erase a pheromone if (placementTimer >= pheromonePlacementSpeed && Input.GetButton("Fire1")) { if (pheromoneType != EPheromoneTypes.ErasePheromone) { _pheromoneManager.PlacePheromone(cursorPosition, pheromoneType); // Log placed pheromone in statistics manager. _statisticsManager.pheromonesPlaced[pheromoneType] += 1; } else { _pheromoneManager.ErasePheromone(cursorPosition); } placementTimer = 0.0f; } } // Else: the shift key is hold, so perform task assignment. else { if (Input.GetButton("Fire1")) { AssignTask(cursorPosition); } } }
/** * When enabled, deposit a pheromone of type _type. The rate is defined in the * GlobalAgentconfiguration object. */ void Update() { placementTimer += Time.deltaTime; if (placementTimer >= _agentConfiguration.pheromonePlacementRate) { Vector3 pheromonePosition = new Vector3(transform.position.x, 0, transform.position.z); pheromonePosition = pheromonePosition - transform.forward; _pheromoneManager.PlacePheromone(pheromonePosition, _type); placementTimer = 0.0f; } }