Пример #1
0
void NexusGameType::idle_server(U32 deltaT)
{
    if(nexusShouldChange() && !isOvertime())
    {
        if(mNexusIsOpen)
            closeNexus(mNexusChangeAtTime);
        else
            openNexus(mNexusChangeAtTime);
    }
}
Пример #2
0
// Server only
void NexusGameType::closeNexus(S32 timeNexusClosed)
{
    if(isOvertime())     // Can't close Nexus during overtime
        return;

    mNexusIsOpen = false;
    mNexusChangeAtTime = getNextChangeTime(timeNexusClosed, mNexusClosedTime);

    // Fire an event
    EventManager::get()->fireEvent(EventManager::NexusClosedEvent);
}
Пример #3
0
// In Nexus, we'll add 20 seconds, and permanently open the Nexus
void NexusGameType::onOvertimeStarted()
{
    mEndingGamePlay += TWENTY_SECONDS;
    openNexus(0);

    // And release a text effect to notify players
    if(isClient())
    {
        // The 750 ms delay of the second TextEffect makes a nice two-tiered effect
        string msg = isOvertime() ? "MORE OVERTIME!" : "OVERTIME!";
        getGame()->emitTextEffect(msg, Colors::red, Point(0,0), false);
        getGame()->emitDelayedTextEffect(750,  "+20 SECONDS", Colors::red, Point(0,0), false);
        getGame()->emitDelayedTextEffect(1500, "NEXUS IS OPEN!", Colors::red, Point(0,0), false);

        // TODO: Need a SFX here
    }
}
Пример #4
0
// If render is false, will return height, but not actually draw
S32 NexusGameType::renderTimeLeftSpecial(S32 right, S32 bottom, bool render) const
{
   const S32 size = 20;
   const S32 gap = 4;

   if(render)
   {
      const Color &color = mNexusIsOpen ? Colors::NexusOpenColor : Colors::NexusClosedColor;

      if(isOvertime() || (mNexusIsOpen && mNexusOpenTime == 0))
         RenderUtils::drawStringfr_fixed(right, bottom, size, color, "Nexus open until end of game");

      else if(!mNexusIsOpen && mNexusClosedTime == 0)
         RenderUtils::drawStringfr_fixed(right, bottom, size, color, "Nexus never opens");

      else if(!mNexusIsOpen && !isTimeUnlimited() && getRemainingGameTimeInMs() <= getNexusTimeLeftMs())
         RenderUtils::drawStringfr_fixed(right, bottom, size, color, "Nexus closed until end of game");

      else if(!isGameOver())
      {
         static const U32 w0      = RenderUtils::getStringWidth(size, "0");
         static const U32 wCloses = RenderUtils::getStringWidth(size, "Nexus closes: ");
         static const U32 wOpens  = RenderUtils::getStringWidth(size, "Nexus opens: ");

         S32 timeLeft = getNexusTimeLeftMs();

         // Get the width of the minutes and 10 seconds digit(s), account for two leading 0s (00:45)
         const U32 minsRemaining = timeLeft / (60 * 1000);
         const U32 tenSecsRemaining = timeLeft / 1000 % 60 / 10;
         const string timestr = itos(minsRemaining) + ":" + itos(tenSecsRemaining);
         const U32 minsWidth = RenderUtils::getStringWidth(size, timestr.c_str()) + (minsRemaining < 10 ? w0 : 0);

         S32 w = minsWidth + w0 + (mNexusIsOpen ? wCloses : wOpens);

         RenderUtils::drawTime(right - w, bottom, size, color, timeLeft, mNexusIsOpen ? "Nexus closes: " : "Nexus opens: ");
      }
   }

   return size + gap;
}
Пример #5
0
void NexusGameType::idle_client(U32 deltaT)
{
#ifndef ZAP_DEDICATED
    if(!isOvertime())
    {
        if(!mNexusIsOpen && nexusShouldChange())         // Nexus has just opened
        {
            if(!isGameOver())
            {
                getGame()->displayMessage(Color(0.6f, 1, 0.8f), "The Nexus is now OPEN!");
                getGame()->playSoundEffect(SFXFlagSnatch);
            }

            mNexusIsOpen = true;
            mNexusChangeAtTime = getNextChangeTime(mNexusChangeAtTime, mNexusOpenTime);
        }

        else if(mNexusIsOpen && nexusShouldChange())       // Nexus has just closed
        {
            if(!isGameOver())
            {
                getGame()->displayMessage(Color(0.6f, 1, 0.8f), "The Nexus is now CLOSED!");
                getGame()->playSoundEffect(SFXFlagDrop);
            }

            mNexusIsOpen = false;
            mNexusChangeAtTime = getNextChangeTime(mNexusChangeAtTime, mNexusClosedTime);
        }
    }

    for(S32 i = 0; i < mYardSaleWaypoints.size();)
    {
        if(mYardSaleWaypoints[i].timeLeft.update(deltaT))
            mYardSaleWaypoints.erase_fast(i);
        else
            i++;
    }
#endif
}
Пример #6
0
bool NexusGameType::isNexusOpen() const
{
    return mNexusIsOpen || isOvertime();
}