Exemplo n.º 1
0
    public override IPlayerSlotController PrepareVideoPlayerSlotController(IPlayerManager playerManager, PlayerContextManager playerContextManager,
        PlayerContextConcurrencyMode concurrencyMode, out bool makePrimaryPlayer, out int audioPlayerSlotIndex, out int currentPlayerSlotIndex)
    {
        int numActive = playerContextManager.NumActivePlayerContexts;
        switch (concurrencyMode)
        {
          case PlayerContextConcurrencyMode.ConcurrentVideo:
            IList<IPlayerContext> playerContexts = playerContextManager.PlayerContexts;
            if (numActive >= 1 && playerContexts[PlayerContextIndex.PRIMARY].AVType == AVType.Video)
            { // The primary slot is a video player slot
              IPlayerSlotController result;
              if (numActive == 1)
              {
                result = playerManager.OpenSlot();
                makePrimaryPlayer = true;
              }
              else // numActive > 1
              {
                IPlayerContext pc = playerContexts[PlayerContextIndex.PRIMARY];
                result = pc.Revoke(); // Necessary to revoke the player context to disable the auto close function (pc.CloseWhenFinished)
                makePrimaryPlayer = true;
              }

              audioPlayerSlotIndex = PlayerContextIndex.PRIMARY;
              currentPlayerSlotIndex = PlayerContextIndex.PRIMARY;
              return result;
            }
            break;
        }
      // All other cases are handled the same as in the default player open strategy
      return base.PrepareVideoPlayerSlotController(playerManager, playerContextManager, concurrencyMode, out makePrimaryPlayer,
          out audioPlayerSlotIndex, out currentPlayerSlotIndex);
    }
Exemplo n.º 2
0
 private void FinishLevel()
 {
     levelFinished = true;
     PlayerContextManager.UpdateBestNumberOfMoves(CURRENT_LEVEL, currentLevelMoveCounter);
     gameInfoPanelController.setBestNumberOfMoves(PlayerContextManager.GetCurrentContext().GetBestNumberOfMovesForLevel(CURRENT_LEVEL));
     nextLevelButton.SetActive(true);
 }
Exemplo n.º 3
0
 private void PrepareNewLevel()
 {
     currentLevel = levelManager.LoadLevel(CURRENT_LEVEL);
     UpdateAllVerticesGameObjects();
     currentLevelMoveCounter = 0;
     gameInfoPanelController.setNumberOfMoves(0);
     gameInfoPanelController.setBestNumberOfMoves(PlayerContextManager.GetCurrentContext().GetBestNumberOfMovesForLevel(CURRENT_LEVEL));
     levelFinished = false;
 }
Exemplo n.º 4
0
 public virtual IPlayerSlotController PrepareAudioPlayerSlotController(IPlayerManager playerManager, PlayerContextManager playerContextManager,
     bool concurrentVideo, out int currentPlayerSlotIndex)
 {
   int numActive;
   if (concurrentVideo)
   {
     numActive = playerContextManager.NumActivePlayerContexts;
     // Solve conflicts - close conflicting slots
     IPlayerContext secondaryPC = playerContextManager.GetPlayerContext(PlayerContextIndex.SECONDARY);
     if (secondaryPC != null)
       secondaryPC.Close();
     IPlayerContext pcPrimary;
     if (numActive > 0 && (pcPrimary = playerContextManager.GetPlayerContext(PlayerContextIndex.PRIMARY)) != null && pcPrimary.AVType == AVType.Audio)
       pcPrimary.Close();
   }
   else // !concurrentVideo
     // Don't enable concurrent controllers: Close all except the primary slot controller
     playerContextManager.CloseAllPlayerContexts();
   numActive = playerContextManager.NumActivePlayerContexts;
   currentPlayerSlotIndex = numActive;
   return playerManager.OpenSlot();
 }
Exemplo n.º 5
0
 private void UpdateLevelButtonState(GameObject levelButton, int levelNumber)
 {
     if (PlayerContextManager.GetCurrentContext().ExistsBestNumberOfMovesForLevel(levelNumber))
     {
         int   playerBest    = PlayerContextManager.GetCurrentContext().GetBestNumberOfMovesForLevel(levelNumber);
         int[] moveThreshold = LevelManager.levelTemplates[levelNumber].GetMoves();
         if (playerBest <= moveThreshold[0])
         {
             MarkMedals(levelButton, 3);
         }
         else if (playerBest <= moveThreshold[1])
         {
             MarkMedals(levelButton, 2);
         }
         else
         {
             MarkMedals(levelButton, 1);
         }
     }
     else
     {
         MarkMedals(levelButton, 0);
         if (levelNumber > 0)
         {
             bool enableButton = PlayerContextManager.GetCurrentContext().ExistsBestNumberOfMovesForLevel(levelNumber - 1);
             if (enableButton)
             {
                 EnableButton(levelButton);
             }
             else
             {
                 DisableButton(levelButton);
             }
         }
     }
 }
