Beispiel #1
0
 private void ChangeScene()
 {
     if (sceneNumber > -1 || chooseSceneBy == ChooseSceneBy.Name)
     {
         KickStarter.sceneChanger.ChangeScene(AdvGame.GetSceneName(chooseSceneBy, sceneName), sceneNumber, true);
     }
 }
Beispiel #2
0
        override public float Run()
        {
            if (endGameType == AC_EndGameType.QuitGame)
            {
                                #if UNITY_EDITOR
                UnityEditor.EditorApplication.isPlaying = false;
                                #else
                Application.Quit();
                                #endif
            }
            else if (endGameType == AC_EndGameType.LoadAutosave)
            {
                SaveSystem.LoadAutoSave();
            }
            else
            {
                KickStarter.runtimeInventory.SetNull();
                KickStarter.runtimeInventory.RemoveRecipes();

                DestroyImmediate(GameObject.FindWithTag(Tags.player));

                if (endGameType == AC_EndGameType.RestartGame)
                {
                    KickStarter.saveSystem.ClearAllData();
                    KickStarter.levelStorage.ClearAllLevelData();
                    KickStarter.runtimeInventory.Start();
                    KickStarter.runtimeVariables.Awake();
                    KickStarter.runtimeVariables.Start();

                    KickStarter.stateHandler.playedGlobalOnStart = false;
                    KickStarter.sceneChanger.ChangeScene(AdvGame.GetSceneName(chooseSceneBy, sceneName), sceneNumber, false);
                }
                else if (endGameType == AC_EndGameType.ResetScene)
                {
                    KickStarter.levelStorage.ClearCurrentLevelData();
                    KickStarter.sceneChanger.ChangeScene("", Application.loadedLevel, false);
                }
            }

            return(0f);
        }
Beispiel #3
0
        override public float Run()
        {
            if (KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
            {
                if (KickStarter.settingsManager.players.Count > 0 && KickStarter.settingsManager.players.Count > playerNumber && playerNumber > -1)
                {
                    if (KickStarter.player != null && KickStarter.player.ID == playerID)
                    {
                        Debug.Log("Cannot switch player - already controlling the desired prefab.");
                        return(0f);
                    }

                    if (KickStarter.settingsManager.players[playerNumber].playerOb != null)
                    {
                        KickStarter.saveSystem.SaveCurrentPlayerData();

                        Vector3    oldPlayerPosition = Vector3.zero;
                        Quaternion oldPlayerRotation = new Quaternion();
                        Vector3    oldPlayerScale    = Vector3.one;

                        if (KickStarter.player != null)
                        {
                            oldPlayerPosition = KickStarter.player.transform.position;
                            oldPlayerRotation = KickStarter.player.transform.rotation;
                            oldPlayerScale    = KickStarter.player.transform.localScale;
                        }

                        if (oldPlayer == OldPlayer.ReplaceWithNPC && oldPlayerNPC != null &&
                            (newPlayerPosition == NewPlayerPosition.ReplaceNPC || newPlayerPosition == NewPlayerPosition.AppearAtMarker))
                        {
                            oldPlayerNPC.transform.position   = oldPlayerPosition;
                            oldPlayerNPC.transform.rotation   = oldPlayerRotation;
                            oldPlayerNPC.transform.localScale = oldPlayerScale;
                        }

                        Quaternion newRotation = Quaternion.identity;
                        if (newPlayerPosition == NewPlayerPosition.ReplaceCurrentPlayer)
                        {
                            newRotation = oldPlayerRotation;
                        }
                        else if (newPlayerPosition == NewPlayerPosition.ReplaceNPC && newPlayerNPC)
                        {
                            newRotation = newPlayerNPC.transform.rotation;
                        }
                        else if (newPlayerPosition == NewPlayerPosition.AppearAtMarker && newPlayerMarker)
                        {
                            newRotation = newPlayerMarker.transform.rotation;
                        }

                        KickStarter.ResetPlayer(KickStarter.settingsManager.players[playerNumber].playerOb, playerID, true, newRotation);
                        Player newPlayer = KickStarter.player;

                        int sceneToLoad = Application.loadedLevel;
                        if (restorePreviousData && KickStarter.saveSystem.DoesPlayerDataExist(playerID, true))
                        {
                            sceneToLoad = KickStarter.saveSystem.GetPlayerScene(playerID);

                            if (sceneToLoad != Application.loadedLevel)
                            {
                                KickStarter.saveSystem.loadingGame = LoadingGame.JustSwitchingPlayer;
                                KickStarter.sceneChanger.ChangeScene("", sceneToLoad, true);
                            }
                        }
                        else
                        {
                            if (newPlayerPosition == NewPlayerPosition.ReplaceCurrentPlayer)
                            {
                                newPlayer.Teleport(oldPlayerPosition);
                                newPlayer.SetRotation(oldPlayerRotation);
                                newPlayer.transform.localScale = oldPlayerScale;
                            }
                            else if (newPlayerPosition == NewPlayerPosition.ReplaceNPC)
                            {
                                if (newPlayerNPC)
                                {
                                    newPlayer.Teleport(newPlayerNPC.transform.position);
                                    newPlayer.SetRotation(newPlayerNPC.transform.rotation);
                                    newPlayer.transform.localScale = newPlayerNPC.transform.localScale;

                                    newPlayerNPC.transform.position += new Vector3(100f, -100f, 100f);
                                }
                            }
                            else if (newPlayerPosition == NewPlayerPosition.AppearAtMarker)
                            {
                                if (newPlayerMarker)
                                {
                                    newPlayer.Teleport(newPlayerMarker.transform.position);
                                    newPlayer.SetRotation(newPlayerMarker.transform.rotation);
                                    newPlayer.transform.localScale = newPlayerMarker.transform.localScale;
                                }
                            }
                            else if (newPlayerPosition == NewPlayerPosition.AppearInOtherScene)
                            {
                                if (chooseNewSceneBy == ChooseSceneBy.Name && newPlayerSceneName == Application.loadedLevelName)
                                {
                                }
                                else if (chooseNewSceneBy == ChooseSceneBy.Number && newPlayerScene == Application.loadedLevel)
                                {
                                }
                                else
                                {
                                    KickStarter.sceneChanger.ChangeScene(AdvGame.GetSceneName(chooseNewSceneBy, newPlayerSceneName), newPlayerScene, true);
                                }
                            }
                        }

                        if (KickStarter.mainCamera.attachedCamera)
                        {
                            KickStarter.mainCamera.attachedCamera.MoveCameraInstant();
                        }

                        AssetLoader.UnloadAssets();
                    }
                    else
                    {
                        Debug.LogWarning("Cannot switch player - no player prefabs is defined.");
                    }
                }
            }

            return(0f);
        }
Beispiel #4
0
        private void LoadLevel(string sceneName, int sceneNumber, bool useLoadingScreen)
        {
            if (useLoadingScreen)
            {
                if (KickStarter.player)
                {
                    KickStarter.player.transform.position += new Vector3(0f, -10000f, 0f);
                }

                GameObject    go            = new GameObject("LevelManager");
                LoadingScreen loadingScreen = go.AddComponent <LoadingScreen>();
                loadingScreen.StartCoroutine(loadingScreen.InnerLoad(sceneName, sceneNumber, AdvGame.GetSceneName(KickStarter.settingsManager.loadingSceneIs, KickStarter.settingsManager.loadingSceneName), KickStarter.settingsManager.loadingScene));
            }
            else
            {
                if (sceneName != "")
                {
                    Application.LoadLevel(sceneName);
                }
                else
                {
                    Application.LoadLevel(sceneNumber);
                }
            }
        }