예제 #1
0
    private void GenerateNewWish()
    {
        GuestWish.GuestWishType wishType = GuestWish.GuestWishType.Random;
        var wish = new GuestWish(wishType, WaitingTimePerWish);

        AllWishes.Add(wish);
        wish.ActivateWish();

        // Display a request quip

        string quipText = "";

        if (wish.IsDrinkWish || wish.IsFoodWish)
        {
            Consumable.Quips quip = null;
            foreach (var consumable in Database.e.consumables)
            {
                if (consumable.wishType == wish.Type)
                {
                    quip = consumable.quips;
                    break;
                }
            }

            if (quip != null)
            {
                quipText = quip.request[Random.Range(0, quip.request.Length)];
            }
        }
        else
        {
            WishQuip quip = GuestManager.I.GetWishQuip(wish.Type);
            if (quip != null)
            {
                quipText = quip.GetRequest();
            }
        }

        if (quipText != "")
        {
            CanvasController.I.ShowNotification(this, quipText);
        }
    }
예제 #2
0
    public void FinishActiveWish(bool success = true, string message = "", GuestWish wish = null)
    {
        var activeWish = wish ?? CurrentWish;

        //if (activeWish == null
        //  || !(CurrentState == GuestState.WaitingForService || CurrentState == GuestState.WaitingForZito))
        //return;

        Debug.Log(sittingIndex + " Finished active wish, start delay");
        Debug.Assert(activeWish != null, "Active wish is null");
        activeWish.FinishWish(success);

        if (CurrentState == GuestState.WaitingForService)
        {
            Delay(DelayAfterWish);
        }

        if (!string.IsNullOrEmpty(message))
        {
            CanvasController.I.ShowNotification(this, message);
        }
    }
예제 #3
0
    void Window(int id)
    {
        if (GUILayout.Button("Spawn Guest"))
        {
            GenerateNewGuest();
        }
        if (GUILayout.Button("Spawn Marina"))
        {
            GenerateNewGuest(GetMarina());
        }

        autoSpawnGuests = GUILayout.Toggle(autoSpawnGuests, "Auto Spawn Guests");
        GUI.enabled     = false;
        slavaHasStarted = GUILayout.Toggle(slavaHasStarted, "Slava started");
        GUI.enabled     = true;
        if (GUILayout.Button("Spawn Fleka"))
        {
            var player = GameObject.Find("Player 1");
            Database.e.CreateFleka(player.transform.position);
        }
        if (GUILayout.Button("Extinguish Candle"))
        {
            Candle.e.Extinguish();
        }

        if (GUILayout.Button("Set test level"))
        {
            GameController.I.LoadLevel("TestLevel");
        }

        if (GUILayout.Button("FAJRONT"))
        {
            AllGuestsLeave();
        }

        if (GUILayout.Button("End Slava"))
        {
            EndSlava();
        }

        if (GUILayout.Button("End game NOW"))
        {
            GameController.I.EndGame();
        }

        GUILayout.Label("Loaded level: " + GameController.I.Level.name);
        GUILayout.Label("Time left: " + Candle.e.TimeLeft.ToString("F1"));

        var guests = FindObjectsOfType <Guest>();

        foreach (var guest in guests)
        {
            GUILayout.Label($"Guest: {guest.name}");
            for (int w = 0; w < guest.AllWishes.Count; w++)
            {
                GuestWish wish    = guest.AllWishes[w];
                string    success = wish.IsSuccess.HasValue ? wish.IsSuccess.Value ? "Success" : "Failure" : "Active";
                GUILayout.Label($"      W{w}: {guest.AllWishes[w].Type}, {success}");
            }
        }

        GUILayout.Label($"All completed wishes");

        for (int w = 0; w < allCompletedWishes.Count; w++)
        {
            GuestWish wish    = allCompletedWishes[w];
            string    success = wish.IsSuccess.HasValue ? wish.IsSuccess.Value ? "Success" : "Failure" : "Active";
            GUILayout.Label($"      W{w}: {wish.Type}, {success}");
        }
    }