Exemplo n.º 6
0
        public override IPlayerSlotController PrepareVideoPlayerSlotController(IPlayerManager playerManager, PlayerContextManager playerContextManager,
                                                                               PlayerContextConcurrencyMode concurrencyMode, out bool makePrimaryPlayer, out int audioPlayerSlotIndex, out int currentPlayerSlotIndex)
        {
            int numActive = playerContextManager.NumActivePlayerContexts;

            switch (concurrencyMode)
            {
            case PlayerContextConcurrencyMode.ConcurrentVideo:
                IList <IPlayerContext> playerContexts = playerContextManager.PlayerContexts;
                if (numActive >= 1 && playerContexts[PlayerContextIndex.PRIMARY].AVType == AVType.Video)
                { // The primary slot is a video player slot
                    IPlayerSlotController result;
                    if (numActive == 1)
                    {
                        result            = playerManager.OpenSlot();
                        makePrimaryPlayer = true;
                    }
                    else // numActive > 1
                    {
                        IPlayerContext pc = playerContexts[PlayerContextIndex.PRIMARY];
                        result            = pc.Revoke(); // Necessary to revoke the player context to disable the auto close function (pc.CloseWhenFinished)
                        makePrimaryPlayer = true;
                    }

                    audioPlayerSlotIndex   = PlayerContextIndex.PRIMARY;
                    currentPlayerSlotIndex = PlayerContextIndex.PRIMARY;
                    return(result);
                }
                break;
            }
            // All other cases are handled the same as in the default player open strategy
            return(base.PrepareVideoPlayerSlotController(playerManager, playerContextManager, concurrencyMode, out makePrimaryPlayer,
                                                         out audioPlayerSlotIndex, out currentPlayerSlotIndex));
        }
Exemplo n.º 7
0
        public virtual IPlayerSlotController PrepareVideoPlayerSlotController(IPlayerManager playerManager, PlayerContextManager playerContextManager,
                                                                              PlayerContextConcurrencyMode concurrencyMode, out bool makePrimaryPlayer, out int audioPlayerSlotIndex, out int currentPlayerSlotIndex)
        {
            IList <IPlayerContext> playerContexts = playerContextManager.PlayerContexts;
            int numActive = playerContexts.Count;
            IPlayerSlotController result;

            switch (concurrencyMode)
            {
            case PlayerContextConcurrencyMode.ConcurrentAudio:
                if (numActive > 1 && playerContexts[PlayerContextIndex.SECONDARY].AVType == AVType.Audio)
                { // The secondary slot is an audio player slot
                    IPlayerContext playerContext = playerContexts[PlayerContextIndex.PRIMARY];
                    result               = playerContext.Revoke();
                    makePrimaryPlayer    = true;
                    audioPlayerSlotIndex = PlayerContextIndex.SECONDARY;
                }
                else if (numActive == 1 && playerContexts[PlayerContextIndex.PRIMARY].AVType == AVType.Audio)
                { // The primary slot is an audio player slot
                    result               = playerManager.OpenSlot();
                    makePrimaryPlayer    = true;
                    audioPlayerSlotIndex = PlayerContextIndex.SECONDARY;
                }
                else
                { // No audio slot available
                    playerContextManager.CloseAllPlayerContexts();
                    result               = playerManager.OpenSlot();
                    makePrimaryPlayer    = true;
                    audioPlayerSlotIndex = PlayerContextIndex.PRIMARY;
                }
                break;

            case PlayerContextConcurrencyMode.ConcurrentVideo:
                if (numActive >= 1 && playerContexts[PlayerContextIndex.PRIMARY].AVType == AVType.Video)
                { // The primary slot is a video player slot
                    if (numActive > 1)
                    {
                        IPlayerContext pcSecondary = playerContextManager.GetPlayerContext(PlayerContextIndex.SECONDARY);
                        pcSecondary.Close();
                    }
                    result               = playerManager.OpenSlot();
                    makePrimaryPlayer    = false;
                    audioPlayerSlotIndex = PlayerContextIndex.PRIMARY;
                }
                else
                {
                    playerContextManager.CloseAllPlayerContexts();
                    result               = playerManager.OpenSlot();
                    makePrimaryPlayer    = true;
                    audioPlayerSlotIndex = PlayerContextIndex.PRIMARY;
                }
                break;

            default:
                // Don't enable concurrent controllers: Close all except the primary slot controller
                playerContextManager.CloseAllPlayerContexts();
                result               = playerManager.OpenSlot();
                makePrimaryPlayer    = true;
                audioPlayerSlotIndex = PlayerContextIndex.PRIMARY;
                break;
            }
            currentPlayerSlotIndex = makePrimaryPlayer ? PlayerContextIndex.PRIMARY : PlayerContextIndex.SECONDARY;
            return(result);
        }
