Beispiel #1
0
        private void UnloadPlayerStart(int playerStartInt, SceneSettings sceneSettings)
        {
            PlayerStart playerStart = ConstantID.GetComponent <PlayerStart> (playerStartInt, sceneSettings.gameObject.scene);

            if (playerStart)
            {
                sceneSettings.defaultPlayerStart = playerStart;
            }
        }
Beispiel #2
0
        private void UnloadCutsceneOnStart(int cutsceneInt, SceneSettings sceneSettings)
        {
            Cutscene cutscene = Serializer.returnComponent <Cutscene> (cutsceneInt, sceneSettings.gameObject);

            if (cutscene && sceneSettings)
            {
                sceneSettings.cutsceneOnStart = cutscene;
            }
        }
Beispiel #3
0
        private void UnloadCutsceneOnStart(int cutsceneInt, SceneSettings sceneSettings)
        {
            Cutscene cutscene = ConstantID.GetComponent <Cutscene> (cutsceneInt, sceneSettings.gameObject.scene);

            if (cutscene)
            {
                sceneSettings.cutsceneOnStart = cutscene;
            }
        }
Beispiel #4
0
        private void UnloadPlayerStart(int playerStartInt, SceneSettings sceneSettings)
        {
            PlayerStart playerStart = Serializer.returnComponent <PlayerStart> (playerStartInt, sceneSettings.gameObject);

            if (playerStart && sceneSettings)
            {
                sceneSettings.defaultPlayerStart = playerStart;
            }
        }
 public override void SceneSettingsGUI()
 {
                 #if UNITY_EDITOR
     if (SceneSettings.IsUnity2D())
     {
         EditorGUILayout.HelpBox("This method is not compatible with 'Unity 2D' mode.", MessageType.Warning);
     }
                 #endif
 }
Beispiel #6
0
        override public void AssignParentList(ActionList actionList)
        {
            if (sceneSettings == null)
            {
                sceneSettings = KickStarter.sceneSettings;
            }

            base.AssignParentList(actionList);
        }
 public override void SceneSettingsGUI()
 {
                 #if UNITY_EDITOR
     KickStarter.sceneSettings.navMesh = (NavigationMesh)EditorGUILayout.ObjectField("Default NavMesh:", KickStarter.sceneSettings.navMesh, typeof(NavigationMesh), true);
     if (SceneSettings.IsUnity2D())
     {
         EditorGUILayout.HelpBox("This method is not compatible with 'Unity 2D' mode.", MessageType.Warning);
     }
                 #endif
 }
Beispiel #8
0
        private void UnloadSortingMap(int sortingMapInt, SceneSettings sceneSettings)
        {
            SortingMap sortingMap = Serializer.returnComponent <SortingMap> (sortingMapInt, sceneSettings.gameObject);

            if (sortingMap && sceneSettings)
            {
                sceneSettings.sortingMap = sortingMap;
                KickStarter.sceneSettings.UpdateAllSortingMaps();
            }
        }
Beispiel #9
0
        private void UnloadSortingMap(int sortingMapInt, SceneSettings sceneSettings)
        {
            SortingMap sortingMap = ConstantID.GetComponent <SortingMap> (sortingMapInt, sceneSettings.gameObject.scene);

            if (sortingMap)
            {
                sceneSettings.sortingMap = sortingMap;
                KickStarter.sceneSettings.UpdateAllSortingMaps();
            }
        }
 override public void AssignParentList(ActionList actionList)
 {
     if (actionList != null)
     {
         sceneSettings = UnityVersionHandler.GetSceneSettingsOfGameObject(actionList.gameObject);
     }
     if (sceneSettings == null)
     {
         sceneSettings = KickStarter.sceneSettings;
     }
 }
Beispiel #11
0
 private static void SetGameEngine()
 {
     if (gameEnginePrefab == null)
     {
         SceneSettings sceneSettings = UnityVersionHandler.GetKickStarterComponent <SceneSettings>();
         if (sceneSettings != null)
         {
             gameEnginePrefab = sceneSettings.gameObject;
         }
     }
 }
