Beispiel #1
0
 public void LoadScene(SceneIndex index)
 {
     if (SceneManager.GetActiveScene().buildIndex != (int)index)
     {
         SceneManager.LoadScene((int)index);
     }
 }
Beispiel #2
0
    private IEnumerator LoadNextScene(SceneIndex sceneIndex)
    {
        while (networkObject == null)
        {
            Debug.Log("Network not ready");
            yield return(null);
        }

        FadeOut();
        // Load loading scene
        yield return(SceneManager.LoadSceneAsync((int)SceneIndex.LOADING_SCENE_INDEX));

        // Artificial load time injected to not flicker in/out of loading scene.
        yield return(new WaitForSeconds(1.0f));

        FadeOut();
        AsyncOperation asyncOp = SceneManager.LoadSceneAsync((int)sceneIndex);

        asyncOp.allowSceneActivation = false;

        while (!asyncOp.isDone)
        {
            if (asyncOp.progress >= 0.9f)
            {
                asyncOp.allowSceneActivation = true;
            }

            yield return(null);
        }

        // Scene loaded for host
        NetworkingPlayer host = NetworkManager.Instance.Networker.Me;

        CheckAllLoadedScene(host);
    }
//--------------------------------------------------------------------------------------------

	void Start()
	{
		mSavedGameManager = SavedGameManager.createOrLoadSavedGameManager(gmPrefab).GetComponent<SavedGameManager>();

		//if the current game ptr is somehow bad, return to the main menu
		if(mSavedGameManager.getCurrentGame() == null)
		{
			Debug.Log("ERROR: CURRENT GAME PTR NULL -- LOADING MAIN MENU");
			SceneManager.LoadScene((int)SceneIndex.MAIN_MENU);
			return;
		}

		//init the sprite arrays
		levelTitleSprites = Resources.LoadAll<Sprite>("GUI_Assets/LevelTitles");
		levelButtonSprites = Resources.LoadAll<Sprite>("GUI_Assets/LevelButtonIcons");
		levelImgSprites = Resources.LoadAll<Sprite>("GUI_Assets/WorldIcons");
		stageButtonSprites = Resources.LoadAll<Sprite>("GUI_Assets/StageButtonIcons");

		//hide classified levels / worlds
		setLevelButtonsClassified();

		//need to get a handle on the final chassis stars
		finalChassisStars = mStagePanel.GetComponentsInChildren<FinalChassisStar>();

		//tutorial always unlocked, init menu to this
		lastButtonClicked = mLevelPanel.GetComponentInChildren<Button>();
		lastButtonClicked.Select();
		handleLevelButtonMouseOver(0);

		//sanity check -- null any selected level data on the current game ptr
		mSavedGameManager.getCurrentGame().setSelectedLevel(SceneIndex.NULL);
		mSelectedLevel = SceneIndex.NULL;

		StartCoroutine(mScreenFader.FadeFromBlack());
	}
 public LoadedScene(ISceneController controller, SceneModel model, GameObject sceneRoot, SceneIndex id)
 {
     Controller      = controller;
     Model           = model;
     SceneIdentifier = id;
     Scene           = sceneRoot;
 }
Beispiel #5
0
 private void LoadNewScene(SceneIndex sceneIndex, bool activateWhenLoaded = true)
 {
     /*checks the following conditions:
      *  - if the current scene...
      *      - is empty OR
      *      - not same as the scene to add AND it's done loading
      *  - if the incoming scene is none (can accept one scene at a time)
      */
     if ((loadedSceneIndex == SceneIndex.None || loadedSceneIndex != sceneIndex && loadedScene.isDone) &&
         incomingSceneIndex == SceneIndex.None)
     {
         if (loadedSceneIndex == SceneIndex.None)
         {
             loadedScene = SceneManager.LoadSceneAsync((int)sceneIndex, LoadSceneMode.Additive);
             loadedScene.allowSceneActivation = activateWhenLoaded;
             loadedSceneIndex = sceneIndex;
         }
         else
         {
             incomingScene = SceneManager.LoadSceneAsync((int)sceneIndex, LoadSceneMode.Additive);
             //determines whether if the scene is allowed activate
             incomingScene.allowSceneActivation = activateWhenLoaded;
             incomingSceneIndex = sceneIndex;
             UnloadCurrentScene();
         }
     }
 }
