示例#1
0
    private void StartDay(bool firstDayAfterTutorial = false)
    {
        _watch.Begin(_availableTimePerDayInSeconds);
        MoneyAtStartOfDay = Money;

        Npc npc;

        if (firstDayAfterTutorial)
        {
            // Always spawn a npc that wants the tutorial item
            var tutorialItemData = _tutorialController.ItemAddedByTutorial;
            var maxOfferAmount   = (int)(tutorialItemData.worth * Random.Range(1.6f, 2f));

            npc = NpcSpawner.Instance.Spawn(new NpcModel {
                NpcType                   = Npc.Type.Buying,
                Item                      = tutorialItemData.type,
                AmountOfOffers            = maxOfferAmount > tutorialItemData.worth * 1.6f ? 6 : Random.Range(2, 5),
                AmountThresholdForLeaving = (int)(tutorialItemData.worth * 2f),
                InitialOfferAmount        = (int)(maxOfferAmount * Random.Range(.8f, .9f)),
                MaxOfferAmount            = maxOfferAmount
            }, false);

            Debug.LogFormat("Tutorial npc:\nWilling to go for: {0}\nInitial offer: {1}\nLeaves at: {2}\nMax increment: {3}", npc.Model.MaxOfferAmount, npc.Model.InitialOfferAmount, npc.Model.AmountThresholdForLeaving, npc.Model.MaxOfferIncrement);
        }
        else
        {
            npc = SpawnNpc();
        }

        DOTween.Sequence()
        .SetDelay(TodaysSpecialItemType.HasValue ? 5f : .85f)
        .OnComplete(() => { npc.Activate(); });

        if (TodaysSpecialItemType.HasValue)
        {
            var todaysSpecialItemDisplayName = ItemFactory.Instance.GetDataFor(TodaysSpecialItemType.Value).displayName;
            var specialItemAnnouncements     = new string[] {
                string.Format("I heard a lot of people are wanting {0} today.", todaysSpecialItemDisplayName),
                string.Format("Purrr, {0} is really scarce. They will probably sell for a lot more today.", todaysSpecialItemDisplayName),
                string.Format("Wow, {0} is totally a hot item today!", todaysSpecialItemDisplayName),
                string.Format("Everyone wants a {0} today!", todaysSpecialItemDisplayName),
            };
            HintController.Instance.ShowHint(specialItemAnnouncements[Random.Range(0, specialItemAnnouncements.Length)]);
        }
    }