Beispiel #1
0
    /// <summary>
    /// Ends in-game day
    /// </summary>
    public void EndDay()
    {
        // determines whether game has met room-related end-day conditions
        if (roomManager.CanEndDay() == false)
        {
            // break from end-day process
            return;
        }

        // decrement number of days left and lose game if final day ends
        --daysRemaining;
        if (daysRemaining < 0 && murdererAtLarge)
        {
            // TODO: refactor notif pop-up to work with separate managers
            //if (notifPopUp.text == "")
            //{
            //    // prints murderer escaped fail state message
            //    notifPopUp.text = "Murderer escaped. Game Over.";
            //    continueButton.gameObject.SetActive(true);
            //}
            // Note: placeholder for first iteration
            Debug.Log("Murderer escaped. Game Over.");
        }

        // if execution chamber is occupied
        if (roomManager.ExecutionRoom.IsOccupied)
        {
            // destroy occupant
            characterExecuted = roomManager.ExecutionRoom.ExecuteOccupant();

            // Remove killer from list of murderers if applicable
            // and return appropriate feedback to player
            // Note: debug logs are placeholders for first iteration
            if (!characterExecuted.CompareTag("murderer"))
            {
                // TODO: refactor notif pop-up to work with separate managers
                //if (notifPopUp.text == "")
                //{
                //    // prints innocent killed fail state message
                //    notifPopUp.text = "Innocent killed. Game Over.";
                //    continueButton.gameObject.SetActive(true);
                //}
                Debug.Log("Innocent killed. Game Over.");
            }
            else
            {
                // remove killer from list of murderers
                murderers.Remove(characterExecuted);

                // if player has found all killers, tell them they've won
                if (murderers.Count < 1)
                {
                    // TODO: refactor notif pop-up to work with separate managers
                    //if (notifPopUp.text == "")
                    //{
                    //    // prints killers found victory condition message
                    //    notifPopUp.text = "All killers found. You win!";
                    //    continueButton.gameObject.SetActive(true);
                    //}
                    Debug.Log("All killers found. You win!");
                    murdererAtLarge = false;

                    // break from end day process
                    return;
                }
                // otherwise (i.e., killers remain to be found)
                else
                {
                    // TODO: refactor notif pop-up to work with separate managers
                    //if (notifPopUp.text == "")
                    //{
                    //    // displays number of murderers left
                    //    if (murderers.Count > 1)
                    //    {
                    //        notifPopUp.text = "Murderer caught. " + murderers.Count + " killers remain.";
                    //        continueButton.gameObject.SetActive(true);
                    //    }
                    //    else if (murderers.Count == 1)
                    //    {
                    //        notifPopUp.text = "Murderer caught. " + murderers.Count + " killer remains.";
                    //        continueButton.gameObject.SetActive(true);
                    //    }
                    //}
                    Debug.Log("Murderer caught. " + murderers.Count + " killers remain.");
                }
            }
        }

        // Note: win / lose conditions haven't been met

        // finally, arm any unarmed killers in game
        foreach (GameObject killer in murderers)
        {
            Murderer killerComp = killer.GetComponent <Murderer>();

            // if killer isn't armed
            if (!killerComp.IsArmed)
            {
                // arm killer and set them to be inactive for night
                killerComp.Arm();
                killerComp.IsActive = false;
            }
            // otherwise (killer currently holds weapon)
            else
            {
                // set killer to be active tonight (i.e., can determine to strike tonight)
                killerComp.IsActive = true;
            }
        }

        // pass killer-to-strike on to next killer in list
        killerToStrike++;
        if (killerToStrike >= murderers.Count)
        {
            killerToStrike = 0;
        }

        // finally, if killer to strike tonight is active
        // they determine to kill a roommate
        if (murderers[killerToStrike].GetComponent <Murderer>().IsActive)
        {
            murderers[killerToStrike].GetComponent <Murderer>().DetermineToKill();
        }
    }