Esempio n. 1
0
        protected override EventResult OnStage(EventStage currentStage)
        {
            switch (currentStage)
            {
            case EventStage.START:
                EventState.currentEventText    = "Your landlord enters the shop.";
                EventState.currentEventOptions = EventState.CONTINUE_OPTION;
                mCurrentOptionOutcomes         = new EventStage[] { EventStage.S1 };
                break;

            case EventStage.S1:
                EventState.currentEventText    = "\"Sorry, but I can't let you stay for free again. You have to leave.\"";
                EventState.currentEventOptions = EventState.CONTINUE_OPTION;
                mCurrentOptionOutcomes         = new EventStage[] { EventStage.S2 };
                break;

            case EventStage.S2:
                EventState.currentEventText    = "You don't have enough money to pay the rent this season. The dream is dead.";
                EventState.currentEventOptions = EventState.currentEventOptions = new string[] { "Aww :(" };
                mCurrentOptionOutcomes         = new EventStage[] { EventStage.ACCEPT };
                break;

            case EventStage.ACCEPT:
                MainGameSystem.GameOver();
                return(EventResult.DONE);
            }

            return(EventResult.CONTINUE);
        }
    protected override EventResult OnStage(EventStage currentStage)
    {
        switch (currentStage)
        {
        case EventStage.START:
            EventState.currentEventText    = "The family peacock has died! The business can't go on without it.";
            EventState.currentEventOptions = new string[] { "Nooo! :(" };
            mCurrentOptionOutcomes         = new EventStage[] { EventStage.ACCEPT };
            return(EventResult.CONTINUE);

        case EventStage.ACCEPT:
            MainGameSystem.GameOver();
            return(EventResult.DONE);
        }

        return(EventResult.DONE);
    }
    protected override EventResult OnStage(EventStage currentStage)
    {
        switch (currentStage)
        {
        case EventStage.START:
            EventState.currentEventText    = "You worked the potion shop for a long time now. It's time to retire.";
            EventState.currentEventOptions = EventState.CONTINUE_OPTION;
            mCurrentOptionOutcomes         = new EventStage[] { EventStage.ACCEPT };
            return(EventResult.CONTINUE);

        case EventStage.ACCEPT:
            MainGameSystem.GameOver();
            return(EventResult.DONE);
        }

        return(EventResult.DONE);
    }