예제 #4
0
    private void Update()
    {
        if (!Application.isPlaying || GameController.I.IsPaused)
        {
            return;
        }

        // Follow guest

        if (followAI)
        {
            transform.position = AI.transform.position + Vector3.up;
        }

        if (!isMarina)
        {
            if (Promaja.IsActive)
            {
                if (Time.time - lastPromajaReaction > timeBetweenPromajaReactions)
                {
                    lastPromajaReaction         = Time.time;
                    timeBetweenPromajaReactions = Random.Range(5.0f, 10.0f);
                    if (Random.value > 0.5f) // not all guests should react
                    {
                        GuestManager.I.ShowPromajaQuip(this);
                    }
                }

                //lastPromajaReaction 1
            }

            if (Fleka.Prljavo)
            {
                if (Time.time - lastPrljavoReaction > timeBetweenPrljavoReactions)
                {
                    lastPrljavoReaction         = Time.time;
                    timeBetweenPrljavoReactions = Random.Range(5.0f, 10.0f);
                    if (Random.value > 0.5f)
                    {
                        GuestManager.I.ShowPrljavoQuip(this);
                    }
                }
            }
        }

        switch (CurrentState)
        {
        case GuestState.WaitingAtTheDoor:
            RingTillDoorIsOpen();
            DoMoveFlipping();

            if (Database.e.entranceDoor.IsOpen)
            {
                if (!isMarina)
                {
                    GuestManager.I.ShowEntryMessage(this);
                }
                CurrentState = GuestState.Entered;
            }
            break;

        case GuestState.Entered:
            DoMoveFlipping();

            if (isMarina)
            {
                AI.GoToSeat();
                CurrentState = GuestState.WalkingIn;
            }
            // Wait for the domacin to open the door
            else if (IsCloseTo(AI.zitoDestination.position, ZITO_RANGE))
            {
                CurrentState = GuestState.WaitingForZito;
                AI.Stop();
                consumer.EnablePlayerInteraction(true);

                if (entryWish == null)
                {
                    entryWish = new GuestWish(GuestWish.GuestWishType.Zito, 30f);
                    AllWishes.Insert(0, entryWish);
                    entryWish.ActivateWish();
                }
            }
            break;

        case GuestState.WalkingIn:
            DoMoveFlipping();

            if (IsCloseTo(seat.transform.position))
            {
                Sit();
                Delay(Random.Range(0f, 2f) * InitialDelay);
            }
            break;

        case GuestState.GoingOut:

            if (Vector3.Distance(transform.position, AI.exitDestination.position) < 1.5f)
            {
                CurrentState = GuestState.Exit;
            }
            return;

        case GuestState.Exit:
            if (!isFadeOut)
            {
                isFadeOut = true;
                Debug.Log(sittingIndex + " BYE!");
                StartCoroutine(DelayDestroy(1.2f));
            }
            break;

        case GuestState.Delay:
            // currently delayed after the wish
            timeForNewWish -= Time.deltaTime;
            if (timeForNewWish <= 0f)
            {
                Debug.Log(sittingIndex + " end delay, new wish");
                RequestingWish();
            }
            break;

        case GuestState.WaitingForZito:
        case GuestState.WaitingForService:
            var currentWish = CurrentWish;

            // update all wishes
            for (int i = 0; i < AllWishes.Count; i++)
            {
                AllWishes[i].UpdateWish(Time.deltaTime);
            }

            // check if there is no current wish
            if (currentWish == null)
            {
                // if wishes count is at max, leave
                if (AllWishes.Count == NumberOfWishes)
                {
                    GoHome();
                }
                else
                {
                    GenerateNewWish();
                }
            }
            else if (currentWish.IsFinished)
            {
                Debug.Log(sittingIndex + " Timeout active wish, start delay");

                bool wasWaitingForZito = CurrentState == GuestState.WaitingForZito;

                // Timeout
                if (currentWish.IsSuccess.Value == false)
                {
                    Debug.LogWarning($"Wish {currentWish.Type} has timed out!");

                    string quipText = "";
                    if (currentWish.IsWindowWish || currentWish.IsTvWish)
                    {
                        Debug.Log("Was window tv wish");

                        WishQuip quip = GuestManager.I.GetWishQuip(currentWish.Type);
                        Debug.Assert(quip != null, "Quip is null");
                        quipText = quip ? quip.GetToolate() : "";
                    }
                    else if (currentWish.IsFoodWish || currentWish.IsDrinkWish)
                    {
                        Debug.Log("Was drink food wish");

                        //var container = currentWish.IsDrinkWish ? consumer.drinkContainer : consumer.foodContainer;
                        Consumable.Quips q = null;
                        foreach (var consumable in Database.e.consumables)
                        {
                            if (consumable.wishType == currentWish.Type)
                            {
                                q = consumable.quips;
                                break;
                            }
                        }

                        //Consumable.Quips q = container.type.quips;
                        Debug.Assert(q != null, "Quip is null");
                        quipText = q.tooLate[Random.Range(0, q.tooLate.Length)];
                    }

                    Debug.Assert(currentWish != null, "Current wish is null before");
                    Debug.Assert(!string.IsNullOrEmpty(quipText), "No quip text");
                    FinishActiveWish(success: false, message: quipText, currentWish);
                    Delay(DelayAfterWish);
                }

                if (wasWaitingForZito)
                {
                    //if (entryWish.IsSuccess.HasValue) // && entryWish.IsSuccess.Value
                    //{
                    Debug.Log($"Waiting for zito completed with {entryWish.IsSuccess.Value}");

                    // go in
                    //AllWishes.RemoveAt(0);

                    /*
                     * if (!entryWish.IsSuccess.Value)
                     * {
                     *  //entryWish.FinishWish(false);
                     *  WishQuip quip = GuestManager.I.GetWishQuip(currentWish.Type);
                     *  string quipText = quip ? quip.GetSuccess() : "";
                     *
                     *  FinishActiveWish(message: quipText);
                     * }*/

                    AI.GoToSeat();
                    followAI = true;
                    consumer.EnablePlayerInteraction(false);
                    CurrentState = GuestState.WalkingIn;

                    if (hasDirtyShoes)
                    {
                        StartCoroutine(MakeFleka(Random.Range(1.2f, 3f)));
                    }
                    //}
                    //else
                    //{
                    // just rage-quit
                    //GoHome(false);
                    //}
                }

                //else
                //Delay(DelayAfterWish);
            }
            // if the current wish is not active, activate it
            else if (!currentWish.IsActive)
            {
                currentWish.ActivateWish();
            }
            else if (currentWish.IsTvWish)
            {
                var selectedChannel = TV.SelectedChannel;
                // correct channel is activated
                if (selectedChannel == currentWish.Type)
                {
                    // we have time set
                    if (timeForTvWish >= 0)
                    {
                        timeForTvWish -= Time.deltaTime;
                        if (timeForTvWish <= 0f)
                        {
                            WishQuip quip     = GuestManager.I.GetWishQuip(currentWish.Type);
                            string   quipText = quip ? quip.GetSuccess() : "";

                            FinishActiveWish(message: quipText);
                        }
                    }
                    else
                    {
                        // set the timer
                        timeForTvWish = 3f;
                    }
                }
                else
                {
                    timeForTvWish = -1f;
                }
            }
            else if (currentWish.IsWindowWish)
            {
                var isWindowOpen = Prozor.IsProzorOpen || Database.e.balkonDoor.IsOpen;
                // windows is as we like it
                if ((currentWish.Type == GuestWish.GuestWishType.OpenWindow && isWindowOpen) ||
                    (currentWish.Type == GuestWish.GuestWishType.CloseWindow && !isWindowOpen))
                {
                    // we have time set
                    if (timeForWindowWish >= 0)
                    {
                        timeForWindowWish -= Time.deltaTime;
                        if (timeForWindowWish <= 0f)
                        {
                            WishQuip quip     = GuestManager.I.GetWishQuip(currentWish.Type);
                            string   quipText = quip ? quip.GetSuccess() : "";

                            FinishActiveWish(message: quipText);
                        }
                    }
                    else
                    {
                        // set the timer
                        timeForWindowWish = 3f;
                    }
                }
                else
                {
                    timeForWindowWish = -1f;
                }
            }
            else if (currentWish.IsDrinkWish || currentWish.IsFoodWish)
            {
                var container = currentWish.IsDrinkWish ? consumer.drinkContainer : consumer.foodContainer;

                const float minimumAmount = 0.5f;

                bool correctConsumable  = currentWish.Type == container.type.wishType;
                bool correctTemperature = container.IsAtGoodTemperature();


                if (container.amount > minimumAmount)
                {
                    Consumable.Quips q = container.type.quips;

                    if (correctConsumable && correctTemperature)
                    {
                        FinishActiveWish(true, q.perfect[Random.Range(0, q.perfect.Length)]);
                    }
                    else if (correctConsumable)
                    {
                        FinishActiveWish(false, q.wrongTemperature[Random.Range(0, q.wrongTemperature.Length)]);
                    }
                    else
                    {
                        FinishActiveWish(false, q.wrongConsumable[Random.Range(0, q.wrongConsumable.Length)]);
                    }
                }
            }

            //Debug.Log($"Happening! {CurrentState}, {entryWish.IsFinished}");



            break;
        }
    }