//--------------------------------------------------------------------------------------------

	public void handleLevelCompleted(SceneIndex level)
	{
		isLevelComplete = true;

		//get the saved game manager
		gameManager = GameObject.Find("SavedGameManager").GetComponent<SavedGameManager>();
		if(gameManager == null)
		{
			return;
		}

		//save whether or not the final chassis was used
		didUseFinalChassis = gameManager.getCurrentGame().getCurrentLoadout().getChasis() == Loadout.LoadoutChasis.FINAL;

		//save the score, and if there were no hits (if player not hit, bonus added to final score)
		score = GameObject.Find("Score").GetComponent<Score>();
		finalScore = score.wasPlayerHit ? 
			score.trueScore : 
			score.trueScore + (int)PointVals.NO_HITS;

		//save score and get the old high scores
		oldPersonalHighScore = gameManager.getCurrentGame().highScores[(int)level - 3];
		oldGlobalHighScore = gameManager.globalHighScores[(int)level - 3];

		//save game
		gameManager.handleLevelCompleted(level, finalScore, didUseFinalChassis);

		//now we can activate the panel and run its animations
		gameObject.SetActive(true);
		StartCoroutine(handlePanelAnimations());

		//activate the button
		button.Select();
	}
        private async void SceneLoadAsync(SceneIndex index)
        {
            var buildIndex = (int)index;

            m_LoadingOperation = SceneManager.LoadSceneAsync(buildIndex, LoadSceneMode.Additive);

            m_TokenSource = new CancellationTokenSource();
            var token = m_TokenSource.Token;

            try
            {
                await ChackLoadingOperationStatus(m_LoadingOperation, token);

                //await TrySceneLoadAsync(index, token);

                Debug.Log("Scene loading is done!");
            }
            catch (OperationCanceledException ex)
            {
                Debug.Log(string.Format("Задача {0} завершена по причине {1}: ", nameof(SceneLoadAsync), ex.Message));
            }

            m_LoadingScene = SceneManager.GetSceneByBuildIndex(buildIndex);

            m_TokenSource.Cancel();
        }
//--------------------------------------------------------------------------------------------

	void Start()
	{
		mSavedGameManager = GameObject.FindGameObjectWithTag("SaveManager").GetComponent<SavedGameManager>();

		//if the current game ptr is somehow bad, return to the main menu
		if(mSavedGameManager.getCurrentGame() == null)
		{
			Debug.Log("CURRENT GAME PTR NULL: RETURNING TO MAIN MENU");

			//TODO -- spawn error message, return to main menu
		}

		//populate map of level buttons
		LevelButtonEventHandler[] levelButtons = GetComponentsInChildren<LevelButtonEventHandler>();
		foreach(LevelButtonEventHandler handler in levelButtons)
		{
			Button button = handler.gameObject.GetComponent<Button>();
			if(button != null)
			{
				mLevelButtonMap.Add(handler, button);
			}
		}

		//TODO -- init high scores using the game manager and current game ptr
		//TODO -- enable / disable buttons based on current game ptr level completion

		//sanity check -- null any selected level data on the current game ptr
		mSavedGameManager.getCurrentGame().setSelectedLevel(SceneIndex.NULL);
		mSelectedLevel = SceneIndex.NULL;
	}
Beispiel #9
0
 private void Awake()
 {
     instance     = this;
     op           = SceneManager.LoadSceneAsync((int)SceneIndex.mainMenu, LoadSceneMode.Additive);
     currentScene = SceneIndex.mainMenu;
     StartCoroutine(LoadAndSetActive(false));
     statusCanvas.SetActive(false);
 }
Beispiel #10
0
 public OOTItem(SceneIndex sceneIndex, string line, string collectableType, string containingItem, int flagIndex)
 {
     this.sceneIndex      = sceneIndex;
     this.line            = line;
     this.collectableType = collectableType;
     this.containingItem  = containingItem;
     this.flagIndex       = flagIndex;
 }
Beispiel #11
0
 public DataScene(string label, GameObject parent, SceneIndex index, IPage[] pages, IPage pageStart)
 {
     Label     = label;
     Parent    = parent;
     Index     = index;
     Pages     = pages;
     PageStart = pageStart;
 }
Beispiel #12
0
 public void LoadScene(SceneIndex sceneIndex)
 {
     Debug.Log("Loading");
     m_PlayersLoadedNextScene.Clear();
     // To trigger events on host when clients finish loading scene
     NetworkManager.Instance.playerLoadedScene += (np, sender) => CheckAllLoadedScene(np);
     StartCoroutine(LoadNextScene(sceneIndex));
 }