Beispiel #12
0
 protected Vector3 GetLookVector(SettingsManager settingsManager)
 {
     if (copyRotation)
     {
         return(runtimeFaceObject.transform.forward);
     }
     else if (SceneSettings.ActInScreenSpace())
     {
         return(AdvGame.GetScreenDirection(runtimeCharToMove.transform.position, runtimeFaceObject.transform.position));
     }
     return(runtimeFaceObject.transform.position - runtimeCharToMove.transform.position);
 }
Beispiel #13
0
        protected void FollowUpdate()
        {
            followUpdateTimer = followFrequency;

            float dist = FollowCheckDistance();

            if (dist > followDistance)
            {
                Paths path = GetComponent <Paths>();
                if (path == null)
                {
                    ACDebug.LogWarning("Cannot move a character with no Paths component", gameObject);
                }
                else
                {
                    path.pathType = AC_PathType.ForwardOnly;
                    path.affectY  = true;

                    Vector3[] pointArray;
                    Vector3   targetPosition = followTarget.Transform.position;

                    if (SceneSettings.ActInScreenSpace())
                    {
                        targetPosition = AdvGame.GetScreenNavMesh(targetPosition);
                    }

                    if (KickStarter.navigationManager)
                    {
                        if (followRandomDirection)
                        {
                            targetPosition = KickStarter.navigationManager.navigationEngine.GetPointNear(targetPosition, followDistance, followDistanceMax);
                        }
                        pointArray = KickStarter.navigationManager.navigationEngine.GetPointsArray(Transform.position, targetPosition, this);
                    }
                    else
                    {
                        List <Vector3> pointList = new List <Vector3>();
                        pointList.Add(targetPosition);
                        pointArray = pointList.ToArray();
                    }

                    if (dist > followDistanceMax)
                    {
                        MoveAlongPoints(pointArray, true);
                    }
                    else
                    {
                        MoveAlongPoints(pointArray, false);
                    }
                    isEvadingPlayer = false;
                }
            }
        }
Beispiel #14
0
        private void SendDataToScene(SingleLevelData levelData, bool restoringSaveFile, SubScene subScene = null)
        {
            SceneSettings  sceneSettings  = (subScene == null) ? KickStarter.sceneSettings : subScene.SceneSettings;
            LocalVariables localVariables = (subScene == null) ? KickStarter.localVariables : subScene.LocalVariables;

            KickStarter.actionListManager.LoadData(levelData.activeLists, subScene);

            UnloadCutsceneOnLoad(levelData.onLoadCutscene, sceneSettings);
            UnloadCutsceneOnStart(levelData.onStartCutscene, sceneSettings);
            UnloadNavMesh(levelData.navMesh, sceneSettings);
            UnloadPlayerStart(levelData.playerStart, sceneSettings);
            UnloadSortingMap(levelData.sortingMap, sceneSettings);
            UnloadTintMap(levelData.tintMap, sceneSettings);

            UnloadTransformData(levelData.allTransformData, subScene);

            foreach (ScriptData _scriptData in levelData.allScriptData)
            {
                if (_scriptData.data != null && _scriptData.data.Length > 0)
                {
                    // Get objects in active scene, and "DontDestroyOnLoad" scene
                    Remember[] saveObjects = Serializer.returnComponents <Remember> (_scriptData.objectID);

                    foreach (Remember saveObject in saveObjects)
                    {
                        if (saveObject != null && UnityVersionHandler.ObjectIsInActiveScene(saveObject.gameObject))
                        {
                            // May have more than one Remember script on the same object, so check all
                            Remember[] saveScripts = saveObject.gameObject.GetComponents <Remember>();
                            foreach (Remember saveScript in saveScripts)
                            {
                                saveScript.LoadData(_scriptData.data, restoringSaveFile);
                            }
                        }
                    }
                }

                /*Remember saveObject = Serializer.returnComponent <Remember> (_scriptData.objectID, sceneSettings.gameObject);
                 * if (saveObject != null && _scriptData.data != null && _scriptData.data.Length > 0)
                 * {
                 *      // May have more than one Remember script on the same object, so check all
                 *      Remember[] saveScripts = saveObject.gameObject.GetComponents <Remember>();
                 *      foreach (Remember saveScript in saveScripts)
                 *      {
                 *              saveScript.LoadData (_scriptData.data, restoringSaveFile);
                 *      }
                 * }*/
            }

            UnloadVariablesData(levelData.localVariablesData, localVariables);
            KickStarter.sceneSettings.UpdateAllSortingMaps();
        }
