/// <summary> /// Set stage of infection and update smiley's image /// </summary> public virtual void SetCondition(int condition) { _mycondition = condition; EndLevelControllerBase egc = LevelSettings.GetActiveEndLevelController(); // Update the stats switch (condition) { case EXPOSED: { egc.NotifyHumanExposed(); GetComponent <AbstractInfection>().Expose(); levelStats.aHumanGotExposed(); LevelSettings.GetActiveEndLevelController().infectionIsInitialized = true; break; } case INFECTIOUS: { levelStats.aHumanGotInfected(); break; } case DEAD: { // Removes this human's Rigidbody from the physics simulation, // which disables movement and collision detection. myRigidbody.simulated = false; // Set the simulated velocity to zero. myRigidbody.velocity = Vector3.zero; // Put this human's sprite on the 'Dead' sorting layer. // This layer is below the others, causing Dead humans to be rendered // below the living. GetComponent <SpriteRenderer>().sortingLayerName = "Dead"; egc.NotifyHumanRemoved(); levelStats.aHumanDied(myID); break; } case RECOVERED: { egc.NotifyHumanRemoved(); levelStats.aHumanRecovered(); break; } } // we want all the smileys to stay the same except for the player if (LevelSettings.GetActiveLevelSettings().ShowInfectionStatus == true || this.tag == "Player") { // Update the sprite image UpdateSpriteImage(); } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Player") { // The player is here. We check how many masks he has and // give this option to the end level controller. // The controller then decides to end the level or not. Debug.Log("Player entered hospital."); // Get number of masks from player int numberOfMasks = other.GetComponent <Player>().getNumMasks(); // Get end level controller and notify him about the number of masks EndLevelControllerBase elc = LevelSettings.GetActiveEndLevelController(); elc.NotifyInt(numberOfMasks); } }
private void Start() { // activate end level controller endlevel = LevelSettings.GetActiveEndLevelController(); // Get player (this may return null if the player is inactive) player = GameObject.FindGameObjectWithTag("Player"); // Get player renderer playerRend = PlayerInside.GetComponent <SpriteRenderer>(); // Per default, we do not show the player in the window UnshowPlayer(); // Initialize the player spawn position playerAppearPosition = gameObject.transform.position + new Vector3(0, -0.5f, 0); // The player is allowed to exit the house if he starts in it // or if he can enter and exit at will. // If he starts in the house and is not allowed to enter and exit at will, // then we will set playerCanExit to false as soon as he left the house for the first time. playerCanExit = EnterAndExitAtWill || playerStartsInside; // Set this point in time as the last execution time of update. // This means, update is first performed at time Time.time + timeBetweenUpdates lastTime = Time.time; }