Beispiel #13
0
    public void ChangeScene(SceneIndex index)
    {
        FadeSetUp("FadeOut");

        _NextScene   = index;
        _IsnextScene = true;
        StartCoroutine("FadeOut");
    }
        private IEnumerator LoadAdditiveScene(SceneIndex scene, SceneModel model)
        {
            OnLoadingStart?.Invoke();
            IsLoading = true;

            AsyncOperation loadSceneJob = SceneManager.LoadSceneAsync(scene.ToString(), LoadSceneMode.Additive);

            while (!loadSceneJob.isDone)
            {
                yield return(null);

                // Callback to update based on the async task progress
                OnLoadingUpdate?.Invoke(loadSceneJob.progress);
            }

            // Scene was done loading
            Scene loadedScene = SceneManager.GetSceneByName(scene.ToString());

            if (loadedScene.isLoaded)
            {
                SceneManager.MergeScenes(loadedScene, SceneManager.GetActiveScene());

                bool controllerFound = false;
                // Get the scene object to initialize the scene using the ISceneController interface
                GameObject[] rootObjects = loadedScene.GetRootGameObjects();
                foreach (GameObject rootObject in rootObjects)
                {
                    // Try to get the scene controller so we can initialize the scene
                    SceneController <SceneModel> sceneController = rootObject.GetComponent <SceneController <SceneModel> >();

                    // This object didn't have the scene controller
                    if (sceneController == null)
                    {
                        continue;
                    }

                    sceneController.BaseModel = model;

                    LoadedScene managedLoadedScene = new LoadedScene(sceneController, model, rootObject, scene);
                    _loadedScenes.Add(managedLoadedScene);

                    yield return(sceneController.Initialization());

                    sceneController.AfterInitialization();

                    controllerFound = true;
                }

                if (!controllerFound)
                {
                    Debug.LogError("[SceneTransitionManager] Could not find any object with component ISceneController in scene: "
                                   + loadedScene.name);
                }
            }

            OnLoadingFinished?.Invoke();
            IsLoading = false;
        }
    public void LoadCard(SceneIndex sceneIndex)
    {
        int index = (int)sceneIndex - 3;

        if (shownCard == null)
        {
            shownCard = titleCards[index];
        }
    }
Beispiel #16
0
    public void ContinueLevel()
    {
        SceneIndex savedMapIndex = LevelLoader.GetSavedScene();

        Debug.Log($"[STAGECOMPLETE] Index: {savedMapIndex}");
        TransitionLoader.UseMainMenuEvents = true;
        GameManager.current.MoveScene(savedMapIndex, false);
        onLevelContinue?.Raise(savedMapIndex);
    }
Beispiel #17
0
 public MenuItem(Vector2 position, String contents, SceneControls control, SceneIndex gotoIndex)
     : base(position, contents)
 {
     zindex = 0.2f;
     fontColor = Color.White;
     highlightColor = Color.White;
     this.control = control;
     this.gotoIndex = gotoIndex;
 }
Beispiel #18
0
 public void EnableStartButton(SceneIndex scene)
 {
     targetScene = scene;
     canStart    = true;
     playWidget.ResetLabel();
     playButtonImage.color = activeColour;
     playButton.enabled    = true;
     hasScene = true;
 }
Beispiel #19
0
    public void StartLevel()
    {
        savedMapIndex = LevelLoader.GetSavedScene();

        Debug.Log($"[MAINMENU] Index: {savedMapIndex}");
        TransitionLoader.UseMainMenuEvents = true;
        GameManager.current.MoveScene(savedMapIndex, false);
        onLevelContinue?.Raise(savedMapIndex);
    }
Beispiel #20
0
 public void QuitToTitle()
 {
     SceneManager.UnloadSceneAsync((int)currentScene);
     op           = SceneManager.LoadSceneAsync((int)SceneIndex.mainMenu, LoadSceneMode.Additive);
     currentScene = SceneIndex.mainMenu;
     statusCanvas.SetActive(false);
     StartCoroutine(LoadAndSetActive(false));
     PlayerManager.instance.Player.GetComponent <PlayerController>().Cleanup();
 }
Beispiel #21
0
 public void loadScene(SceneIndex index)
 {
     statusCanvas.SetActive(false);
     loadingScreen.SetActive(true);
     SceneManager.UnloadSceneAsync((int)currentScene);
     op           = SceneManager.LoadSceneAsync((int)index, LoadSceneMode.Additive);
     currentScene = index;
     StartCoroutine(LoadAndSetActive(true));
 }