Beispiel #15
0
        protected override void Awake()
        {
            isDragControlled = true;
            targetIsPlayer   = false;
            SetOriginalPosition();

            if (KickStarter.settingsManager)
            {
                _is2D = SceneSettings.IsUnity2D();
            }

            base.Awake();
        }
Beispiel #16
0
        protected void Awake()
        {
            if (GetComponent <Renderer>())
            {
                GetComponent <Renderer>().enabled = false;
            }

            if (SceneSettings.IsUnity2D())
            {
                transform.RotateAround(transform.position, Vector3.right, 90f);
                transform.RotateAround(transform.position, transform.right, -90f);
            }
        }
        override public void Skip()
        {
            if (runtimeChar != null && runtimeMarker != null)
            {
                runtimeChar.EndPath();

                if (runtimeChar is NPC)
                {
                    NPC npcToMove = (NPC)runtimeChar;
                    npcToMove.StopFollowing();
                }

                Vector3[] pointArray;
                Vector3   targetPosition = runtimeMarker.transform.position;

                if (SceneSettings.ActInScreenSpace())
                {
                    targetPosition = AdvGame.GetScreenNavMesh(targetPosition);
                }

                if (pathFind && KickStarter.navigationManager)
                {
                    pointArray = KickStarter.navigationManager.navigationEngine.GetPointsArray(runtimeChar.transform.position, targetPosition);
                    KickStarter.navigationManager.navigationEngine.ResetHoles(KickStarter.sceneSettings.navMesh);
                }
                else
                {
                    List <Vector3> pointList = new List <Vector3>();
                    pointList.Add(targetPosition);
                    pointArray = pointList.ToArray();
                }

                int i = pointArray.Length - 1;

                if (i > 0)
                {
                    runtimeChar.SetLookDirection(pointArray[i] - pointArray[i - 1], true);
                }
                else
                {
                    runtimeChar.SetLookDirection(pointArray[i] - runtimeChar.transform.position, true);
                }

                runtimeChar.Teleport(pointArray [i]);

                if (faceAfter)
                {
                    runtimeChar.SetLookDirection(runtimeMarker.transform.forward, true);
                }
            }
        }
        private void SetDesired()
        {
            Vector2 targetOffset = GetOffsetForPosition(target.transform.position);

            if (targetOffset.x < (perspectiveOffset.x - freedom.x))
            {
                desiredOffset.x = targetOffset.x + freedom.x;
            }
            else if (targetOffset.x > (perspectiveOffset.x + freedom.x))
            {
                desiredOffset.x = targetOffset.x - freedom.x;
            }

            desiredOffset.x += afterOffset.x;
            if (directionInfluence.x != 0f)
            {
                desiredOffset.x += Vector3.Dot(target.forward, transform.right) * directionInfluence.x;
            }

            if (limitHorizontal)
            {
                desiredOffset.x = ConstrainAxis(desiredOffset.x, constrainHorizontal);
            }

            if (targetOffset.y < (perspectiveOffset.y - freedom.y))
            {
                desiredOffset.y = targetOffset.y + freedom.y;
            }
            else if (targetOffset.y > (perspectiveOffset.y + freedom.y))
            {
                desiredOffset.y = targetOffset.y - freedom.y;
            }

            desiredOffset.y += afterOffset.y;
            if (directionInfluence.y != 0f)
            {
                if (SceneSettings.IsTopDown())
                {
                    desiredOffset.y += Vector3.Dot(target.forward, transform.up) * directionInfluence.y;
                }
                else
                {
                    desiredOffset.y += Vector3.Dot(target.forward, transform.forward) * directionInfluence.y;
                }
            }

            if (limitVertical)
            {
                desiredOffset.y = ConstrainAxis(desiredOffset.y, constrainVertical);
            }
        }
