override public float Run()
        {
            if (KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
            {
                PlayerPrefab newPlayerPrefab = KickStarter.settingsManager.GetPlayerPrefab(playerID);

                if (newPlayerPrefab != null)
                {
                    if (KickStarter.player != null && KickStarter.player.ID == playerID)
                    {
                        Log("Cannot switch player - already controlling the desired prefab.");
                        return(0f);
                    }

                    if (newPlayerPrefab.playerOb != null)
                    {
                        KickStarter.saveSystem.SaveCurrentPlayerData();

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

                        PlayerData oldPlayerData         = new PlayerData();
                        NPCData    oldNPCData            = new NPCData();
                        bool       recordedOldPlayerData = false;
                        bool       recordedOldNPCData    = false;

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

                            oldPlayerData         = KickStarter.player.SavePlayerData(oldPlayerData);
                            recordedOldPlayerData = true;
                        }

                        if (newPlayerPosition != NewPlayerPosition.ReplaceCurrentPlayer)
                        {
                            if (oldPlayer == OldPlayer.ReplaceWithAssociatedNPC &&
                                (runtimeOldPlayerNPC == null || !runtimeOldPlayerNPC.gameObject.activeInHierarchy) &&
                                KickStarter.player.associatedNPCPrefab != null)
                            {
                                GameObject newObject = (GameObject)Instantiate(KickStarter.player.associatedNPCPrefab.gameObject);
                                newObject.name      = KickStarter.player.associatedNPCPrefab.gameObject.name;
                                runtimeOldPlayerNPC = newObject.GetComponent <NPC>();
                            }

                            if ((oldPlayer == OldPlayer.ReplaceWithNPC || oldPlayer == OldPlayer.ReplaceWithAssociatedNPC) &&
                                runtimeOldPlayerNPC != null && runtimeOldPlayerNPC.gameObject.activeInHierarchy)
                            {
                                runtimeOldPlayerNPC.Teleport(oldPlayerPosition);
                                runtimeOldPlayerNPC.TransformRotation    = oldPlayerRotation;
                                runtimeOldPlayerNPC.transform.localScale = oldPlayerScale;

                                if (recordedOldPlayerData)
                                {
                                    ApplyRenderData(runtimeOldPlayerNPC, oldPlayerData);
                                }

                                // Force the rotation / sprite child to update
                                runtimeOldPlayerNPC._Update();
                            }
                        }

                        if (runtimeNewPlayerNPC == null || newPlayerPosition == NewPlayerPosition.ReplaceAssociatedNPC)
                        {
                            // Try to find from associated NPC prefab

                            if (newPlayerPrefab.playerOb.associatedNPCPrefab != null)
                            {
                                ConstantID prefabID = newPlayerPrefab.playerOb.associatedNPCPrefab.GetComponent <ConstantID>();
                                if (prefabID != null && prefabID.constantID != 0)
                                {
                                    newPlayerNPC_ID     = prefabID.constantID;
                                    runtimeNewPlayerNPC = AssignFile <NPC> (prefabID.constantID, null);
                                }
                            }
                        }

                        Quaternion newRotation = Quaternion.identity;
                        if (newPlayerPosition == NewPlayerPosition.ReplaceCurrentPlayer)
                        {
                            newRotation = oldPlayerRotation;
                        }
                        else if (newPlayerPosition == NewPlayerPosition.ReplaceNPC && runtimeNewPlayerNPC != null)
                        {
                            newRotation = runtimeNewPlayerNPC.TransformRotation;
                        }
                        else if (newPlayerPosition == NewPlayerPosition.AppearAtMarker && runtimeNewPlayerMarker != null)
                        {
                            newRotation = runtimeNewPlayerMarker.transform.rotation;
                        }

                        if (runtimeNewPlayerNPC != null)
                        {
                            oldNPCData = runtimeNewPlayerNPC.SaveData(oldNPCData);
                        }

                        bool replacesOldPlayer = newPlayerPosition == NewPlayerPosition.ReplaceCurrentPlayer &&
                                                 (!restorePreviousData || !KickStarter.saveSystem.DoesPlayerDataExist(playerID, true));
                        KickStarter.ResetPlayer(newPlayerPrefab.playerOb, playerID, true, newRotation, keepInventory, false, replacesOldPlayer, alwaysSnapCamera);
                        Player newPlayer = KickStarter.player;
                        PlayerMenus.ResetInventoryBoxes();

                        if (replacesOldPlayer && recordedOldPlayerData)
                        {
                            ApplyRenderData(newPlayer, oldPlayerData);
                        }

                        if (restorePreviousData && KickStarter.saveSystem.DoesPlayerDataExist(playerID, true))
                        {
                            int    sceneToLoad     = KickStarter.saveSystem.GetPlayerScene(playerID);
                            string sceneToLoadName = KickStarter.saveSystem.GetPlayerSceneName(playerID);

                            if (sceneToLoad >= 0 && sceneToLoad != UnityVersionHandler.GetCurrentSceneNumber())
                            {
                                KickStarter.saveSystem.loadingGame = LoadingGame.JustSwitchingPlayer;
                                KickStarter.sceneChanger.ChangeScene(new SceneInfo(string.Empty, sceneToLoad), true, false);
                            }
                            else if (!string.IsNullOrEmpty(sceneToLoadName) && sceneToLoadName != UnityVersionHandler.GetCurrentSceneName())
                            {
                                KickStarter.saveSystem.loadingGame = LoadingGame.JustSwitchingPlayer;
                                KickStarter.sceneChanger.ChangeScene(new SceneInfo(sceneToLoadName, -1), true, false);
                            }
                            else
                            {
                                // Same scene
                                if (runtimeNewPlayerNPC != null)
                                {
                                    newPlayer.RepositionToTransform(runtimeNewPlayerNPC.transform);
                                    runtimeNewPlayerNPC.HideFromView(newPlayer);
                                }
                            }
                        }
                        else
                        {
                            // No data to restore

                            if (newPlayerPosition == NewPlayerPosition.ReplaceCurrentPlayer)
                            {
                                newPlayer.Teleport(oldPlayerPosition);
                                newPlayer.SetRotation(oldPlayerRotation);
                                newPlayer.transform.localScale = oldPlayerScale;
                            }
                            else if (newPlayerPosition == NewPlayerPosition.ReplaceNPC || newPlayerPosition == NewPlayerPosition.ReplaceAssociatedNPC)
                            {
                                if (runtimeNewPlayerNPC != null)
                                {
                                    newPlayer.RepositionToTransform(runtimeNewPlayerNPC.transform);
                                    runtimeNewPlayerNPC.HideFromView(newPlayer);

                                    if (recordedOldNPCData)
                                    {
                                        ApplyRenderData(newPlayer, oldNPCData);
                                    }
                                }
                            }
                            else if (newPlayerPosition == NewPlayerPosition.AppearAtMarker)
                            {
                                if (runtimeNewPlayerMarker)
                                {
                                    newPlayer.RepositionToTransform(runtimeNewPlayerMarker.transform);
                                }
                            }
                            else if (newPlayerPosition == NewPlayerPosition.AppearInOtherScene)
                            {
                                if (chooseNewSceneBy == ChooseSceneBy.Name && newPlayerSceneName == UnityVersionHandler.GetCurrentSceneName() ||
                                    (chooseNewSceneBy == ChooseSceneBy.Number && newPlayerScene == UnityVersionHandler.GetCurrentSceneNumber()))
                                {
                                    // Already in correct scene
                                    if (runtimeNewPlayerNPC && runtimeNewPlayerNPC.gameObject.activeInHierarchy)
                                    {
                                        newPlayer.RepositionToTransform(runtimeNewPlayerNPC.transform);
                                        runtimeNewPlayerNPC.HideFromView(newPlayer);
                                    }
                                }
                                else
                                {
                                    KickStarter.sceneChanger.ChangeScene(new SceneInfo(chooseNewSceneBy, newPlayerSceneName, newPlayerScene), true, false, true);
                                }
                            }
                        }

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

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

            return(0f);
        }
Exemple #2
0
        private void ReturnPlayerData(PlayerData playerData, Player player)
        {
            if (player == null)
            {
                return;
            }

            player.Teleport (new Vector3 (playerData.playerLocX, playerData.playerLocY, playerData.playerLocZ));
            player.SetRotation (playerData.playerRotY);
            //player.SetLookDirection (Vector3.zero, true);

            player.walkSpeedScale = playerData.playerWalkSpeed;
            player.runSpeedScale = playerData.playerRunSpeed;

            // Animation clips
            if (player.animationEngine == AnimationEngine.Sprites2DToolkit || player.animationEngine == AnimationEngine.SpritesUnity)
            {
                player.idleAnimSprite = playerData.playerIdleAnim;
                player.walkAnimSprite = playerData.playerWalkAnim;
                player.talkAnimSprite = playerData.playerTalkAnim;
                player.runAnimSprite = playerData.playerRunAnim;
            }
            else if (player.animationEngine == AnimationEngine.Legacy)
            {
                player.idleAnim = AssetLoader.RetrieveAsset <AnimationClip> (player.idleAnim, playerData.playerIdleAnim);
                player.walkAnim = AssetLoader.RetrieveAsset <AnimationClip> (player.walkAnim, playerData.playerWalkAnim);
                player.talkAnim = AssetLoader.RetrieveAsset <AnimationClip> (player.talkAnim, playerData.playerTalkAnim);
                player.runAnim = AssetLoader.RetrieveAsset <AnimationClip> (player.runAnim, playerData.playerRunAnim);
            }
            else if (player.animationEngine == AnimationEngine.Mecanim)
            {
                player.moveSpeedParameter = playerData.playerWalkAnim;
                player.talkParameter = playerData.playerTalkAnim;
                player.turnParameter = playerData.playerRunAnim;
            }

            // Sound
            player.walkSound = AssetLoader.RetrieveAsset (player.walkSound, playerData.playerWalkSound);
            player.runSound = AssetLoader.RetrieveAsset (player.runSound, playerData.playerRunSound);

            // Portrait graphic
            player.portraitIcon.texture = AssetLoader.RetrieveAsset (player.portraitIcon.texture, playerData.playerPortraitGraphic);
            player.speechLabel = playerData.playerSpeechLabel;

            // Rendering
            player.lockDirection = playerData.playerLockDirection;
            player.lockScale = playerData.playerLockScale;
            if (player.spriteChild && player.spriteChild.GetComponent <FollowSortingMap>())
            {
                player.spriteChild.GetComponent <FollowSortingMap>().lockSorting = playerData.playerLockSorting;
            }
            else if (player.GetComponent <FollowSortingMap>())
            {
                player.GetComponent <FollowSortingMap>().lockSorting = playerData.playerLockSorting;
            }
            else
            {
                player.ReleaseSorting ();
            }

            if (playerData.playerLockDirection)
            {
                player.spriteDirection = playerData.playerSpriteDirection;
            }
            if (playerData.playerLockScale)
            {
                player.spriteScale = playerData.playerSpriteScale;
            }
            if (playerData.playerLockSorting)
            {
                if (player.spriteChild && player.spriteChild.GetComponent <Renderer>())
                {
                    player.spriteChild.GetComponent <Renderer>().sortingOrder = playerData.playerSortingOrder;
                    player.spriteChild.GetComponent <Renderer>().sortingLayerName = playerData.playerSortingLayer;
                }
                else if (player.GetComponent <Renderer>())
                {
                    player.GetComponent <Renderer>().sortingOrder = playerData.playerSortingOrder;
                    player.GetComponent <Renderer>().sortingLayerName = playerData.playerSortingLayer;
                }
            }

            // Active path
            player.Halt ();
            player.ForceIdle ();

            if (playerData.playerPathData != null && playerData.playerPathData != "" && player.GetComponent <Paths>())
            {
                Paths savedPath = player.GetComponent <Paths>();
                savedPath = Serializer.RestorePathData (savedPath, playerData.playerPathData);
                player.SetPath (savedPath, playerData.playerTargetNode, playerData.playerPrevNode, playerData.playerPathAffectY);
                player.isRunning = playerData.playerIsRunning;
                player.lockedPath = false;
            }
            else if (playerData.playerActivePath != 0)
            {
                Paths savedPath = Serializer.returnComponent <Paths> (playerData.playerActivePath);
                if (savedPath)
                {
                    player.lockedPath = playerData.playerLockedPath;

                    if (player.lockedPath)
                    {
                        player.SetLockedPath (savedPath);
                    }
                    else
                    {
                        player.SetPath (savedPath, playerData.playerTargetNode, playerData.playerPrevNode);
                    }
                }
            }

            // Previous path
            if (playerData.lastPlayerActivePath != 0)
            {
                Paths savedPath = Serializer.returnComponent <Paths> (playerData.lastPlayerActivePath);
                if (savedPath)
                {
                    player.SetLastPath (savedPath, playerData.lastPlayerTargetNode, playerData.lastPlayerPrevNode);
                }
            }

            // Head target
            player.lockHotspotHeadTurning = playerData.playerLockHotspotHeadTurning;
            if (playerData.isHeadTurning)
            {
                player.SetHeadTurnTarget (new Vector3 (playerData.headTargetX, playerData.headTargetY, playerData.headTargetZ), true);
            }
            else
            {
                player.ClearHeadTurnTarget (true);
            }

            player.ignoreGravity = playerData.playerIgnoreGravity;
        }
Exemple #3
0
        override public float Run()
        {
            if (KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
            {
                if (KickStarter.sceneChanger.GetSubScenes().Length > 0)
                {
                    //	ACDebug.LogWarning ("Cannot switch players while multiple scenes are open!");
                    //	return 0f;
                }

                if (KickStarter.settingsManager.players.Count > 0 && KickStarter.settingsManager.players.Count > playerNumber && playerNumber > -1)
                {
                    if (KickStarter.player != null && KickStarter.player.ID == playerID)
                    {
                        ACDebug.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, keepInventory);
                        Player newPlayer = KickStarter.player;
                        PlayerMenus.ResetInventoryBoxes();

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

                            if (sceneToLoad != UnityVersionHandler.GetCurrentSceneNumber())
                            {
                                KickStarter.saveSystem.loadingGame = LoadingGame.JustSwitchingPlayer;
                                KickStarter.sceneChanger.ChangeScene(new SceneInfo("", 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 == UnityVersionHandler.GetCurrentSceneName())
                                {
                                }
                                else if (chooseNewSceneBy == ChooseSceneBy.Number && newPlayerScene == UnityVersionHandler.GetCurrentSceneNumber())
                                {
                                }
                                else
                                {
                                    KickStarter.sceneChanger.ChangeScene(new SceneInfo(chooseNewSceneBy, newPlayerSceneName, newPlayerScene), true);
                                }
                            }
                        }

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

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

            return(0f);
        }
        override public float Run()
        {
            if (KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
            {
                if (KickStarter.sceneChanger.GetSubScenes().Length > 0)
                {
                    //	ACDebug.LogWarning ("Cannot switch players while multiple scenes are open!");
                    //	return 0f;
                }

                if (KickStarter.settingsManager.players.Count > 0 && KickStarter.settingsManager.players.Count > playerNumber && playerNumber > -1)
                {
                    if (KickStarter.player != null && KickStarter.player.ID == playerID)
                    {
                        ACDebug.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.TransformRotation;
                            oldPlayerScale    = KickStarter.player.transform.localScale;
                        }

                        if (newPlayerPosition != NewPlayerPosition.ReplaceCurrentPlayer)
                        {
                            if (oldPlayer == OldPlayer.ReplaceWithAssociatedNPC && (oldPlayerNPC == null || !oldPlayerNPC.gameObject.activeInHierarchy) && KickStarter.player.associatedNPCPrefab != null)
                            {
                                GameObject newObject = (GameObject)Instantiate(KickStarter.player.associatedNPCPrefab.gameObject);
                                newObject.name = KickStarter.player.associatedNPCPrefab.gameObject.name;
                                oldPlayerNPC   = newObject.GetComponent <NPC>();
                            }

                            if ((oldPlayer == OldPlayer.ReplaceWithNPC || oldPlayer == OldPlayer.ReplaceWithAssociatedNPC) &&
                                oldPlayerNPC != null && oldPlayerNPC.gameObject.activeInHierarchy)
                            {
                                oldPlayerNPC.transform.position   = oldPlayerPosition;
                                oldPlayerNPC.TransformRotation    = oldPlayerRotation;
                                oldPlayerNPC.transform.localScale = oldPlayerScale;

                                // Force the rotation / sprite child to update
                                oldPlayerNPC._Update();
                            }
                        }

                        if (newPlayerNPC == null || newPlayerPosition == NewPlayerPosition.ReplaceAssociatedNPC)
                        {
                            // Try to find from associated NPC prefab

                            if (KickStarter.settingsManager.players[playerNumber].playerOb.associatedNPCPrefab != null)
                            {
                                ConstantID prefabID = KickStarter.settingsManager.players[playerNumber].playerOb.associatedNPCPrefab.GetComponent <ConstantID>();
                                if (prefabID != null && prefabID.constantID != 0)
                                {
                                    newPlayerNPC_ID = prefabID.constantID;
                                    newPlayerNPC    = AssignFile <NPC> (prefabID.constantID, null);
                                }
                            }
                        }

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

                        bool replacesOldPlayer = newPlayerPosition == NewPlayerPosition.ReplaceCurrentPlayer &&
                                                 (!restorePreviousData || !KickStarter.saveSystem.DoesPlayerDataExist(playerID, true));

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

                        if (restorePreviousData && KickStarter.saveSystem.DoesPlayerDataExist(playerID, true))
                        {
                            if (newPlayerNPC)
                            {
                                newPlayerNPC.transform.position += new Vector3(100f, -100f, 100f);
                            }

                            int sceneToLoad = KickStarter.saveSystem.GetPlayerScene(playerID);
                            if (sceneToLoad >= 0 && sceneToLoad != UnityVersionHandler.GetCurrentSceneNumber())
                            {
                                KickStarter.saveSystem.loadingGame = LoadingGame.JustSwitchingPlayer;
                                KickStarter.sceneChanger.ChangeScene(new SceneInfo("", sceneToLoad), true, false, newPlayerNPC_ID);
                            }
                            else
                            {
                                string sceneToLoadName = KickStarter.saveSystem.GetPlayerSceneName(playerID);
                                if (sceneToLoadName != "" && sceneToLoadName != UnityVersionHandler.GetCurrentSceneName())
                                {
                                    KickStarter.saveSystem.loadingGame = LoadingGame.JustSwitchingPlayer;
                                    KickStarter.sceneChanger.ChangeScene(new SceneInfo(sceneToLoadName, -1), true, false, newPlayerNPC_ID);
                                }
                            }
                        }
                        else
                        {
                            // No data to restore

                            if (newPlayerPosition == NewPlayerPosition.ReplaceCurrentPlayer)
                            {
                                newPlayer.Teleport(oldPlayerPosition);
                                newPlayer.SetRotation(oldPlayerRotation);
                                newPlayer.transform.localScale = oldPlayerScale;
                            }
                            else if (newPlayerPosition == NewPlayerPosition.ReplaceNPC || newPlayerPosition == NewPlayerPosition.ReplaceAssociatedNPC)
                            {
                                if (newPlayerNPC)
                                {
                                    newPlayer.Teleport(newPlayerNPC.transform.position);
                                    newPlayer.SetRotation(newPlayerNPC.TransformRotation);
                                    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 == UnityVersionHandler.GetCurrentSceneName() ||
                                    (chooseNewSceneBy == ChooseSceneBy.Number && newPlayerScene == UnityVersionHandler.GetCurrentSceneNumber()))
                                {
                                    // Already in correct scene
                                    if (newPlayerNPC && newPlayerNPC.gameObject.activeInHierarchy)
                                    {
                                        newPlayer.Teleport(newPlayerNPC.transform.position);
                                        newPlayer.SetRotation(newPlayerNPC.TransformRotation);
                                        newPlayer.transform.localScale = newPlayerNPC.transform.localScale;

                                        newPlayerNPC.transform.position += new Vector3(100f, -100f, 100f);
                                    }
                                }
                                else
                                {
                                    if (newPlayerNPC && newPlayerNPC.gameObject.activeInHierarchy)
                                    {
                                        newPlayerNPC.transform.position += new Vector3(100f, -100f, 100f);
                                    }

                                    //KickStarter.saveSystem.loadingGame = LoadingGame.JustSwitchingPlayer;
                                    KickStarter.sceneChanger.ChangeScene(new SceneInfo(chooseNewSceneBy, newPlayerSceneName, newPlayerScene), true, false, newPlayerNPC_ID, true);
                                }
                            }
                        }

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

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

            return(0f);
        }