Beispiel #22
0
        public SceneData(SceneIndex index, byte[] saveFile)
        {
            this.index = index;
            int startIndex = SCENE_DATA_HEAD + (int)index * SCENE_DATA_SIZE;

            sceneBytes = new byte[SCENE_DATA_SIZE];
            for (int i = 0; i < SCENE_DATA_SIZE; i++)
            {
                sceneBytes[i] = saveFile[startIndex + i];
            }
        }
        /*
         * private async void SceneEnterAsync(SceneIndex index)
         * {
         *  m_TokenSource = new CancellationTokenSource();
         *  var token = m_TokenSource.Token;
         *
         *  try
         *  {
         *      await TrySceneEnterAsync(index, token);
         *  }
         *  catch (OperationCanceledException ex)
         *  {
         *
         *      Debug.Log(string.Format("Задача {0} завершена по причине {1}: ", nameof(SceneEnterAsync), ex.Message));
         *  }
         *
         *  m_TokenSource.Cancel();
         * }
         *
         *
         *
         * private async Task TrySceneLoadAsync(SceneIndex index, CancellationToken token)
         * {
         *  IScene scene = null;
         *  while(!GetInitialized(index, out scene))
         *  {
         *      Debug.Log("Trying to get initialized scene...");
         *      await Task.Delay(1000);
         *
         *      if (token.IsCancellationRequested)
         *          break;;
         *  }
         *
         *
         *  scene.Load();
         *
         *  while(!SceneCheckState<StateConfigure>(scene))
         *  {
         *      await Task.Delay(100);
         *
         *      if (token.IsCancellationRequested)
         *          break;;
         *  }
         *  Debug.Log("Scene load is done!");
         *
         * }
         *
         * private async Task TrySceneEnterAsync(SceneIndex index, CancellationToken token)
         * {
         *  IScene scene = null;
         *  while(!GetLoaded(index, out scene))
         *  {
         *      Debug.Log("Trying to get initialized scene...");
         *      await Task.Delay(1000);
         *
         *      if (token.IsCancellationRequested)
         *          break;;
         *  }
         *
         *
         *  scene.Enter();
         *
         *  while(!SceneCheckState<StateActivate>(scene))
         *  {
         *      await Task.Delay(100);
         *
         *      if (token.IsCancellationRequested)
         *          break;;
         *  }
         *
         *  Debug.Log("Scene enter is done!");
         *
         * }
         *
         *
         *
         * public bool AddInitialized(IScene scene)
         * {
         *  if(m_SceneInitialized.Contains(scene))
         *  {
         *      Debug.Log("Scene already registered.");
         *      return false;
         *  }
         *
         *  m_SceneInitialized.Add(scene);
         *
         *  //Subscribe(true, scene);
         *
         *  Debug.Log("Scene was add to initialized list.");
         *  return true;
         * }
         *
         * public bool RemoveInitialized(IScene scene)
         * {
         *  if(m_SceneInitialized.Contains(scene))
         *  {
         *      Debug.Log("Scene was not registered.");
         *      return false;
         *  }
         *
         *  m_SceneInitialized.Remove(scene);
         *
         *  //Subscribe(false, scene);
         *
         *  Debug.Log("Scene removed.");
         *  return true;
         *
         * }
         *
         *
         * public bool AddLoaded(IScene scene)
         * {
         *  if(m_SceneLoaded.Contains(scene))
         *  {
         *      Debug.Log("Scene already registered.");
         *      return false;
         *  }
         *
         *  m_SceneLoaded.Add(scene);
         *
         *  //Subscribe(true, scene);
         *
         *  Debug.Log("Scene was add to loaded list.");
         *  return true;
         * }
         *
         * public bool RemoveLoaded(IScene scene)
         * {
         *
         *  if(m_SceneLoaded.Contains(scene))
         *  {
         *      Debug.Log("Scene was not registered.");
         *      return false;
         *  }
         *
         *  m_SceneLoaded.Remove(scene);
         *
         *  //Subscribe(false, scene);
         *
         * Debug.Log("Scene removed.");
         *  return true;
         *
         * }
         *
         *
         * public bool AddActivated(IScene scene)
         * {
         *  if(m_SceneActivated.Contains(scene))
         *  {
         *      Debug.Log("Scene already registered.");
         *      return false;
         *  }
         *
         *  m_SceneActivated.Add(scene);
         *
         *  //Subscribe(true, scene);
         *
         *  Debug.Log("Scene was add to activated list.");
         *  return true;
         * }
         *
         * public bool RemoveActivated(IScene scene)
         * {
         *  if(m_SceneActivated.Contains(scene))
         *  {
         *      Debug.Log("Scene was not registered.");
         *      return false;
         *  }
         *
         *  m_SceneActivated.Remove(scene);
         *
         *  //Subscribe(false, scene);
         *
         *  Debug.Log("Scene removed.");
         *  return true;
         *
         * }
         *
         *
         * public bool GetInitialized(SceneIndex index, out IScene scene)
         * {
         *  if(m_SceneInitialized.Get(index, out scene))
         *  {
         *      return true;
         *  }
         *
         *  Debug.Log("Scene is not initialize!");
         *  scene = null;
         *  return false;
         * }
         *
         * public bool GetLoaded(SceneIndex index, out IScene scene)
         * {
         *  if(m_ScenesLoaded.TryGetValue(index, out scene))
         *  {
         *      return true;
         *  }
         *
         *  Debug.Log("Scene is not load!");
         *  scene = null;
         *  return false;
         * }
         *
         * public bool GetActivated(SceneIndex index, out IScene scene)
         * {
         *  if(m_ScenesActivated.TryGetValue(index, out scene))
         *  {
         *      return true;
         *  }
         *
         *  Debug.Log("Scene is not active!");
         *  scene = null;
         *  return false;
         * }
         *
         */
        //private void Subscribe(bool subscribe, IScene scene)
        //{
        //    if(subscribe)
        //        scene.StateUpdated += SceneStateUpdated;
        //    else
        //       scene.StateUpdated -= SceneStateUpdated;
        //}

        //protected virtual void SceneStateUpdated(ISceneEventArgs args)
        //{
        //
        //
        //}