Beispiel #19
0
        protected Vector3 GetLookVector(string direction)
        {
            Vector3 lookVector  = Vector3.zero;
            Vector3 upVector    = Camera.main.transform.up;
            Vector3 rightVector = Camera.main.transform.right - new Vector3(0f, 0.01f); // Angle slightly so that left->right rotations face camera

            if (SceneSettings.IsTopDown())
            {
                upVector = -Camera.main.transform.forward;
            }

            if (direction == "down")
            {
                lookVector = -upVector;
            }
            else if (direction == "left")
            {
                lookVector = -rightVector;
            }
            else if (direction == "right")
            {
                lookVector = rightVector;
            }
            else if (direction == "up")
            {
                lookVector = upVector;
            }
            else if (direction == "downleft")
            {
                lookVector = (-upVector - rightVector).normalized;
            }
            else if (direction == "downright")
            {
                lookVector = (-upVector + rightVector).normalized;
            }
            else if (direction == "upleft")
            {
                lookVector = (upVector - rightVector).normalized;
            }
            else if (direction == "upright")
            {
                lookVector = (upVector + rightVector).normalized;
            }
            else
            {
                //TODO: face object in here
            }

            lookVector = new Vector3(lookVector.x, 0f, lookVector.y);
            return(lookVector);
        }
Beispiel #20
0
        private Vector3 GetLookVector(SettingsManager settingsManager)
        {
            Vector3 lookVector = runtimeFaceObject.transform.position - runtimeCharToMove.transform.position;

            if (copyRotation)
            {
                lookVector = runtimeFaceObject.transform.forward;
            }
            else if (SceneSettings.ActInScreenSpace())
            {
                lookVector = AdvGame.GetScreenDirection(runtimeCharToMove.transform.position, runtimeFaceObject.transform.position);
            }

            return(lookVector);
        }
Beispiel #21
0
        /**
         * Places the Player at the GameObject's position, and activates the assigned cameraOnStart.
         */
        public void PlacePlayerAt()
        {
            if (KickStarter.mainCamera)
            {
                if (fadeInOnStart)
                {
                    KickStarter.mainCamera.FadeIn(fadeSpeed);
                }

                if (KickStarter.settingsManager)
                {
                    if (KickStarter.player)
                    {
                        KickStarter.player.SetLookDirection(ForwardDirection, true);
                        KickStarter.player.Teleport(KickStarter.sceneChanger.GetStartPosition(Position));

                        if (SceneSettings.ActInScreenSpace())
                        {
                            KickStarter.player.Transform.position = AdvGame.GetScreenNavMesh(KickStarter.player.Transform.position);
                        }
                    }

                    if (KickStarter.settingsManager.movementMethod == MovementMethod.FirstPerson)
                    {
                        KickStarter.mainCamera.SetFirstPerson();
                    }
                    else if (cameraOnStart)
                    {
                        SetCameraOnStart();
                    }
                    else
                    {
                        if (!KickStarter.settingsManager.IsInFirstPerson())
                        {
                            ACDebug.LogWarning("PlayerStart '" + gameObject.name + "' has no Camera On Start", this);

                            if (KickStarter.sceneSettings != null &&
                                this != KickStarter.sceneSettings.defaultPlayerStart)
                            {
                                KickStarter.sceneSettings.defaultPlayerStart.SetCameraOnStart();
                            }
                        }
                    }

                    KickStarter.eventManager.Call_OnOccupyPlayerStart(KickStarter.player, this);
                }
            }
        }