Esempio n. 4
0
 private void HPChange()
 {
     if (preHp != hp)
     {
         invincible = true;
         if (hp == 0 && system.gameOver == false && system != null)
         {
             system.GameOver(GetComponent <PlayerInput>().playerNum);
         }
         preHp = hp;
     }
     if (invincible)
     {
         if (invincibleCount >= invincibleTime)
         {
             invincibleCount = 0;
             invincible      = false;
         }
         else
         {
             invincibleCount += Time.deltaTime;
         }
     }
 }
    // Update is called once per frame
    void Update()
    {
        if (EventState.currentEvent != null)
        {
            return;                                 // no updating while an event is happening
        }
        if (GameData.singleton.currentStage == GameStage.GS_SIMULATION)
        {
            if (GameData.singleton.totalQuarterlyCustomers <= 0) // no more customers to handle
            {
                if (!EventState.hasMoreEventsRightNow && GameData.singleton.quarterTimeElapsed >= QuarterTotalTime)
                {
                    // transition to "end of quarter" stage
                    Debug.Log("All customers served this quarter.");
                    GameStageExtensions.GameLoopGotoNextStage();
                }
            }
            else
            {
                // yeah like it's slightly gross to do this here in this way...
                // running code on state changes really does want an event-driven style thing, I guess
                if (mPaymentTime == 0)
                {
                    mPaymentTime  = QuarterTotalTime / GameData.singleton.totalQuarterlyCustomers;
                    mPaymentTimer = mPaymentTime;
                }

                mPaymentTimer -= Time.deltaTime;
                if (mPaymentTimer <= 0)
                {
                    int product = Random.Range(0, (int)PotionType.PT_MAX);
                    while (GameData.singleton.quarterlyCustomers[product] == 0)
                    {
                        product = (product + 1) % (int)PotionType.PT_MAX;
                    }

                    if (GameData.singleton.potionsOwned[product] > 0)
                    {
                        SellProduct(product);
                    }
                    else
                    {
                        GameData.singleton.unfulfilledDemand[product] += 1;
                        Debug.Log("A customer wanted " + (PotionType)product + " but we were out of stock");

                        // get enough of this, and we queue up an event where a customer asks for this type specifically
                        if (GameData.singleton.unfulfilledDemand[product] > 3 && GameData.singleton.outOfStockEventCooldown <= GameData.singleton.quarter)
                        {
                            EventState.PushEvent(new OutOfStockEvent((PotionType)product), GameData.singleton.quarter);
                            GameData.singleton.outOfStockEventCooldown = GameData.singleton.quarter + 2;
                        }
                    }

                    mPaymentTimer = Random.Range(mPaymentTime * 0.9f, mPaymentTime * 1.1f);
                    GameData.singleton.quarterlyCustomers[product] -= 1;
                    --GameData.singleton.totalQuarterlyCustomers;
                }
            }
        }
        else if (GameData.singleton.currentStage == GameStage.GS_END_OF_QUARTER)
        {
            if (GameData.singleton.money < GameData.singleton.rent && !GameData.singleton.missedRent)
            {
                if (GameData.singleton.lastMissedRentQuarter == -1)
                {
                    EventState.PushEvent(new MissedRentEvents.MissedRentEvent(), GameData.singleton.quarter, 0, GameStage.GS_END_OF_QUARTER); // going to miss rent? add event
                    GameData.singleton.lastMissedRentQuarter = GameData.singleton.quarter;
                }
                else if (GameData.singleton.lastMissedRentQuarter == GameData.singleton.quarter - 1)
                {
                    EventState.PushEvent(new MissedRentEvents.MissedRentAgainEvent(), GameData.singleton.quarter, 0, GameStage.GS_END_OF_QUARTER); // game over
                    GameData.singleton.missedRent = true;
                }
                else
                {
                    Debug.LogError("Missed rent in quarter " + GameData.singleton.lastMissedRentQuarter + " but it's now " + GameData.singleton.quarter + ", and somehow it wasn't cleared?");
                }
            }
            else if (GameData.singleton.lastMissedRentQuarter < GameData.singleton.quarter)
            {
                GameData.singleton.lastMissedRentQuarter = -1;
            }

            if (GameData.singleton.peacockHealth <= 0 && !GameData.singleton.peacockDied)
            {
                EventState.PushEvent(new PeacockSickEvent(), GameData.singleton.quarter, 0, GameStage.GS_END_OF_QUARTER);
                GameData.singleton.peacockDied = true;
            }

            if (GameData.singleton.quarter >= 16 && !GameData.singleton.reachedEndOfLife && !GameData.singleton.missedRent && !GameData.singleton.peacockDied)
            {
                EventState.PushEvent(new EndOfLifeEvent(), GameData.singleton.quarter, 0);
                GameData.singleton.reachedEndOfLife = true;
            }

            if (!EventState.hasMoreEventsRightNow) // ensure we play through all events before advancing to next quarter
            {
                mPaymentTime = 0;

                // Advance to the next quarter and update any other affected state
                // Go tho the end-of-quarter summary state (or game over state)
                if (GameData.singleton.reachedEndOfLife)
                {
                    MainGameSystem.GameOver();
                }
                else
                {
                    // This will advance to the summaries after the end of the quarter
                    GameStageExtensions.GameLoopGotoNextStage();
                }
                Debug.Log("game stage is now " + GameData.singleton.currentStage);
            }
        }
    }