/*
 *      public void SceneEnterNext<TScene, TPage>(bool delay = false)
 *          where TScene: class, IScene
 *          where TPage: class, IPage
 *      {
 *          SceneEnterNext(typeof(TScene), typeof(TPage), delay);
 *      }
 *
 *      public void SceneEnterNext(Type sceneNextType, Type pageNextType, bool delay = false)
 *      {
 *          var sceneNext = Cache.Get(sceneNextType);
 *          var pageNext = sceneNext.Cache.Get(pageNextType);
 *
 *          if(SceneActive == null)
 *          {
 *              LogWarning(Label, "You are trying to turn a scene [" + SceneActive.Label + "] that has not been registered!");
 *              return;
 *          }
 *
 *          if(SceneActive.Stats.IsActive)
 *          {
 *
 *              PageExit(pageNext);
 *              SceneActive.Activate(false);
 *              Log(Label, "[" + SceneActive.Label + "] was deactivated!");
 *          }
 *
 *
 *          if(delay)
 *          {
 *              StopCoroutine("WaitForSceneExit");
 *              StartCoroutine(WaitForSceneExit(sceneNextType, pageNextType));
 *              //Log("Animation is enabled on page [ " + Name + " ]");
 *          }
 *          else
 *          {
 *              SceneEnter(sceneNextType, pageNextType);
 *          }
 *
 *      }
 *
 *      public void SceneEnter<TScene, TPage>()
 *          where TScene: class, IScene
 *          where TPage: class, IPage
 *      {
 *          SceneEnter(typeof(TScene), typeof(TPage));
 *      }
 *
 *      public void SceneEnter(Type sceneType, Type pageType)
 *      {
 *          var sceneNext = Cache.Get(sceneType);
 *          Log(Label, "[" + sceneNext.Label + "] was found in the cache! Hashcode is [" + sceneNext.GetHashCode() + "]");
 *
 *
 *          //var pageNext = sceneNext.Cache.Get(pageType);
 *          //Log(Label, "[" + pageNext.Label + "] was found in the cache! Hashcode is [" + pageNext.GetHashCode() + "]");
 *
 *
 *
 *          if(sceneNext==null)
 *          {
 *              LogWarning(Label, "You are trying to turn a scene on [" + sceneNext.Label + "] that has not been registered!");
 *              return;
 *          }
 *
 *          SceneActive = sceneNext.Activate(true);
 *          //SceneActive.DataSceneLoading.PageActive = pageNext;
 *
 *
 *          //PageEnter(pageNext);
 *          Log(Label, "[" + SceneActive.Label + "] was activated!");
 *      }
 *
 *
 *      private IEnumerator WaitForSceneExit(Type sceneType, Type pageType)
 *      {
 *
 *          Log(Label, "Waiting for exit [" + SceneActive.Label + "]...");
 *
 *          while (sceneActive.DataAnimation.TargetState != AScene.ANIMATOR_STATE_NONE)
 *          {
 *              yield return null;
 *          }
 *
 *          yield return new WaitForSeconds(2f);
 *          SceneEnter(sceneType, pageType);
 *
 *      }
 */
        private bool GetSceneByIndex <T>(out SceneIndex index)
            where T : IScene
        {
            if (!m_SceneIndexes.TryGetValue(typeof(T), out index))
            {
                Debug.Log("Index was not found!");
                return(false);
            }

            return(true);
        }
Beispiel #24
0
 public void LoadLevel(SceneIndex newScene)
 {
     if (newScene != SceneIndex.CreditScene)
     {
         StartCoroutine(LoadNewLevel(newScene));
     }
     else
     {
         StartCoroutine(LoadCredits());
     }
 }
Beispiel #25
0
 private void Awake()
 {
     if (instance == false)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(gameObject);
     currentLevel = SceneIndex.TitleScreen;
 }
 private static void FetchSceneIndex()
 {
     //fetches the saved level
     if (mapData != null)
     {
         savedMapIndex = (SceneIndex)(mapData.mapLevel + 2);
     }
     else
     {
         savedMapIndex = SceneIndex.Level1_Game;
     }
     Debug.Log($"[LEVELLOADER] Index: {savedMapIndex}");
 }
Beispiel #27
0
    private void EvaluateNewState(InitStates newState)
    {
        switch (newState)
        {
        case InitStates.LevelClear:
            previousLevelScene = TransitionManager.instance.GetCurrentLevel();
            break;

        case InitStates.MainMenu:
            EvaluateMessages();
            break;
        }
    }