Beispiel #22
0
        private void UnloadTintMap(int tintMapInt, SceneSettings sceneSettings)
        {
            TintMap tintMap = ConstantID.GetComponent <TintMap> (tintMapInt, sceneSettings.gameObject.scene);

            if (tintMap)
            {
                sceneSettings.tintMap = tintMap;

                // Reset all FollowTintMap components
                FollowTintMap[] followTintMaps = FindObjectsOfType(typeof(FollowTintMap)) as FollowTintMap[];
                foreach (FollowTintMap followTintMap in followTintMaps)
                {
                    followTintMap.ResetTintMap();
                }
            }
        }
Beispiel #23
0
        private void UnloadTintMap(int tintMapInt, SceneSettings sceneSettings)
        {
            TintMap tintMap = Serializer.returnComponent <TintMap> (tintMapInt, sceneSettings.gameObject);

            if (tintMap && sceneSettings)
            {
                sceneSettings.tintMap = tintMap;

                // Reset all FollowTintMap components
                FollowTintMap[] followTintMaps = FindObjectsOfType(typeof(FollowTintMap)) as FollowTintMap[];
                foreach (FollowTintMap followTintMap in followTintMaps)
                {
                    followTintMap.ResetTintMap();
                }
            }
        }
Beispiel #24
0
        private Vector3 GetLookVector()
        {
            Vector3 lookVector  = Vector3.zero;
            Vector3 upVector    = Camera.main.transform.up;
            Vector3 rightVector = Camera.main.transform.right - new Vector3(0f, 0.01f);              // Angle slightly so that left->right rotations face camera

            if (SceneSettings.IsTopDown())
            {
                upVector = -Camera.main.transform.forward;
            }

            if (direction == CharDirection.Down)
            {
                lookVector = -upVector;
            }
            else if (direction == CharDirection.Left)
            {
                lookVector = -rightVector;
            }
            else if (direction == CharDirection.Right)
            {
                lookVector = rightVector;
            }
            else if (direction == CharDirection.Up)
            {
                lookVector = upVector;
            }
            else if (direction == CharDirection.DownLeft)
            {
                lookVector = (-upVector - rightVector).normalized;
            }
            else if (direction == CharDirection.DownRight)
            {
                lookVector = (-upVector + rightVector).normalized;
            }
            else if (direction == CharDirection.UpLeft)
            {
                lookVector = (upVector - rightVector).normalized;
            }
            else if (direction == CharDirection.UpRight)
            {
                lookVector = (upVector + rightVector).normalized;
            }

            lookVector = new Vector3(lookVector.x, 0f, lookVector.y);
            return(lookVector);
        }
Beispiel #25
0
        /**
         * <summary>Unsets the values of all script variables, so that they can be re-assigned to the correct scene if multiple scenes are open.</summary>
         */
        public void ClearVariables()
        {
            playerPrefab           = null;
            mainCameraPrefab       = null;
            persistentEnginePrefab = null;
            gameEnginePrefab       = null;

            // Managers
            sceneManagerPrefab     = null;
            settingsManagerPrefab  = null;
            actionsManagerPrefab   = null;
            variablesManagerPrefab = null;
            inventoryManagerPrefab = null;
            speechManagerPrefab    = null;
            cursorManagerPrefab    = null;
            menuManagerPrefab      = null;

            // PersistentEngine components
            optionsComponent                = null;
            runtimeInventoryComponent       = null;
            runtimeVariablesComponent       = null;
            playerMenusComponent            = null;
            stateHandlerComponent           = null;
            sceneChangerComponent           = null;
            saveSystemComponent             = null;
            levelStorageComponent           = null;
            runtimeLanguagesComponent       = null;
            actionListAssetManagerComponent = null;

            // GameEngine components
            menuSystemComponent        = null;
            dialogComponent            = null;
            playerInputComponent       = null;
            playerInteractionComponent = null;
            playerMovementComponent    = null;
            playerCursorComponent      = null;
            playerQTEComponent         = null;
            sceneSettingsComponent     = null;
            navigationManagerComponent = null;
            actionListManagerComponent = null;
            localVariablesComponent    = null;
            menuPreviewComponent       = null;
            eventManagerComponent      = null;

            SetGameEngine();
        }
