Ejemplo n.º 1
0
        private static void Callback(object obj)
        {
            if (sidePlayerPrefab >= 0)
            {
                switch (obj.ToString())
                {
                case "Delete":
                    Undo.RecordObject(KickStarter.settingsManager, "Delete player reference");
                    KickStarter.settingsManager.players.RemoveAt(sidePlayerPrefab);
                    break;

                case "SetAsDefault":
                    for (int i = 0; i < KickStarter.settingsManager.players.Count; i++)
                    {
                        KickStarter.settingsManager.players[i].isDefault = (i == sidePlayerPrefab);
                    }
                    break;

                case "EditStartData":
                    PlayerStartDataEditor.CreateNew(sidePlayerPrefab);
                    break;

                case "FindReferences":
                    PlayerPrefab playerPrefab = KickStarter.settingsManager.players[sidePlayerPrefab];
                    FindPlayerReferences(playerPrefab.ID, (playerPrefab != null) ? playerPrefab.playerOb.GetName() : "(Unnamed)");
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        /** Updates the Player's presence in the scene. According to the data set in this class, they will be added to or removed from the scene. */
        public void UpdatePresenceInScene()
        {
            PlayerPrefab playerPrefab = KickStarter.settingsManager.GetPlayerPrefab(playerID);

            if (playerPrefab != null)
            {
                if (KickStarter.saveSystem.CurrentPlayerID == playerID)
                {
                    playerPrefab.SpawnInScene(false);
                }
                else if (SceneChanger.CurrentSceneIndex == currentScene)
                {
                    playerPrefab.SpawnInScene(false);
                }
                else
                {
                    SubScene subScene = KickStarter.sceneChanger.GetSubScene(currentScene);
                    if (subScene != null)
                    {
                        playerPrefab.SpawnInScene(subScene.gameObject.scene);
                    }
                    else
                    {
                        playerPrefab.RemoveFromScene();
                    }
                }
            }
        }
        public override string SetLabel()
        {
            if (playerIDParameterID >= 0)
            {
                return(string.Empty);
            }

            if (settingsManager == null)
            {
                settingsManager = AdvGame.GetReferences().settingsManager;
            }

            if (settingsManager != null && settingsManager.playerSwitching == PlayerSwitching.Allow)
            {
                PlayerPrefab newPlayerPrefab = settingsManager.GetPlayerPrefab(playerID);
                if (newPlayerPrefab != null)
                {
                    if (newPlayerPrefab.playerOb != null)
                    {
                        return(newPlayerPrefab.playerOb.name);
                    }
                    else
                    {
                        return("Undefined prefab");
                    }
                }
            }

            return(string.Empty);
        }
Ejemplo n.º 4
0
        public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
        {
            foreach (TimelineClip timelineClip in GetClips())
            {
                SpeechPlayableClip clip = (SpeechPlayableClip)timelineClip.asset;
                timelineClip.displayName = clip.GetDisplayName();

                Char speaker = null;
                if (Application.isPlaying)
                {
                    if (isPlayerLine)
                    {
                        speaker = AssignPlayer(playerID);
                    }
                    else if (speakerConstantID != 0)
                    {
                        speaker = ConstantID.GetComponent <Char> (speakerConstantID);
                    }
                }
                else
                {
                    if (isPlayerLine)
                    {
                        if (KickStarter.settingsManager != null)
                        {
                            if (KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow && playerID >= 0)
                            {
                                PlayerPrefab playerPrefab = KickStarter.settingsManager.GetPlayerPrefab(playerID);
                                if (playerPrefab != null)
                                {
                                    speaker = playerPrefab.playerOb;
                                }
                            }
                            else
                            {
                                speaker = KickStarter.settingsManager.GetDefaultPlayer(false);
                            }
                        }
                    }
                    else
                    {
                        speaker = SpeakerPrefab;
                    }
                }

                clip.speechTrackPlaybackMode = playbackMode;
                clip.speaker         = speaker;
                clip.trackInstanceID = GetInstanceID();
            }

            ScriptPlayable <SpeechPlayableMixer> mixer = ScriptPlayable <SpeechPlayableMixer> .Create(graph);

            mixer.SetInputCount(inputCount);
            mixer.GetBehaviour().trackInstanceID = GetInstanceID();
            mixer.GetBehaviour().playbackMode    = playbackMode;
            return(mixer);
        }
Ejemplo n.º 5
0
        public virtual string GetOwner(int index)
        {
            bool _isPlayer = isPlayer;

            if (!_isPlayer && speaker != null && speaker.IsPlayer)
            {
                _isPlayer = true;
            }

            if (_isPlayer)
            {
                if (isPlayer && KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
                {
                    if (parameterID < 0 && playerID >= 0)
                    {
                        PlayerPrefab playerPrefab = KickStarter.settingsManager.GetPlayerPrefab(playerID);
                        if (playerPrefab != null && playerPrefab.playerOb != null)
                        {
                            return(playerPrefab.playerOb.name);
                        }
                    }
                }
                else if (isPlayer && KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.DoNotAllow && KickStarter.settingsManager.player)
                {
                    return(KickStarter.settingsManager.player.name);
                }
                else if (!isPlayer && speaker != null)
                {
                    return(speaker.name);
                }

                return("Player");
            }
            else
            {
                if (isAssetFile)
                {
                    if (!isPlayer && parameterID == -1)
                    {
                        speaker = IDToField <Char> (speaker, constantID, false);
                    }
                }

                if (speaker)
                {
                    return(speaker.name);
                }
                else
                {
                    return("Narrator");
                }
            }
        }
Ejemplo n.º 6
0
        private void OnGUI()
        {
            if (KickStarter.settingsManager == null)
            {
                return;
            }

            if (playerIndex >= 0 && playerIndex < KickStarter.settingsManager.players.Count)
            {
                PlayerPrefab playerPrefab = KickStarter.settingsManager.players[playerIndex];

                playerPrefab.ShowStartDataGUI("AC.KickStarter.players[" + playerIndex.ToString() + "]");
            }
        }
Ejemplo n.º 7
0
 private void SetDefaultPlayer(PlayerPrefab defaultPlayer)
 {
     foreach (PlayerPrefab _player in players)
     {
         if (_player == defaultPlayer)
         {
             _player.isDefault = true;
         }
         else
         {
             _player.isDefault = false;
         }
     }
 }
Ejemplo n.º 8
0
        private void CreatePlayersGUI()
        {
            playerSwitching = (PlayerSwitching)EditorGUILayout.EnumPopup("Player switching:", playerSwitching);
            if (playerSwitching == PlayerSwitching.DoNotAllow)
            {
                player = (Player)EditorGUILayout.ObjectField("Player:", player, typeof(Player), false);
            }
            else
            {
                shareInventory = EditorGUILayout.Toggle("Share same Inventory?", shareInventory);

                foreach (PlayerPrefab _player in players)
                {
                    EditorGUILayout.BeginHorizontal();

                    _player.playerOb = (Player)EditorGUILayout.ObjectField("Player " + _player.ID + ":", _player.playerOb, typeof(Player), false);

                    if (_player.isDefault)
                    {
                        GUILayout.Label("DEFAULT", EditorStyles.boldLabel, GUILayout.Width(80f));
                    }
                    else
                    {
                        if (GUILayout.Button("Make default", GUILayout.Width(80f)))
                        {
                            SetDefaultPlayer(_player);
                        }
                    }

                    if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth))
                    {
                        Undo.RecordObject(this, "Delete player reference");
                        players.Remove(_player);
                        break;
                    }

                    EditorGUILayout.EndHorizontal();
                }

                if (GUILayout.Button("Add new player"))
                {
                    Undo.RecordObject(this, "Add player");

                    PlayerPrefab newPlayer = new PlayerPrefab(GetPlayerIDArray());
                    players.Add(newPlayer);
                }
            }
        }
Ejemplo n.º 9
0
        public string GetOwner(int index)
        {
            bool _isPlayer = isPlayerLine;

            if (!_isPlayer && SpeakerPrefab != null && SpeakerPrefab.IsPlayer)
            {
                _isPlayer = true;
            }

            if (_isPlayer)
            {
                if (isPlayerLine && KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
                {
                    if (playerID >= 0)
                    {
                        PlayerPrefab playerPrefab = KickStarter.settingsManager.GetPlayerPrefab(playerID);
                        if (playerPrefab != null && playerPrefab.playerOb != null)
                        {
                            return(playerPrefab.playerOb.name);
                        }
                    }
                }
                else if (isPlayerLine && KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.DoNotAllow && KickStarter.settingsManager.player)
                {
                    return(KickStarter.settingsManager.player.name);
                }
                else if (!isPlayerLine && SpeakerPrefab != null)
                {
                    return(SpeakerPrefab.name);
                }

                return("Player");
            }
            else
            {
                if (SpeakerPrefab)
                {
                    return(SpeakerPrefab.name);
                }
                else
                {
                    return("Narrator");
                }
            }
        }
Ejemplo n.º 10
0
        private static void SideMenu(PlayerPrefab playerPrefab)
        {
            GenericMenu menu = new GenericMenu();

            sidePlayerPrefab = KickStarter.settingsManager.players.IndexOf(playerPrefab);

            if (!playerPrefab.isDefault)
            {
                menu.AddItem(new GUIContent("Set as default"), false, Callback, "SetAsDefault");
                menu.AddItem(new GUIContent("Edit start data..."), false, Callback, "EditStartData");
                menu.AddSeparator(string.Empty);
            }

            menu.AddItem(new GUIContent("Find references..."), false, Callback, "FindReferences");
            menu.AddItem(new GUIContent("Delete"), false, Callback, "Delete");

            menu.ShowAsContext();
        }
        public override string SetLabel()
        {
            if (KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
            {
                PlayerPrefab newPlayerPrefab = KickStarter.settingsManager.GetPlayerPrefab(playerID);
                if (newPlayerPrefab != null)
                {
                    if (newPlayerPrefab.playerOb != null)
                    {
                        return(newPlayerPrefab.playerOb.name);
                    }
                    else
                    {
                        return("Undefined prefab");
                    }
                }
            }

            return(string.Empty);
        }
Ejemplo n.º 12
0
 protected Player AssignPlayer(int _playerID)
 {
     if (KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow && _playerID >= 0)
     {
         PlayerPrefab playerPrefab = KickStarter.settingsManager.GetPlayerPrefab(_playerID);
         if (playerPrefab != null)
         {
             Player _player = playerPrefab.GetSceneInstance();
             if (_player == null)
             {
                 Debug.LogWarning("Cannot assign Player with ID = " + _playerID + " because they are not currently in the scene.");
             }
             return(_player);
         }
         else
         {
             Debug.LogWarning("No Player prefab found with ID = " + _playerID);
         }
         return(null);
     }
     return(KickStarter.player);
 }
Ejemplo n.º 13
0
        override public string SetLabel()
        {
            if (playerIDParameterID >= 0)
            {
                return(string.Empty);
            }

            if (settingsManager != null &&
                settingsManager.playerSwitching == PlayerSwitching.Allow)
            {
                PlayerPrefab playerPrefab = KickStarter.settingsManager.GetPlayerPrefab(playerID);
                if (playerPrefab != null && playerPrefab.playerOb != null)
                {
                    return(playerPrefab.playerOb.name);
                }
                else
                {
                    return("Undefined prefab");
                }
            }

            return(string.Empty);
        }
Ejemplo n.º 14
0
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            isPlayer = EditorGUILayout.Toggle("Is Player?", isPlayer);
            if (isPlayer)
            {
                if (KickStarter.settingsManager && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
                {
                    parameterID = ChooseParameterGUI("Player ID:", parameters, parameterID, ParameterType.Integer);
                    if (parameterID < 0)
                    {
                        playerID = ChoosePlayerGUI(playerID, true);
                    }
                }

                if (KickStarter.settingsManager && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
                {
                    if (parameterID < 0 && playerID >= 0)
                    {
                        PlayerPrefab playerPrefab = KickStarter.settingsManager.GetPlayerPrefab(playerID);
                        animChar = (playerPrefab != null) ? playerPrefab.playerOb : null;
                    }
                    else
                    {
                        animChar = KickStarter.settingsManager.GetDefaultPlayer();
                    }
                }
                else if (Application.isPlaying)
                {
                    animChar = KickStarter.player;
                }
                else if (AdvGame.GetReferences().settingsManager)
                {
                    animChar = AdvGame.GetReferences().settingsManager.GetDefaultPlayer();
                }
            }
            else
            {
                parameterID = Action.ChooseParameterGUI("Character:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID = 0;
                    animChar   = null;
                }
                else
                {
                    animChar = (Char)EditorGUILayout.ObjectField("Character:", animChar, typeof(Char), true);

                    constantID = FieldToID <Char> (animChar, constantID);
                    animChar   = IDToField <Char> (animChar, constantID, true);
                }
            }

            if (animChar)
            {
                ResetAnimationEngine(animChar.animationEngine, animChar.customAnimationClass);
            }

            if (editingAnimEngine != null)
            {
                editingAnimEngine.ActionCharAnimGUI(this, parameters);
            }
            else
            {
                EditorGUILayout.HelpBox("This Action requires a Character before more options will show.", MessageType.Info);
            }

            AfterRunningOption();
        }
Ejemplo n.º 15
0
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            isPlayer = EditorGUILayout.Toggle("Is player?", isPlayer);
            if (isPlayer)
            {
                if (KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
                {
                    playerParameterID = ChooseParameterGUI("Player ID:", parameters, playerParameterID, ParameterType.Integer);
                    if (playerParameterID < 0)
                    {
                        playerID = ChoosePlayerGUI(playerID, true);
                    }
                }

                Player _player = null;

                if (playerParameterID < 0 || KickStarter.settingsManager == null || KickStarter.settingsManager.playerSwitching == PlayerSwitching.DoNotAllow)
                {
                    if (playerID >= 0)
                    {
                        PlayerPrefab playerPrefab = KickStarter.settingsManager.GetPlayerPrefab(playerID);
                        if (playerPrefab != null)
                        {
                            _player = (Application.isPlaying) ? playerPrefab.GetSceneInstance() : playerPrefab.playerOb;
                        }
                    }
                    else
                    {
                        _player = (Application.isPlaying) ? KickStarter.player : AdvGame.GetReferences().settingsManager.GetDefaultPlayer();
                    }
                }

                if (_player != null && _player.GetShapeable())
                {
                    shapeObject = _player.GetShapeable();
                }
                else
                {
                    shapeObject = null;
                    EditorGUILayout.HelpBox("Cannot find player with Shapeable script attached", MessageType.Warning);
                }
            }
            else
            {
                parameterID = ChooseParameterGUI("Object:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID  = 0;
                    shapeObject = null;
                }
                else
                {
                    shapeObject = (Shapeable)EditorGUILayout.ObjectField("Object:", shapeObject, typeof(Shapeable), true);

                    constantID  = FieldToID <Shapeable> (shapeObject, constantID);
                    shapeObject = IDToField <Shapeable> (shapeObject, constantID, false);
                }
            }

            if (shapeObject != null && shapeObject.shapeGroups != null)
            {
                shapeGroupID   = ActionBlendShape.ShapeableGroupGUI("Shape group:", shapeObject.shapeGroups, shapeGroupID);
                disableAllKeys = EditorGUILayout.Toggle("Disable all keys?", disableAllKeys);
                if (!disableAllKeys)
                {
                    ShapeGroup _shapeGroup = shapeObject.GetGroup(shapeGroupID);
                    if (_shapeGroup != null)
                    {
                        if (_shapeGroup.shapeKeys != null && _shapeGroup.shapeKeys.Count > 0)
                        {
                            shapeKeyID = ShapeableKeyGUI(_shapeGroup.shapeKeys, shapeKeyID);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("No shape keys found.", MessageType.Info);
                        }
                    }
                    shapeValue = EditorGUILayout.Slider("New value:", shapeValue, 0f, 100f);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("An object must be assigned before more options can show.", MessageType.Info);
            }

            fadeTime = EditorGUILayout.FloatField("Transition time:", fadeTime);
            if (fadeTime > 0f)
            {
                moveMethod = (MoveMethod)EditorGUILayout.EnumPopup("Move method:", moveMethod);
                if (moveMethod == MoveMethod.CustomCurve)
                {
                    timeCurve = EditorGUILayout.CurveField("Time curve:", timeCurve);
                }
                willWait = EditorGUILayout.Toggle("Wait until finish?", willWait);
            }

            AfterRunningOption();
        }
Ejemplo n.º 16
0
        public override 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 character.");
                        return(0f);
                    }

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

                        if (takeOldPlayerPosition)
                        {
                            if (KickStarter.player != null)
                            {
                                if (keepInventory)
                                {
                                    KickStarter.saveSystem.AssignItemsToPlayer(KickStarter.runtimeInventory.PlayerInvCollection, playerID);
                                }

                                _Camera oldCamera = KickStarter.mainCamera.attachedCamera;
                                KickStarter.player.RemoveFromScene();

                                // Transfer open sub-scene data since both are in the same scene
                                PlayerData tempPlayerData = new PlayerData();
                                tempPlayerData = KickStarter.sceneChanger.SavePlayerData(tempPlayerData);
                                string     openSubSceneData = tempPlayerData.openSubScenes;
                                PlayerData newPlayerData    = KickStarter.saveSystem.GetPlayerData(playerID);
                                newPlayerData.openSubScenes = openSubSceneData;

                                // Force-set position / scene
                                PlayerData oldPlayerData = KickStarter.saveSystem.GetPlayerData(KickStarter.saveSystem.CurrentPlayerID);
                                newPlayerData.CopyPosition(oldPlayerData);
                                newPlayerData.UpdatePresenceInScene();
                                oldPlayerData.currentScene = -1;

                                Player newPlayer = newPlayerPrefab.GetSceneInstance(true);
                                KickStarter.player = newPlayer;

                                if (KickStarter.player != null)
                                {
                                    KickStarter.player.EndPath();
                                    KickStarter.player.StopFollowing();
                                }

                                // Same camera
                                if (oldCamera != null && KickStarter.mainCamera.attachedCamera != oldCamera)
                                {
                                    oldCamera.MoveCameraInstant();
                                    KickStarter.mainCamera.SetGameCamera(oldCamera);
                                }

                                return(0f);
                            }
                            else
                            {
                                LogWarning("Cannot take the old Player's position because no Player is currently active!");
                            }
                        }
                        else
                        {
                            if (KickStarter.player != null)
                            {
                                if (stopOldMoving || !KickStarter.player.IsPathfinding())
                                {
                                    KickStarter.player.EndPath();
                                }
                            }

                            if (keepInventory)
                            {
                                KickStarter.saveSystem.AssignItemsToPlayer(KickStarter.runtimeInventory.PlayerInvCollection, playerID);
                            }

                            int sceneIndexToLoad = KickStarter.saveSystem.GetPlayerSceneIndex(playerID);
                            if (sceneIndexToLoad < 0)
                            {
                                bool hasData = (KickStarter.saveSystem.GetPlayerData(playerID) != null);
                                if (hasData)
                                {
                                    LogWarning("Cannot switch to Player ID " + playerID + " because their current scene index = " + sceneIndexToLoad);
                                }
                                else
                                {
                                    LogWarning("Cannot switch to Player ID " + playerID + " because no save data was found for them.");
                                }
                                return(0f);
                            }

                            SubScene subScene = KickStarter.sceneChanger.GetSubScene(sceneIndexToLoad);
                            if (subScene == null && SceneChanger.CurrentSceneIndex != sceneIndexToLoad)
                            {
                                // Different scene, and not open as a sub-scene
                                if (KickStarter.player != null)
                                {
                                    KickStarter.player.Halt();
                                }

                                KickStarter.saveSystem.SwitchToPlayerInDifferentScene(playerID, sceneIndexToLoad, assignScreenOverlay);
                                return(0f);
                            }

                            // Same scene

                            // Transfer open sub-scene data since both are in the same scene
                            PlayerData tempPlayerData = new PlayerData();
                            tempPlayerData = KickStarter.sceneChanger.SavePlayerData(tempPlayerData);
                            string     openSubSceneData = tempPlayerData.openSubScenes;
                            PlayerData newPlayerData    = KickStarter.saveSystem.GetPlayerData(playerID);
                            newPlayerData.openSubScenes = openSubSceneData;

                            Player newPlayer = newPlayerPrefab.GetSceneInstance(true);
                            KickStarter.player = newPlayer;

                            if (stopNewMoving && KickStarter.player != null)
                            {
                                KickStarter.player.EndPath();
                                KickStarter.player.StopFollowing();
                            }

                            if (KickStarter.mainCamera.attachedCamera && alwaysSnapCamera)
                            {
                                KickStarter.mainCamera.attachedCamera.MoveCameraInstant();
                            }
                        }
                    }
                    else
                    {
                        LogWarning("Cannot switch to an empty Player - no Player prefab is defined for ID " + playerID + ".");
                    }
                }
                else
                {
                    LogWarning("Cannot switch Player - no Player prefab is defined.");
                }
            }

            return(0f);
        }
Ejemplo n.º 17
0
        /**
         * <summary>Deserialises a string of data, and restores the GameObject to its previous state.</summary>
         * <param name = "stringData">The data, serialised as a string</param>
         */
        public void LoadTransformData(TransformData data)
        {
            if (data == null)
            {
                return;
            }
            savePrevented = data.savePrevented; if (savePrevented)
            {
                return;
            }

            if (data.parentIsPlayer)
            {
                Player player = KickStarter.player;

                if (data.parentPlayerID >= 0)
                {
                    player = null;
                    PlayerPrefab playerPrefab = KickStarter.settingsManager.GetPlayerPrefab(data.parentPlayerID);
                    if (playerPrefab != null)
                    {
                        player = playerPrefab.GetSceneInstance();
                    }
                }

                if (player)
                {
                    if (data.heldHand == Hand.Left)
                    {
                        transform.parent = player.leftHandBone;
                    }
                    else
                    {
                        transform.parent = player.rightHandBone;
                    }
                }
            }
            else if (data.parentID != 0)
            {
                ConstantID parentObject = ConstantID.GetComponent <ConstantID> (data.parentID);

                if (parentObject)
                {
                    if (data.parentIsNPC)
                    {
                        Char _char = parentObject.GetComponent <NPC> ();
                        if (_char && !_char.IsPlayer)
                        {
                            if (data.heldHand == Hand.Left)
                            {
                                transform.parent = _char.leftHandBone;
                            }
                            else
                            {
                                transform.parent = _char.rightHandBone;
                            }
                        }
                    }
                    else
                    {
                        transform.parent = parentObject.gameObject.transform;
                    }
                }
            }
            else if (data.parentID == 0 && saveParent)
            {
                transform.parent = null;
            }

            switch (transformSpace)
            {
            case GlobalLocal.Global:
                transform.position    = new Vector3(data.LocX, data.LocY, data.LocZ);
                transform.eulerAngles = new Vector3(data.RotX, data.RotY, data.RotZ);
                break;

            case GlobalLocal.Local:
                transform.localPosition    = new Vector3(data.LocX, data.LocY, data.LocZ);
                transform.localEulerAngles = new Vector3(data.RotX, data.RotY, data.RotZ);
                break;
            }

            transform.localScale = new Vector3(data.ScaleX, data.ScaleY, data.ScaleZ);
        }
Ejemplo n.º 18
0
        public static void PreparePlayer()
        {
            saveSystem.SpawnAllPlayers();

            Player[] localPlayers = FindObjectsOfType <Player> ();

            if (settingsManager.playerSwitching == PlayerSwitching.Allow)
            {
                // Local players are ignored
                foreach (Player localPlayer in localPlayers)
                {
                    if (localPlayer.ID <= -1)
                    {
                        ACDebug.LogWarning("Local Player " + localPlayer.GetName() + " found in scene " + localPlayer.gameObject.scene.name + ". This is not allowed when Player Switching is enabled - in this mode, Players can only be spawned in.", localPlayer);
                    }
                }

                PlayerPrefab playerPrefab = settingsManager.GetPlayerPrefab(saveSystem.CurrentPlayerID);
                if (playerPrefab != null)
                {
                    playerPrefab.SpawnInScene(true);
                }
            }
            else
            {
                // Local players take priority
                foreach (Player localPlayer in localPlayers)
                {
                    if (localPlayer.ID == -1)
                    {
                        localPlayer.ID = -2 - SceneChanger.CurrentSceneIndex;                         // Always unique to the scene
                        player         = localPlayer;
                        return;
                    }
                }

                foreach (Player localPlayer in localPlayers)
                {
                    if (localPlayer.ID == 0)
                    {
                        player = localPlayer;
                        return;
                    }
                }

                if (settingsManager.GetDefaultPlayer() != null)
                {
                    player = settingsManager.GetDefaultPlayer().SpawnFromPrefab(0);
                }
            }

            if (player == null && settingsManager.movementMethod != MovementMethod.None)
            {
                ACDebug.LogWarning("No Player found - this can be assigned in the Settings Manager.");
            }

            if (player)
            {
                player.EndPath();
                player.Halt(false);
            }

            KickStarter.saveSystem.SpawnFollowingPlayers();
        }
Ejemplo n.º 19
0
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            isPlayer = EditorGUILayout.Toggle("Is Player?", isPlayer);
            if (isPlayer)
            {
                if (KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
                {
                    playerParameterID = ChooseParameterGUI("Player ID:", parameters, playerParameterID, ParameterType.Integer);
                    if (playerParameterID < 0)
                    {
                        playerID = ChoosePlayerGUI(playerID, true);
                    }
                }

                if (playerParameterID < 0)
                {
                    if (playerID >= 0)
                    {
                        PlayerPrefab playerPrefab = KickStarter.settingsManager.GetPlayerPrefab(playerID);
                        if (playerPrefab != null)
                        {
                            _char = (Application.isPlaying) ? playerPrefab.GetSceneInstance() : playerPrefab.playerOb;
                        }
                    }
                    else
                    {
                        _char = (Application.isPlaying) ? KickStarter.player : AdvGame.GetReferences().settingsManager.GetDefaultPlayer();
                    }
                }
            }
            else
            {
                _char = (Char)EditorGUILayout.ObjectField("Character:", _char, typeof(Char), true);

                _charID = FieldToID <Char> (_char, _charID);
                _char   = IDToField <Char> (_char, _charID, true);
            }

            if (_char != null)
            {
                if (_char.GetAnimEngine() && _char.GetAnimEngine().ActionCharHoldPossible())
                {
                    if (_char.GetAnimEngine().IKEnabled)
                    {
                        charHoldMethod = (CharHoldMethod)EditorGUILayout.EnumPopup("Hold method:", charHoldMethod);
                        if (charHoldMethod == CharHoldMethod.MoveHandWithIK)
                        {
                            ikHoldMethod = (IKHoldMethod)EditorGUILayout.EnumPopup("IK command:", ikHoldMethod);
                        }
                    }
                    else
                    {
                        charHoldMethod = CharHoldMethod.ParentObjectToHand;
                    }

                    if (charHoldMethod == CharHoldMethod.ParentObjectToHand || ikHoldMethod == IKHoldMethod.SetTarget)
                    {
                        objectToHoldParameterID = Action.ChooseParameterGUI("Object to hold:", parameters, objectToHoldParameterID, ParameterType.GameObject);
                        if (objectToHoldParameterID >= 0)
                        {
                            objectToHoldID = 0;
                            objectToHold   = null;
                        }
                        else
                        {
                            objectToHold = (GameObject)EditorGUILayout.ObjectField("Object to hold:", objectToHold, typeof(GameObject), true);

                            objectToHoldID = FieldToID(objectToHold, objectToHoldID);
                            objectToHold   = IDToField(objectToHold, objectToHoldID, false);
                        }
                    }

                    hand = (Hand)EditorGUILayout.EnumPopup("Hand:", hand);

                    if (charHoldMethod == CharHoldMethod.ParentObjectToHand)
                    {
                        localEulerAnglesParameterID = Action.ChooseParameterGUI("Object local angles:", parameters, localEulerAnglesParameterID, ParameterType.Vector3);
                        if (localEulerAnglesParameterID < 0)
                        {
                            localEulerAngles = EditorGUILayout.Vector3Field("Object local angles:", localEulerAngles);
                        }
                    }
                    else if (charHoldMethod == CharHoldMethod.MoveHandWithIK && ikHoldMethod == IKHoldMethod.SetTarget)
                    {
                        ikTransitionCurve = EditorGUILayout.CurveField("Transition curve:", ikTransitionCurve);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("This Action is not compatible with this Character's Animation Engine.", MessageType.Info);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("This Action requires a Character before more options will show.", MessageType.Info);
            }

            AfterRunningOption();
        }
Ejemplo n.º 20
0
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            if (lineID > -1)
            {
                if (multiLineIDs != null && multiLineIDs.Length > 0 && AdvGame.GetReferences().speechManager != null && AdvGame.GetReferences().speechManager.separateLines)
                {
                    string IDs = lineID.ToString();
                    foreach (int multiLineID in multiLineIDs)
                    {
                        IDs += ", " + multiLineID;
                    }

                    EditorGUILayout.LabelField("Speech Manager IDs:", IDs);
                }
                else
                {
                    EditorGUILayout.LabelField("Speech Manager ID:", lineID.ToString());
                }
            }

            if (Application.isPlaying && runtimeSpeaker == null)
            {
                AssignValues(parameters);
            }

            isPlayer = EditorGUILayout.Toggle("Player line?", isPlayer);
            if (isPlayer)
            {
                if (KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
                {
                    parameterID = ChooseParameterGUI("Player ID:", parameters, parameterID, ParameterType.Integer);
                    if (parameterID < 0)
                    {
                        playerID = ChoosePlayerGUI(playerID, true);
                    }
                }
            }
            else
            {
                if (Application.isPlaying)
                {
                    if (runtimeSpeaker)
                    {
                        EditorGUILayout.LabelField("Speaker: " + runtimeSpeaker.name);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("The speaker cannot be assigned while the game is running.", MessageType.Info);
                    }
                }
                else
                {
                    parameterID = Action.ChooseParameterGUI("Speaker:", parameters, parameterID, ParameterType.GameObject);
                    if (parameterID >= 0)
                    {
                        constantID = 0;
                        speaker    = null;
                    }
                    else
                    {
                        speaker = (Char)EditorGUILayout.ObjectField("Speaker:", speaker, typeof(Char), true);

                        constantID = FieldToID <Char> (speaker, constantID);
                        speaker    = IDToField <Char> (speaker, constantID, false);
                    }
                }
            }

            messageParameterID = Action.ChooseParameterGUI("Line text:", parameters, messageParameterID, ParameterType.String);
            if (messageParameterID < 0)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Line text:", GUILayout.Width(65f));
                EditorStyles.textField.wordWrap = true;
                messageText = EditorGUILayout.TextArea(messageText, GUILayout.MaxWidth(400f));
                EditorGUILayout.EndHorizontal();
            }

            Char _speaker = null;

            if (isPlayer)
            {
                if (KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
                {
                    if (parameterID < 0 && playerID >= 0)
                    {
                        PlayerPrefab playerPrefab = KickStarter.settingsManager.GetPlayerPrefab(playerID);
                        _speaker = (playerPrefab != null) ? playerPrefab.playerOb : null;
                    }
                    else
                    {
                        _speaker = KickStarter.settingsManager.GetDefaultPlayer();
                    }
                }
                else if (Application.isPlaying)
                {
                    _speaker = KickStarter.player;
                }
                else if (AdvGame.GetReferences().settingsManager)
                {
                    _speaker = AdvGame.GetReferences().settingsManager.GetDefaultPlayer();
                }
            }
            else
            {
                _speaker = (Application.isPlaying) ? runtimeSpeaker : speaker;
            }

            if (_speaker != null)
            {
                noAnimation = EditorGUILayout.Toggle("Don't animate speaker?", noAnimation);
                if (!noAnimation)
                {
                    if (_speaker.GetAnimEngine())
                    {
                        _speaker.GetAnimEngine().ActionSpeechGUI(this, _speaker);
                    }
                }
            }
            else if (!isPlayer && parameterID < 0)
            {
                EditorGUILayout.HelpBox("If no Character is set, this line\nwill be considered to be a Narration.", MessageType.Info);
            }

            isBackground = EditorGUILayout.Toggle("Play in background?", isBackground);
            if (!isBackground)
            {
                waitTimeOffset = EditorGUILayout.Slider("Wait time offset (s):", waitTimeOffset, 0f, 4f);
            }

            AfterRunningOption();
        }
Ejemplo n.º 21
0
        /**
         * Ends all skippable ActionLists.
         * This is triggered when the user presses the "EndCutscene" Input button.
         */
        public void EndCutscene()
        {
            if (!IsInSkippableCutscene())
            {
                return;
            }

            if (AdvGame.GetReferences().settingsManager.blackOutWhenSkipping)
            {
                KickStarter.mainCamera.ForceOverlayForFrames(4);
            }

            KickStarter.eventManager.Call_OnSkipCutscene();

            // Stop all non-looping sound
            Sound[] sounds = FindObjectsOfType(typeof(Sound)) as Sound[];
            foreach (Sound sound in sounds)
            {
                if (sound.GetComponent <AudioSource>())
                {
                    if (sound.soundType != SoundType.Music && !sound.GetComponent <AudioSource>().loop)
                    {
                        sound.Stop();
                    }
                }
            }

            // Set correct Player prefab before skipping
            if (KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
            {
                if (!noPlayerOnStartQueue && playerIDOnStartQueue >= 0)
                {
                    if (KickStarter.player == null || KickStarter.player.ID != playerIDOnStartQueue)
                    {
                        //
                        PlayerPrefab oldPlayerPrefab = KickStarter.settingsManager.GetPlayerPrefab(playerIDOnStartQueue);
                        if (oldPlayerPrefab != null)
                        {
                            if (KickStarter.player != null)
                            {
                                KickStarter.player.Halt();
                            }

                            Player oldPlayer = oldPlayerPrefab.GetSceneInstance();
                            KickStarter.player = oldPlayer;
                        }
                    }
                }
            }

            List <ActiveList> listsToSkip  = new List <ActiveList>();
            List <ActiveList> listsToReset = new List <ActiveList>();

            foreach (ActiveList activeList in activeLists)
            {
                if (!activeList.inSkipQueue && activeList.actionList.IsSkippable())
                {
                    listsToReset.Add(activeList);
                }
                else
                {
                    listsToSkip.Add(activeList);
                }
            }

            foreach (ActiveList activeList in KickStarter.actionListAssetManager.ActiveLists)
            {
                if (!activeList.inSkipQueue && activeList.actionList.IsSkippable())
                {
                    listsToReset.Add(activeList);
                }
                else
                {
                    listsToSkip.Add(activeList);
                }
            }

            foreach (ActiveList listToReset in listsToReset)
            {
                // Kill, but do isolated, to bypass setting GameState etc
                listToReset.Reset(true);
            }

            foreach (ActiveList listToSkip in listsToSkip)
            {
                listToSkip.Skip();
            }
        }
Ejemplo n.º 22
0
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            isPlayer = EditorGUILayout.Toggle("Is Player?", isPlayer);
            if (isPlayer)
            {
                if (KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
                {
                    parameterID = ChooseParameterGUI("Player ID:", parameters, parameterID, ParameterType.Integer);
                    if (parameterID < 0)
                    {
                        playerID = ChoosePlayerGUI(playerID, true);
                    }
                }

                if (KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
                {
                    if (parameterID < 0 && playerID >= 0)
                    {
                        PlayerPrefab playerPrefab = KickStarter.settingsManager.GetPlayerPrefab(playerID);
                        _char = (playerPrefab != null) ? playerPrefab.playerOb : null;
                    }
                    else
                    {
                        _char = KickStarter.settingsManager.GetDefaultPlayer();
                    }
                }
                else if (Application.isPlaying)
                {
                    _char = KickStarter.player;
                }
                else
                {
                    _char = KickStarter.settingsManager.GetDefaultPlayer();
                }
            }
            else
            {
                parameterID = Action.ChooseParameterGUI("Character:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID = 0;
                    _char      = null;
                }
                else
                {
                    _char = (Char)EditorGUILayout.ObjectField("Character:", _char, typeof(Char), true);

                    constantID = FieldToID <Char> (_char, constantID);
                    _char      = IDToField <Char> (_char, constantID, false);
                }
            }

            if (_char)
            {
                EditorGUILayout.Space();
                renderLock_sorting = (RenderLock)EditorGUILayout.EnumPopup("Sorting:", renderLock_sorting);
                if (renderLock_sorting == RenderLock.Set)
                {
                    mapType = (SortingMapType)EditorGUILayout.EnumPopup("Sorting type:", mapType);
                    if (mapType == SortingMapType.OrderInLayer)
                    {
                        sortingOrderParameterID = Action.ChooseParameterGUI("New order:", parameters, sortingOrderParameterID, ParameterType.Integer);
                        if (sortingOrderParameterID < 0)
                        {
                            sortingOrder = EditorGUILayout.IntField("New order:", sortingOrder);
                        }
                    }
                    else if (mapType == SortingMapType.SortingLayer)
                    {
                        sortingLayerParameterID = Action.ChooseParameterGUI("New layer:", parameters, sortingLayerParameterID, ParameterType.String);
                        if (sortingLayerParameterID < 0)
                        {
                            sortingLayer = EditorGUILayout.TextField("New layer:", sortingLayer);
                        }
                    }
                }

                if (_char.GetAnimEngine())
                {
                    _char.GetAnimEngine().ActionCharRenderGUI(this, parameters);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("This Action requires a Character before more options will show.", MessageType.Info);
            }

            EditorGUILayout.Space();
            AfterRunningOption();
        }
Ejemplo n.º 23
0
 private void SetDefaultPlayer(PlayerPrefab defaultPlayer)
 {
     foreach (PlayerPrefab _player in players)
     {
         if (_player == defaultPlayer)
         {
             _player.isDefault = true;
         }
         else
         {
             _player.isDefault = false;
         }
     }
 }
        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);
        }
Ejemplo n.º 25
0
        private void CreatePlayersGUI()
        {
            playerSwitching = (PlayerSwitching) EditorGUILayout.EnumPopup ("Player switching:", playerSwitching);
            if (playerSwitching == PlayerSwitching.DoNotAllow)
            {
                player = (Player) EditorGUILayout.ObjectField ("Player:", player, typeof (Player), false);
            }
            else
            {
                shareInventory = EditorGUILayout.Toggle ("Share same Inventory?", shareInventory);

                foreach (PlayerPrefab _player in players)
                {
                    EditorGUILayout.BeginHorizontal ();

                    _player.playerOb = (Player) EditorGUILayout.ObjectField ("Player " + _player.ID + ":", _player.playerOb, typeof (Player), false);

                    if (_player.isDefault)
                    {
                        GUILayout.Label ("DEFAULT", EditorStyles.boldLabel, GUILayout.Width (80f));
                    }
                    else
                    {
                        if (GUILayout.Button ("Make default", GUILayout.Width (80f)))
                        {
                            SetDefaultPlayer (_player);
                        }
                    }

                    if (GUILayout.Button (deleteContent, EditorStyles.miniButtonRight, buttonWidth))
                    {
                        Undo.RecordObject (this, "Delete player reference");
                        players.Remove (_player);
                        break;
                    }

                    EditorGUILayout.EndHorizontal ();
                }

                if (GUILayout.Button("Add new player"))
                {
                    Undo.RecordObject (this, "Add player");

                    PlayerPrefab newPlayer = new PlayerPrefab (GetPlayerIDArray ());
                    players.Add (newPlayer);
                }
            }
        }