Beispiel #28
0
        public Scene getScene(SceneIndex sceneIndex)
        {
            Scene temp = null;

            for (int i = 0; i < this.scenes.Count; i++)
            {
                if (this.scenes[i].sceneIndex == sceneIndex)
                {
                    temp = this.scenes[i];
                }
            }

            return temp;
        }
 /// <summary>
 /// Moves to selected scene
 /// </summary>
 public void _Move(SceneIndex sceneIndex)
 {
     if (sceneIndex != SceneIndex.None || sceneIndex != SceneIndex.Persistence)
     {
         try{
             GameManager.current.MoveScene(sceneIndex, false);
             onSceneMove?.Raise();
         }
         catch {
             //prevents error in case the developer plays directly at the scene
             //instead of playing it at the persistent scene
             SceneManager.LoadScene((int)sceneIndex);
         }
     }
 }
Beispiel #30
0
        SceneLoadedCallbackCoroutine
            (SceneIndex sceneIndex, SceneLoadedCallback callback)
        {
            lock (SceneLoadLock)
            {
                SceneLoadInProgress = true;
                AsyncOperation SceneLoad
                    = SceneManager.LoadSceneAsync((int)sceneIndex, LoadSceneMode.Additive);
                ConfirmSceneLoadNotNull(sceneIndex, SceneLoad);
                yield return(new WaitUntil(() => SceneLoad.isDone));

                SceneLoadInProgress = false;
                callback();
            }
        }
Beispiel #31
0
 private static void CheckAll(string command)
 {
     foreach (var item in map.items)
     {
         SceneIndex sceneIndex = item.sceneIndex;
         SceneData  scene      = save.scenes[(int)sceneIndex];
         string     check      = "\t[ ]";
         if (item.CheckWord(scene.GetChestWord(), scene.GetCollectableWord()))
         {
             check = "\t[x]";
         }
         check += " " + item.ToString();
         Console.WriteLine(check);
     }
 }
Beispiel #32
0
    private IEnumerator BeginGameLoad(SceneIndex newLevel)
    {
        isLoading = true;
        LoadingScreen.instance.BeginFade(true);
        isFading = true;

        //wait till fade end before initialising level

        while (isFading)
        {
            yield return(null);
        }

        //Unload currentlevel (e.g. mainMenu)
        AsyncOperation sceneUnload = (SceneManager.UnloadSceneAsync((int)currentLevel));

        while (!sceneUnload.isDone)
        {
            yield return(null);
        }
        //Load in new level
        AsyncOperation sceneLoad = (SceneManager.LoadSceneAsync((int)newLevel, LoadSceneMode.Additive));

        while (!sceneLoad.isDone)
        {
            yield return(null);
        }
        currentLevel = newLevel; // once done current level is new level
        SaveData.current.lastSession.lastLevel = currentLevel;
        InitStateManager.instance.BeginNewState(InitStates.LevelLoaded);
        //loadUi
        sceneLoad = SceneManager.LoadSceneAsync((int)SceneIndex.UIscene, LoadSceneMode.Additive);
        while (!sceneLoad.isDone)
        {
            yield return(null);
        }
        InitStateManager.instance.BeginNewState(InitStates.UISceneLoaded);
        //load in player scene
        sceneLoad = (SceneManager.LoadSceneAsync((int)SceneIndex.PlayerScene, LoadSceneMode.Additive));
        while (!sceneLoad.isDone)
        {
            yield return(null);
        }
        InitStateManager.instance.BeginNewState(InitStates.PlayerSceneLoaded);

        isLoading = false;
    }
Beispiel #33
0
    private IEnumerator LoadTabletMenu()
    {
        isLoading = true;
        LoadingScreen.instance.BeginFade(true);
        isFading = true;

        //wait till fade end before initialising level

        while (isFading)
        {
            yield return(null);
        }

        //get all currently loaded scenes
        Scene[] loadedScenes = GetAllActiveScenes();

        //add and unload operations
        foreach (Scene scene in loadedScenes)
        {
            if (scene.buildIndex != (int)SceneIndex.ManagerScene)
            {
                sceneLoading.Add(SceneManager.UnloadSceneAsync(scene));
            }
        }

        //wait until every scene has unloaded
        for (int i = 0; i < sceneLoading.Count; i++)
        {
            while (!sceneLoading[i].isDone)
            {
                yield return(null);
            }
        }
        //clear scens loading
        sceneLoading.Clear();

        //begin loading title screen
        AsyncOperation menu = SceneManager.LoadSceneAsync((int)SceneIndex.TabletMenu, LoadSceneMode.Additive);

        while (!menu.isDone)
        {
            yield return(null);
        }
        currentLevel = SceneIndex.TabletMenu;
        SaveData.current.lastSession.lastLevel = currentLevel;
        InitStateManager.instance.BeginNewState(InitStates.MainMenu);
    }
Beispiel #34
0
    private void UnloadCurrentScene()
    {
        if (loadedSceneIndex != SceneIndex.None)
        {
            SceneManager.UnloadSceneAsync((int)loadedSceneIndex);

            //make new scene into a current one
            loadedScene        = incomingScene;
            loadedSceneIndex   = incomingSceneIndex;
            incomingScene      = null;
            incomingSceneIndex = SceneIndex.None;
        }
        else
        {
            Debug.LogError("Scene is not unloading");
        }
    }