Beispiel #26
0
        /**
         * Initialises the Player's animation.
         */
        public void Initialise()
        {
            if (GetAnimation())
            {
                // Hack: Force idle of Legacy characters
                AdvGame.PlayAnimClip(GetAnimation(), AdvGame.GetAnimLayerInt(AnimLayer.Base), idleAnim, AnimationBlendMode.Blend, WrapMode.Loop, 0f, null, false);
            }
            else if (spriteChild)
            {
                // Hack: update 2D sprites
                PrepareSpriteChild(SceneSettings.IsTopDown(), SceneSettings.IsUnity2D());
                UpdateSpriteChild(SceneSettings.IsTopDown(), SceneSettings.IsUnity2D());
            }
            UpdateScale();

            GetAnimEngine().TurnHead(Vector2.zero);
            GetAnimEngine().PlayIdle();
        }
Beispiel #27
0
        protected Vector3 GetLookVector(SettingsManager settingsManager)
        {
            if (copyRotation)
            {
                Marker runtimeMarker = runtimeFaceObject.GetComponent <Marker>();
                if (runtimeMarker != null)
                {
                    return(runtimeMarker.ForwardDirection);
                }

                return(runtimeFaceObject.transform.forward);
            }
            else if (SceneSettings.ActInScreenSpace())
            {
                return(AdvGame.GetScreenDirection(runtimeCharToMove.transform.position, runtimeFaceObject.transform.position));
            }
            return(runtimeFaceObject.transform.position - runtimeCharToMove.transform.position);
        }
Beispiel #28
0
        /**
         * Sets the camera's rotation and projection according to the chosen settings in SettingsManager.
         */
        public void SetCorrectRotation()
        {
            if (KickStarter.settingsManager)
            {
                if (SceneSettings.IsTopDown())
                {
                    transform.rotation = Quaternion.Euler(90f, 0, 0);
                    return;
                }

                if (SceneSettings.IsUnity2D())
                {
                    Camera.orthographic = true;
                }
            }

            transform.rotation = Quaternion.Euler(0, 0, 0);
        }
Beispiel #29
0
        /**
         * <summary>Rebuilds the nodes List from an array of points. The first point on the new path will be the GameObject's current position.</summary>
         * <param name = "pointData">An array of position vectors that dictate the new path</param>
         */
        public void BuildNavPath(Vector3[] pointData)
        {
            if (pointData != null && pointData.Length > 0)
            {
                pathType  = AC_PathType.ForwardOnly;
                affectY   = false;
                nodePause = 0;

                List <Vector3> newNodes = new List <Vector3>();

                newNodes.Clear();
                newNodes.Add(this.transform.position);

                nodeCommands.Clear();

                for (int i = 0; i < pointData.Length; i++)
                {
                    if (i == 0)
                    {
                        // If first point, ignore if same as position
                        if (SceneSettings.IsUnity2D())
                        {
                            Vector2 testPoint  = new Vector2(transform.position.x, transform.position.y);
                            Vector2 testPoint2 = new Vector2(pointData[0].x, pointData[0].y);
                            if ((testPoint - testPoint2).magnitude < 0.001f)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            Vector3 testPoint = new Vector3(transform.position.x, pointData[0].y, transform.position.z);
                            if ((testPoint - pointData[0]).magnitude < 0.001f)
                            {
                                continue;
                            }
                        }
                    }
                    newNodes.Add(pointData[i]);
                }

                nodes = newNodes;
            }
        }
Beispiel #30
0
 /**
  * <summary>Calculates the player's position relative to the next scene's PlayerStart.</summary>
  * <param name = "marker">The Marker of the GameObject that marks the position that the player should be placed relative to.</param>
  */
 public void SetRelativePosition(Marker marker)
 {
     if (KickStarter.player == null || marker == null)
     {
         relativePosition = Vector2.zero;
     }
     else
     {
         relativePosition = KickStarter.player.Transform.position - marker.Position;
         if (SceneSettings.IsUnity2D())
         {
             relativePosition.z = 0f;
         }
         else if (SceneSettings.IsTopDown())
         {
             relativePosition.y = 0f;
         }
     }
 }