Exemplo n.º 8
0
        public virtual IPlayerSlotController PrepareAudioPlayerSlotController(IPlayerManager playerManager, PlayerContextManager playerContextManager,
                                                                              bool concurrentVideo, out int currentPlayerSlotIndex)
        {
            int numActive;

            if (concurrentVideo)
            {
                numActive = playerContextManager.NumActivePlayerContexts;
                // Solve conflicts - close conflicting slots
                IPlayerContext secondaryPC = playerContextManager.GetPlayerContext(PlayerContextIndex.SECONDARY);
                if (secondaryPC != null)
                {
                    secondaryPC.Close();
                }
                IPlayerContext pcPrimary;
                if (numActive > 0 && (pcPrimary = playerContextManager.GetPlayerContext(PlayerContextIndex.PRIMARY)) != null && pcPrimary.AVType == AVType.Audio)
                {
                    pcPrimary.Close();
                }
            }
            else // !concurrentVideo
                 // Don't enable concurrent controllers: Close all except the primary slot controller
            {
                playerContextManager.CloseAllPlayerContexts();
            }
            numActive = playerContextManager.NumActivePlayerContexts;
            currentPlayerSlotIndex = numActive;
            return(playerManager.OpenSlot());
        }
Exemplo n.º 9
0
 public void ResetProgress()
 {
     PlayerContextManager.Reset();
 }
Exemplo n.º 10
0
 public virtual IPlayerSlotController PrepareVideoPlayerSlotController(IPlayerManager playerManager, PlayerContextManager playerContextManager,
     PlayerContextConcurrencyMode concurrencyMode, out bool makePrimaryPlayer, out int audioPlayerSlotIndex, out int currentPlayerSlotIndex)
 {
   IList<IPlayerContext> playerContexts = playerContextManager.PlayerContexts;
   int numActive = playerContexts.Count;
   IPlayerSlotController result;
   switch (concurrencyMode)
   {
     case PlayerContextConcurrencyMode.ConcurrentAudio:
       if (numActive > 1 && playerContexts[PlayerContextIndex.SECONDARY].AVType == AVType.Audio)
       { // The secondary slot is an audio player slot
         IPlayerContext playerContext = playerContexts[PlayerContextIndex.PRIMARY];
         result = playerContext.Revoke();
         makePrimaryPlayer = true;
         audioPlayerSlotIndex = PlayerContextIndex.SECONDARY;
       }
       else if (numActive == 1 && playerContexts[PlayerContextIndex.PRIMARY].AVType == AVType.Audio)
       { // The primary slot is an audio player slot
         result = playerManager.OpenSlot();
         makePrimaryPlayer = true;
         audioPlayerSlotIndex = PlayerContextIndex.SECONDARY;
       }
       else
       { // No audio slot available
         playerContextManager.CloseAllPlayerContexts();
         result = playerManager.OpenSlot();
         makePrimaryPlayer = true;
         audioPlayerSlotIndex = PlayerContextIndex.PRIMARY;
       }
       break;
     case PlayerContextConcurrencyMode.ConcurrentVideo:
       if (numActive >= 1 && playerContexts[PlayerContextIndex.PRIMARY].AVType == AVType.Video)
       { // The primary slot is a video player slot
         if (numActive > 1)
         {
           IPlayerContext pcSecondary = playerContextManager.GetPlayerContext(PlayerContextIndex.SECONDARY);
           pcSecondary.Close();
         }
         result = playerManager.OpenSlot();
         makePrimaryPlayer = false;
         audioPlayerSlotIndex = PlayerContextIndex.PRIMARY;
       }
       else
       {
         playerContextManager.CloseAllPlayerContexts();
         result = playerManager.OpenSlot();
         makePrimaryPlayer = true;
         audioPlayerSlotIndex = PlayerContextIndex.PRIMARY;
       }
       break;
     default:
       // Don't enable concurrent controllers: Close all except the primary slot controller
       playerContextManager.CloseAllPlayerContexts();
       result = playerManager.OpenSlot();
       makePrimaryPlayer = true;
       audioPlayerSlotIndex = PlayerContextIndex.PRIMARY;
       break;
   }
   currentPlayerSlotIndex = makePrimaryPlayer ? PlayerContextIndex.PRIMARY : PlayerContextIndex.SECONDARY;
   return result;
 }