Beispiel #35
0
    IEnumerator coLoadLevel(SceneIndex toLoad)
    {
        loading = true;

        // Wait for the loading screen to fade in
        yield return(new WaitForSecondsRealtime(1.0f));

        // Unload the last scene if we are not the manager scene
        if (current != (int)SceneIndex.MANAGER)
        {
            currentlyLoading.Add(SceneManager.UnloadSceneAsync(current));
        }

        currentlyLoading.Add(SceneManager.LoadSceneAsync((int)toLoad, LoadSceneMode.Additive));
        current = (int)toLoad;

        float percent;

        // Update the progress bar
        // For each scene we are loading / unloading
        for (int i = 0; i < currentlyLoading.Count; i++)
        {
            while (currentlyLoading[i].isDone == false)
            {
                percent = 0;

                // Add the completion percent of the current operation (scene being loaded / unloaded)
                foreach (AsyncOperation operation in currentlyLoading)
                {
                    percent += operation.progress;
                }

                // Turn the into a percent
                percent = (percent / currentlyLoading.Count) * 100.0f;

                // Apply it to the loading bar
                loadingBar.value = Mathf.Round(percent);

                yield return(null);
            }
        }

        yield return(new WaitForSecondsRealtime(1.0f));

        loading = false;
    }
//--------------------------------------------------------------------------------------------

	public void handleStageButtonMouseExit(SceneIndex si)
	{
		//overwrite the data panel with null data
		initDataPanel(SceneIndex.NULL);
	}
//--------------------------------------------------------------------------------------------

	void initDataPanel(SceneIndex sceneIndex)
	{
		switch(sceneIndex)
		{
		case SceneIndex.GAMEPLAY_TUTORIAL_1:
		case SceneIndex.GAMEPLAY_TUTORIAL_2:
		case SceneIndex.GAMEPLAY_TUTORIAL_3:
		case SceneIndex.GAMEPLAY_1_1:
		case SceneIndex.GAMEPLAY_1_2:
		case SceneIndex.GAMEPLAY_1_3:
		case SceneIndex.GAMEPLAY_2_1:
		case SceneIndex.GAMEPLAY_2_2:
		case SceneIndex.GAMEPLAY_2_3:
		case SceneIndex.GAMEPLAY_3_1:
		case SceneIndex.GAMEPLAY_3_2:
		case SceneIndex.GAMEPLAY_3_3:
		case SceneIndex.GAMEPLAY_4_1:
		case SceneIndex.GAMEPLAY_4_2:
			
			int i = (int)sceneIndex - 3;
			bool isUnlocked = mSavedGameManager.getCurrentGame().unlockedLevels[i];

			//set data panel image
			mDataPanelImg.sprite = isUnlocked ? levelImgSprites[i] : levelImgSprites[levelImgSprites.Length - 1];

			//set data panel high scores
			i = (int)sceneIndex - 3;
			foreach(Text t in mDataPanel.GetComponentsInChildren<Text>())
			{
				if(t.gameObject.name == "HighScorePersonal")
				{
					t.text = isUnlocked ? mSavedGameManager.getCurrentGame().highScores[i].ToString() : "-";
				}
				else if(t.gameObject.name == "HighScoreGlobal")
				{
					t.text = (mSavedGameManager.globalHighScores[i]).ToString();
				}
			}

			break;

		default:
			
			mDataPanelImg.sprite = levelImgSprites[levelImgSprites.Length - 1];

			//restore default high score text
			foreach(Text t in mDataPanel.GetComponentsInChildren<Text>())
			{
				if(t.gameObject.name == "HighScorePersonal")
				{
					t.text = "-";
				}
				else if(t.gameObject.name == "HighScoreGlobal")
				{
					t.text = "-";
				}
			}
			break;
		}
	}
//--------------------------------------------------------------------------------------------

	public SavedGame(string name)
	{
		mName = name;

		mSelectedLevel = SceneIndex.NULL;
		mCurrentLoadout = null;

		initLevelCompletionArray(SavedGameManager.NUM_GAMEPLAY_LEVELS);
		initHighScoreArray(SavedGameManager.NUM_GAMEPLAY_LEVELS);
		initFinalChassisArray(SavedGameManager.NUM_GAMEPLAY_LEVELS);

		initLoadoutArrays(Loadout.NUM_LOADOUTS);
	}
//--------------------------------------------------------------------------------------------

	public void handleIncomingLoadoutUnlock(SceneIndex index)
	{
		switch(index)
		{
		case SceneIndex.GAMEPLAY_TUTORIAL_1:
			unlockedSecondary[(int)Loadout.LoadoutSecondary.PHASING] = true;
			break;
		case SceneIndex.GAMEPLAY_TUTORIAL_2:
			unlockedPrimary[(int)Loadout.LoadoutPrimary.SWATTER] = true;
			break;
		case SceneIndex.GAMEPLAY_TUTORIAL_3:
			unlockedChasis[(int)Loadout.LoadoutChasis.FINAL] = true;
			break;

		case SceneIndex.GAMEPLAY_1_1:
			unlockedChasis[(int)Loadout.LoadoutChasis.BOOSTER] = true;
			break;
		case SceneIndex.GAMEPLAY_1_2:
			unlockedPrimary[(int)Loadout.LoadoutPrimary.BUGSPRAY] = true;
			break;
		case SceneIndex.GAMEPLAY_1_3:
			unlockedSecondary[(int)Loadout.LoadoutSecondary.HOLOGRAM] = true;
			break;

		case SceneIndex.GAMEPLAY_2_1:
			unlockedPrimary[(int)Loadout.LoadoutPrimary.FLAME] = true;
			break;
		case SceneIndex.GAMEPLAY_2_2:
			unlockedChasis[(int)Loadout.LoadoutChasis.SHRINK] = true;
			break;
		case SceneIndex.GAMEPLAY_2_3:
			unlockedSecondary[(int)Loadout.LoadoutSecondary.TESLA] = true;
			break;

		case SceneIndex.GAMEPLAY_3_1:
			unlockedSecondary[(int)Loadout.LoadoutSecondary.FREEZE] = true;
			break;
		case SceneIndex.GAMEPLAY_3_2:
			unlockedPrimary[(int)Loadout.LoadoutPrimary.VOLT] = true;
			break;
		case SceneIndex.GAMEPLAY_3_3:
			unlockedChasis[(int)Loadout.LoadoutChasis.QUICK] = true;
			break;

		default:
			break;
		}
	}
Beispiel #40
0
	public void setSelectedLevel(SceneIndex sl){ mSelectedLevel = sl; }
//--------------------------------------------------------------------------------------------

	public void handleStageButtonClicked(SceneIndex si)
	{
		if(si != SceneIndex.NULL && mSavedGameManager.getCurrentGame().unlockedLevels[(int)si - 3])
		{
			//save the incoming scene index
			mSelectedLevel = si;
			Debug.Log("NEW SELECTED LEVEL: " + mSelectedLevel);

			//automatically start the loadouts menu
			handleContinueButtonClicked();
		}
	}
//--------------------------------------------------------------------------------------------

	public void handleMapButtonClicked(SceneIndex si)
	{
		//save the incoming scene index
		mSelectedLevel = si;
		Debug.Log("NEW SELECTED LEVEL: " + mSelectedLevel);
	}
//--------------------------------------------------------------------------------------------

	public int getCurrentLevelHighscore(SceneIndex level)
	{
		return mCurrentGame.highScores[(int)level - 3];
	}
//--------------------------------------------------------------------------------------------

	public void handleLevelCompleted(SceneIndex currentLevel, int score, bool didUseFinalChassis)
	{
		//convert from SceneIndex to indexing int
		int i = (int)currentLevel - 3;
		if(i < 0 || i >= NUM_GAMEPLAY_LEVELS) return;

		//handle high scores
		if(globalHighScores[i] < score)			//global
		{
			globalHighScores[i] = score;
		}

		//handle stuff on the current game object
		mCurrentGame.handleIncomingScore(i, score);							//highscore
		mCurrentGame.handleIncomingLevelUnlock(i);							//level unlock
		mCurrentGame.handleIncomingFinalChassis(i, didUseFinalChassis);		//final chassis use
		mCurrentGame.handleIncomingLoadoutUnlock(currentLevel);				//loadout unlock

		//major change -- write out to file
		writeSavedGameFile();
	}
//--------------------------------------------------------------------------------------------

	public void handleStageButtonMouseOver(SceneIndex si)
	{
		//initialize the data panel with the current stage's data
		initDataPanel(si);
	}
Beispiel #46
0
        public Boolean gotoScene(SceneIndex sceneIndex)
        {
            Boolean flag = false;

            for (int i = 0; i < this.scenes.Count; i++)
            {
                if (this.scenes[i].sceneIndex == sceneIndex)
                {
                    Console.WriteLine("Found scene");
                    Console.Out.WriteLine("Stopping");
                    scenes[i].Stop();
                    Console.Out.WriteLine("Transfering options");
                    scenes[i].options = scenes[this.sceneIndex].options;
                    Console.Out.WriteLine("Setting scene index");
                    this.sceneIndex = i;
                    Console.Out.WriteLine("Loading content");
                    this.loadSceneContent();
                    Console.Out.WriteLine("Returning");
                    flag = true;
                    break;
                }
            }

            return flag;
        }
Beispiel #47
0
//--------------------------------------------------------------------------------------------

	public SavedGame(string name)
	{
		mName = name;

		mSelectedLevel = SceneIndex.NULL;
		mCurrentLoadout = null;
	}