Example #1
0
        public void SetTilt(Vector3 lookAtPosition, bool isInstant)
        {
            if (KickStarter.settingsManager.movementMethod == MovementMethod.UltimateFPS)
            {
                fpCam = UltimateFPSIntegration.GetFPCamTransform();
            }

            if (fpCam == null)
            {
                return;
            }

            if (isInstant)
            {
                isTilting = false;

                transform.LookAt(lookAtPosition);
                float tilt = transform.localEulerAngles.x;
                if (targetTilt > 180)
                {
                    targetTilt = targetTilt - 360;
                }

                if (fpCam && fpCam.GetComponent <FirstPersonCamera>())
                {
                    fpCam.GetComponent <FirstPersonCamera>().SetRotationY(tilt);
                }
                else if (KickStarter.settingsManager.movementMethod == MovementMethod.UltimateFPS)
                {
                    UltimateFPSIntegration.SetTilt(tilt);
                }
            }
            else
            {
                // Base the speed of tilt change on how much horizontal rotation is needed

                actualTilt = fpCam.eulerAngles.x;
                if (actualTilt > 180)
                {
                    actualTilt = actualTilt - 360;
                }

                Quaternion oldRotation = fpCam.rotation;
                fpCam.transform.LookAt(lookAtPosition);
                targetTilt     = fpCam.localEulerAngles.x;
                fpCam.rotation = oldRotation;
                if (targetTilt > 180)
                {
                    targetTilt = targetTilt - 360;
                }

                Vector3 flatLookVector = lookAtPosition - transform.position;
                flatLookVector.y = 0f;

                tiltSpeed     = Mathf.Abs(2f / Vector3.Dot(fpCam.forward.normalized, flatLookVector.normalized)) * turnSpeed / 100f;
                tiltSpeed     = Mathf.Min(tiltSpeed, 2f);
                tiltStartTime = Time.time;
                isTilting     = true;
            }
        }
Example #2
0
 private void UpdateTilt()
 {
     if (fpCam && fpCam.GetComponent <FirstPersonCamera>())
     {
         fpCam.GetComponent <FirstPersonCamera>().SetRotationY(actualTilt);
     }
     else if (KickStarter.settingsManager.movementMethod == MovementMethod.UltimateFPS)
     {
         UltimateFPSIntegration.SetTilt(actualTilt);
     }
 }
Example #3
0
        public void ChangeScene(string sceneName, int sceneNumber, bool saveRoomData)
        {
            bool useLoadingScreen = false;

            if (KickStarter.settingsManager != null && KickStarter.settingsManager.useLoadingScreen)
            {
                useLoadingScreen = true;
            }

            KickStarter.mainCamera.FadeOut(0f);

            if (KickStarter.player)
            {
                KickStarter.player.Halt();

                if (KickStarter.settingsManager.movementMethod == MovementMethod.UltimateFPS)
                {
                    UltimateFPSIntegration.SetCameraEnabled(false, true);
                }
            }

            Sound[] sounds = FindObjectsOfType(typeof(Sound)) as Sound[];
            foreach (Sound sound in sounds)
            {
                if (sound.canDestroy)
                {
                    if (sound.GetComponent <RememberSound>())
                    {
                        DestroyImmediate(sound.GetComponent <RememberSound>());
                    }
                    DestroyImmediate(sound);
                }
            }

            KickStarter.playerMenus.ClearParents();
            KickStarter.dialog.KillDialog(true, true);

            if (saveRoomData)
            {
                KickStarter.levelStorage.StoreCurrentLevelData();
                previousScene     = Application.loadedLevel;
                previousSceneName = Application.loadedLevelName;
            }

            KickStarter.stateHandler.gameState = GameState.Normal;
            playerOnTransition = KickStarter.player;

            LoadLevel(sceneName, sceneNumber, useLoadingScreen);
        }
Example #4
0
        public void Disable()
        {
            if (KickStarter.settingsManager.movementMethod == MovementMethod.UltimateFPS)
            {
                UltimateFPSIntegration.SetCameraEnabled(false, true);
            }

            if (_camera)
            {
                _camera.enabled = false;
            }
            if (_audioListener)
            {
                _audioListener.enabled = false;
            }
        }
Example #5
0
        private void Start()
        {
            AssignFadeTexture();

            if (lookAtTransform)
            {
                lookAtTransform.localPosition = new Vector3(0f, 0f, 10f);
                LookAtZ = lookAtTransform.localPosition.z;
                LookAtCentre();
            }

            if (KickStarter.settingsManager.movementMethod == MovementMethod.UltimateFPS)
            {
                UltimateFPSIntegration.SetCameraEnabled(true);
            }

            StartCoroutine("ShowScene");
        }
        public static void _Update(GameState gameState)
        {
            bool cursorLock = false;
            bool moveLock   = false;
            bool cameraIsOn = false;

            if (gameState == GameState.Normal)
            {
                cursorLock = KickStarter.playerInput.cursorIsLocked;
                moveLock   = !KickStarter.playerInput.isUpLocked;
                cameraIsOn = true;
            }

            if (gameState != GameState.Paused)
            {
                UltimateFPSIntegration.SetCameraEnabled(cameraIsOn);
            }

            UltimateFPSIntegration.SetMovementState(moveLock);
            UltimateFPSIntegration.SetCameraState(cursorLock);
        }
Example #7
0
        public void ShowGUI()
        {
            EditorGUILayout.LabelField("Save game settings", EditorStyles.boldLabel);

            if (saveFileName == "")
            {
                saveFileName = SaveSystem.SetProjectName();
            }
            saveFileName = EditorGUILayout.TextField("Save filename:", saveFileName);
                        #if !UNITY_WEBPLAYER && !UNITY_ANDROID
            saveTimeDisplay     = (SaveTimeDisplay)EditorGUILayout.EnumPopup("Time display:", saveTimeDisplay);
            takeSaveScreenshots = EditorGUILayout.ToggleLeft("Take screenshot when saving?", takeSaveScreenshots);
                        #else
            EditorGUILayout.HelpBox("Save-game screenshots are disabled for WebPlayer and Android platforms.", MessageType.Info);
            takeSaveScreenshots = false;
                        #endif

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Cutscene settings:", EditorStyles.boldLabel);

            actionListOnStart    = ActionListAssetMenu.AssetGUI("ActionList on start game:", actionListOnStart);
            blackOutWhenSkipping = EditorGUILayout.Toggle("Black out when skipping?", blackOutWhenSkipping);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Character settings:", EditorStyles.boldLabel);

            CreatePlayersGUI();

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Interface settings", EditorStyles.boldLabel);

            movementMethod = (MovementMethod)EditorGUILayout.EnumPopup("Movement method:", movementMethod);
            if (movementMethod == MovementMethod.UltimateFPS && !UltimateFPSIntegration.IsDefinePresent())
            {
                EditorGUILayout.HelpBox("The 'UltimateFPSIsPresent' preprocessor define must be declared in the Player Settings.", MessageType.Warning);
            }

            inputMethod       = (InputMethod)EditorGUILayout.EnumPopup("Input method:", inputMethod);
            interactionMethod = (AC_InteractionMethod)EditorGUILayout.EnumPopup("Interaction method:", interactionMethod);

            if (inputMethod != InputMethod.TouchScreen)
            {
                useOuya = EditorGUILayout.ToggleLeft("Playing on OUYA platform?", useOuya);
                if (useOuya && !OuyaIntegration.IsDefinePresent())
                {
                    EditorGUILayout.HelpBox("The 'OUYAIsPresent' preprocessor define must be declared in the Player Settings.", MessageType.Warning);
                }
                if (interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction)
                {
                    selectInteractions = (SelectInteractions)EditorGUILayout.EnumPopup("Select Interactions by:", selectInteractions);
                    if (selectInteractions != SelectInteractions.CyclingCursorAndClickingHotspot)
                    {
                        seeInteractions = (SeeInteractions)EditorGUILayout.EnumPopup("See Interactions with:", seeInteractions);
                        if (seeInteractions == SeeInteractions.ClickOnHotspot)
                        {
                            stopPlayerOnClickHotspot = EditorGUILayout.ToggleLeft("Stop player moving when click Hotspot?", stopPlayerOnClickHotspot);
                        }
                    }

                    if (selectInteractions == SelectInteractions.CyclingCursorAndClickingHotspot)
                    {
                        autoCycleWhenInteract = EditorGUILayout.ToggleLeft("Auto-cycle after an Interaction?", autoCycleWhenInteract);
                    }

                    if (SelectInteractionMethod() == SelectInteractions.ClickingMenu)
                    {
                        cancelInteractions = (CancelInteractions)EditorGUILayout.EnumPopup("Close interactions with:", cancelInteractions);
                    }
                    else
                    {
                        cancelInteractions = CancelInteractions.CursorLeavesMenu;
                    }
                }
            }
            if (interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
            {
                autoCycleWhenInteract = EditorGUILayout.ToggleLeft("Reset cursor after an Interaction?", autoCycleWhenInteract);
            }
            lockCursorOnStart = EditorGUILayout.ToggleLeft("Lock cursor in screen's centre when game begins?", lockCursorOnStart);
            hideLockedCursor  = EditorGUILayout.ToggleLeft("Hide cursor when locked in screen's centre?", hideLockedCursor);
            onlyInteractWhenCursorUnlocked = EditorGUILayout.ToggleLeft("Disallow Interactions if cursor is unlocked?", onlyInteractWhenCursorUnlocked);
            if (IsInFirstPerson())
            {
                disableFreeAimWhenDragging = EditorGUILayout.ToggleLeft("Disable free-aim when dragging?", disableFreeAimWhenDragging);
            }
            if (inputMethod != InputMethod.TouchScreen)
            {
                runConversationsWithKeys = EditorGUILayout.ToggleLeft("Dialogue options can be selected with number keys?", runConversationsWithKeys);
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Inventory settings", EditorStyles.boldLabel);

            if (interactionMethod != AC_InteractionMethod.ContextSensitive)
            {
                inventoryInteractions = (InventoryInteractions)EditorGUILayout.EnumPopup("Inventory interactions:", inventoryInteractions);

                if (interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction)
                {
                    if (selectInteractions == SelectInteractions.CyclingCursorAndClickingHotspot)
                    {
                        cycleInventoryCursors = EditorGUILayout.ToggleLeft("Include Inventory items in Interaction cycles?", cycleInventoryCursors);
                    }
                    else
                    {
                        cycleInventoryCursors = EditorGUILayout.ToggleLeft("Include Inventory items in Interaction menus?", cycleInventoryCursors);
                    }
                }

                if (inventoryInteractions == InventoryInteractions.Multiple && CanSelectItems(false))
                {
                    selectInvWithUnhandled = EditorGUILayout.ToggleLeft("Select item if Interaction is unhandled?", selectInvWithUnhandled);
                    if (selectInvWithUnhandled)
                    {
                        CursorManager cursorManager = AdvGame.GetReferences().cursorManager;
                        if (cursorManager != null && cursorManager.cursorIcons != null && cursorManager.cursorIcons.Count > 0)
                        {
                            selectInvWithIconID = GetIconID("Select with unhandled:", selectInvWithIconID, cursorManager);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("No Interaction cursors defined - please do so in the Cursor Manager.", MessageType.Info);
                        }
                    }

                    giveInvWithUnhandled = EditorGUILayout.ToggleLeft("Give item if Interaction is unhandled?", giveInvWithUnhandled);
                    if (giveInvWithUnhandled)
                    {
                        CursorManager cursorManager = AdvGame.GetReferences().cursorManager;
                        if (cursorManager != null && cursorManager.cursorIcons != null && cursorManager.cursorIcons.Count > 0)
                        {
                            giveInvWithIconID = GetIconID("Give with unhandled:", giveInvWithIconID, cursorManager);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("No Interaction cursors defined - please do so in the Cursor Manager.", MessageType.Info);
                        }
                    }
                }
            }

            if (interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction && selectInteractions != SelectInteractions.ClickingMenu && inventoryInteractions == InventoryInteractions.Multiple)
            {
            }
            else
            {
                reverseInventoryCombinations = EditorGUILayout.ToggleLeft("Combine interactions work in reverse?", reverseInventoryCombinations);
            }

            //if (interactionMethod != AC_InteractionMethod.ChooseHotspotThenInteraction || inventoryInteractions == InventoryInteractions.Single)
            if (CanSelectItems(false))
            {
                inventoryDragDrop = EditorGUILayout.ToggleLeft("Drag and drop Inventory interface?", inventoryDragDrop);
                if (!inventoryDragDrop)
                {
                    if (interactionMethod == AC_InteractionMethod.ContextSensitive || inventoryInteractions == InventoryInteractions.Single)
                    {
                        rightClickInventory = (RightClickInventory)EditorGUILayout.EnumPopup("Right-click active item:", rightClickInventory);
                    }
                }
                else if (inventoryInteractions == AC.InventoryInteractions.Single)
                {
                    inventoryDropLook = EditorGUILayout.ToggleLeft("Can drop an Item onto itself to Examine it?", inventoryDropLook);
                }
            }

            if (CanSelectItems(false) && !inventoryDragDrop)
            {
                inventoryDisableLeft = EditorGUILayout.ToggleLeft("Left-click deselects active item?", inventoryDisableLeft);

                if (movementMethod == MovementMethod.PointAndClick && !inventoryDisableLeft)
                {
                    canMoveWhenActive = EditorGUILayout.ToggleLeft("Can move player if an Item is active?", canMoveWhenActive);
                }
            }

            inventoryActiveEffect = (InventoryActiveEffect)EditorGUILayout.EnumPopup("Active cursor FX:", inventoryActiveEffect);
            if (inventoryActiveEffect == InventoryActiveEffect.Pulse)
            {
                inventoryPulseSpeed = EditorGUILayout.Slider("Active FX pulse speed:", inventoryPulseSpeed, 0.5f, 2f);
            }

            activeWhenUnhandled  = EditorGUILayout.ToggleLeft("Show Active FX when an Interaction is unhandled?", activeWhenUnhandled);
            canReorderItems      = EditorGUILayout.ToggleLeft("Items can be re-ordered in Menu?", canReorderItems);
            hideSelectedFromMenu = EditorGUILayout.ToggleLeft("Hide currently active Item in Menu?", hideSelectedFromMenu);
            activeWhenHover      = EditorGUILayout.ToggleLeft("Show Active FX when Cursor hovers over Item in Menu?", activeWhenHover);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Required inputs:", EditorStyles.boldLabel);
            EditorGUILayout.HelpBox("The following inputs are available for the chosen interface settings:" + GetInputList(), MessageType.Info);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Movement settings", EditorStyles.boldLabel);

            if ((inputMethod == InputMethod.TouchScreen && movementMethod != MovementMethod.PointAndClick) || movementMethod == MovementMethod.Drag)
            {
                dragWalkThreshold = EditorGUILayout.FloatField("Walk threshold:", dragWalkThreshold);
                dragRunThreshold  = EditorGUILayout.FloatField("Run threshold:", dragRunThreshold);

                if (inputMethod == InputMethod.TouchScreen && movementMethod == MovementMethod.FirstPerson)
                {
                    freeAimTouchSpeed = EditorGUILayout.FloatField("Freelook speed:", freeAimTouchSpeed);
                }

                drawDragLine = EditorGUILayout.Toggle("Draw drag line?", drawDragLine);
                if (drawDragLine)
                {
                    dragLineWidth = EditorGUILayout.FloatField("Drag line width:", dragLineWidth);
                    dragLineColor = EditorGUILayout.ColorField("Drag line colour:", dragLineColor);
                }
            }
            else if (movementMethod == MovementMethod.Direct)
            {
                magnitudeAffectsDirect = EditorGUILayout.ToggleLeft("Input magnitude affects speed?", magnitudeAffectsDirect);
                directMovementType     = (DirectMovementType)EditorGUILayout.EnumPopup("Direct-movement type:", directMovementType);
                if (directMovementType == DirectMovementType.RelativeToCamera)
                {
                    limitDirectMovement = (LimitDirectMovement)EditorGUILayout.EnumPopup("Movement limitation:", limitDirectMovement);
                    if (cameraPerspective == CameraPerspective.ThreeD)
                    {
                        directMovementPerspective = EditorGUILayout.ToggleLeft("Account for player's position on screen?", directMovementPerspective);
                    }
                }
            }
            else if (movementMethod == MovementMethod.PointAndClick)
            {
                clickPrefab         = (Transform)EditorGUILayout.ObjectField("Click marker:", clickPrefab, typeof(Transform), false);
                walkableClickRange  = EditorGUILayout.Slider("NavMesh search %:", walkableClickRange, 0f, 1f);
                doubleClickMovement = EditorGUILayout.Toggle("Double-click to move?", doubleClickMovement);
            }
            if (movementMethod == MovementMethod.StraightToCursor)
            {
                dragRunThreshold  = EditorGUILayout.FloatField("Run threshold:", dragRunThreshold);
                singleTapStraight = EditorGUILayout.ToggleLeft("Single-clicking also moves player?", singleTapStraight);
                if (singleTapStraight)
                {
                    singleTapStraightPathfind = EditorGUILayout.ToggleLeft("Pathfind when single-clicking?", singleTapStraightPathfind);
                }
            }
            if (movementMethod == MovementMethod.FirstPerson && inputMethod == InputMethod.TouchScreen)
            {
                dragAffects = (DragAffects)EditorGUILayout.EnumPopup("Touch-drag affects:", dragAffects);
            }
            if ((movementMethod == MovementMethod.Direct || movementMethod == MovementMethod.FirstPerson) && inputMethod != InputMethod.TouchScreen)
            {
                jumpSpeed = EditorGUILayout.Slider("Jump speed:", jumpSpeed, 1f, 10f);
            }

            destinationAccuracy = EditorGUILayout.Slider("Destination accuracy:", destinationAccuracy, 0f, 1f);

            if (inputMethod == InputMethod.TouchScreen)
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Touch Screen settings", EditorStyles.boldLabel);

                offsetTouchCursor = EditorGUILayout.Toggle("Drag cursor with touch?", offsetTouchCursor);
                doubleTapHotspots = EditorGUILayout.Toggle("Double-tap Hotspots?", doubleTapHotspots);
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Camera settings", EditorStyles.boldLabel);

            cameraPerspective_int = (int)cameraPerspective;
            cameraPerspective_int = EditorGUILayout.Popup("Camera perspective:", cameraPerspective_int, cameraPerspective_list);
            cameraPerspective     = (CameraPerspective)cameraPerspective_int;
            if (movementMethod == MovementMethod.FirstPerson)
            {
                cameraPerspective = CameraPerspective.ThreeD;
            }
            if (cameraPerspective == CameraPerspective.TwoD)
            {
                movingTurning = (MovingTurning)EditorGUILayout.EnumPopup("Moving and turning:", movingTurning);
                if (movingTurning == MovingTurning.TopDown || movingTurning == MovingTurning.Unity2D)
                {
                    verticalReductionFactor = EditorGUILayout.Slider("Vertical movement factor:", verticalReductionFactor, 0.1f, 1f);
                }
            }

            forceAspectRatio = EditorGUILayout.Toggle("Force aspect ratio?", forceAspectRatio);
            if (forceAspectRatio)
            {
                wantedAspectRatio = EditorGUILayout.FloatField("Aspect ratio:", wantedAspectRatio);
                                #if UNITY_IPHONE
                landscapeModeOnly = EditorGUILayout.Toggle("Landscape-mode only?", landscapeModeOnly);
                                #endif
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Hotpot settings", EditorStyles.boldLabel);

            hotspotDetection = (HotspotDetection)EditorGUILayout.EnumPopup("Hotspot detection method:", hotspotDetection);
            if (hotspotDetection == HotspotDetection.PlayerVicinity && (movementMethod == MovementMethod.Direct || IsInFirstPerson()))
            {
                hotspotsInVicinity = (HotspotsInVicinity)EditorGUILayout.EnumPopup("Hotspots in vicinity:", hotspotsInVicinity);
            }
            else if (hotspotDetection == HotspotDetection.MouseOver)
            {
                scaleHighlightWithMouseProximity = EditorGUILayout.ToggleLeft("Highlight Hotspots based on cursor proximity?", scaleHighlightWithMouseProximity);
                if (scaleHighlightWithMouseProximity)
                {
                    highlightProximityFactor = EditorGUILayout.FloatField("Cursor proximity factor:", highlightProximityFactor);
                }
            }

            if (cameraPerspective != CameraPerspective.TwoD)
            {
                playerFacesHotspots = EditorGUILayout.Toggle("Player turns head to active?", playerFacesHotspots);
            }

            hotspotIconDisplay = (HotspotIconDisplay)EditorGUILayout.EnumPopup("Display Hotspot icon:", hotspotIconDisplay);
            if (hotspotIconDisplay != HotspotIconDisplay.Never)
            {
                if (cameraPerspective != CameraPerspective.TwoD)
                {
                    occludeIcons = EditorGUILayout.Toggle("Don't show behind Colliders?", occludeIcons);
                }
                hotspotIcon = (HotspotIcon)EditorGUILayout.EnumPopup("Hotspot icon type:", hotspotIcon);
                if (hotspotIcon == HotspotIcon.Texture)
                {
                    hotspotIconTexture = (Texture2D)EditorGUILayout.ObjectField("Hotspot icon texture:", hotspotIconTexture, typeof(Texture2D), false);
                }
                hotspotIconSize = EditorGUILayout.FloatField("Hotspot icon size:", hotspotIconSize);
            }

                        #if UNITY_5
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Audio settings", EditorStyles.boldLabel);
            volumeControl = (VolumeControl)EditorGUILayout.EnumPopup("Volume controlled by:", volumeControl);
            if (volumeControl == VolumeControl.AudioMixerGroups)
            {
                musicMixerGroup             = (AudioMixerGroup)EditorGUILayout.ObjectField("Music mixer:", musicMixerGroup, typeof(AudioMixerGroup), false);
                sfxMixerGroup               = (AudioMixerGroup)EditorGUILayout.ObjectField("SFX mixer:", sfxMixerGroup, typeof(AudioMixerGroup), false);
                speechMixerGroup            = (AudioMixerGroup)EditorGUILayout.ObjectField("Speech mixer:", speechMixerGroup, typeof(AudioMixerGroup), false);
                musicAttentuationParameter  = EditorGUILayout.TextField("Music atten. parameter:", musicAttentuationParameter);
                sfxAttentuationParameter    = EditorGUILayout.TextField("SFX atten. parameter:", sfxAttentuationParameter);
                speechAttentuationParameter = EditorGUILayout.TextField("Speech atten. parameter:", speechAttentuationParameter);
            }
                        #endif

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Raycast settings", EditorStyles.boldLabel);
            navMeshRaycastLength  = EditorGUILayout.FloatField("NavMesh ray length:", navMeshRaycastLength);
            hotspotRaycastLength  = EditorGUILayout.FloatField("Hotspot ray length:", hotspotRaycastLength);
            moveableRaycastLength = EditorGUILayout.FloatField("Moveable ray length:", moveableRaycastLength);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Layer names", EditorStyles.boldLabel);

            hotspotLayer = EditorGUILayout.TextField("Hotspot:", hotspotLayer);
            navMeshLayer = EditorGUILayout.TextField("Nav mesh:", navMeshLayer);
            if (cameraPerspective == CameraPerspective.TwoPointFiveD)
            {
                backgroundImageLayer = EditorGUILayout.TextField("Background image:", backgroundImageLayer);
            }
            deactivatedLayer = EditorGUILayout.TextField("Deactivated:", deactivatedLayer);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Loading scene", EditorStyles.boldLabel);
            useLoadingScreen = EditorGUILayout.Toggle("Use loading screen?", useLoadingScreen);
            if (useLoadingScreen)
            {
                loadingSceneIs = (ChooseSceneBy)EditorGUILayout.EnumPopup("Choose loading scene by:", loadingSceneIs);
                if (loadingSceneIs == ChooseSceneBy.Name)
                {
                    loadingSceneName = EditorGUILayout.TextField("Loading scene name:", loadingSceneName);
                }
                else
                {
                    loadingScene = EditorGUILayout.IntField("Loading screen scene:", loadingScene);
                }
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Options data", EditorStyles.boldLabel);

            if (!PlayerPrefs.HasKey(ppKey))
            {
                optionsData   = new OptionsData();
                optionsBinary = Serializer.SerializeObjectBinary(optionsData);
                PlayerPrefs.SetString(ppKey, optionsBinary);
            }

            optionsBinary = PlayerPrefs.GetString(ppKey);
            if (optionsBinary.Length > 0)
            {
                optionsData = Serializer.DeserializeObjectBinary <OptionsData> (optionsBinary);
            }
            else
            {
                optionsData = new OptionsData();
            }

            defaultSpeechVolume  = optionsData.speechVolume = EditorGUILayout.Slider("Speech volume:", optionsData.speechVolume, 0f, 1f);
            defaultMusicVolume   = optionsData.musicVolume = EditorGUILayout.Slider("Music volume:", optionsData.musicVolume, 0f, 1f);
            defaultSfxVolume     = optionsData.sfxVolume = EditorGUILayout.Slider("SFX volume:", optionsData.sfxVolume, 0f, 1f);
            defaultShowSubtitles = optionsData.showSubtitles = EditorGUILayout.Toggle("Show subtitles?", optionsData.showSubtitles);
            defaultLanguage      = optionsData.language = EditorGUILayout.IntField("Language:", optionsData.language);

            optionsBinary = Serializer.SerializeObjectBinary(optionsData);
            PlayerPrefs.SetString(ppKey, optionsBinary);

            if (GUILayout.Button("Reset options data"))
            {
                PlayerPrefs.DeleteKey("Options");
                optionsData = new OptionsData();
                Debug.Log("PlayerPrefs cleared");
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Debug settings", EditorStyles.boldLabel);
            showActiveActionLists = EditorGUILayout.ToggleLeft("List active ActionLists in Game window?", showActiveActionLists);
            showHierarchyIcons    = EditorGUILayout.ToggleLeft("Show icons in Hierarchy window?", showHierarchyIcons);


            if (GUI.changed)
            {
                EditorUtility.SetDirty(this);
            }
        }
Example #8
0
        private void Update()
        {
            if (KickStarter.settingsManager != null && KickStarter.settingsManager.IsInLoadingScene())
            {
                return;
            }

            if (gameState != GameState.Paused)
            {
                lastNonPausedState = gameState;
            }

            KickStarter.dialog._Update();

            if (!inputIsOff)
            {
                KickStarter.playerInput.UpdateInput();

                if (gameState == GameState.Normal)
                {
                    KickStarter.playerInput.UpdateDirectInput();
                }

                if (gameState != GameState.Paused)
                {
                    KickStarter.playerQTE.UpdateQTE();
                    //KickStarter.dialog.UpdateSkipDialogue ();
                }
            }

            if (!cursorIsOff)
            {
                KickStarter.playerCursor.UpdateCursor();
            }

            if (!menuIsOff)
            {
                KickStarter.playerMenus.UpdateAllMenus();
            }

            if (!interactionIsOff)
            {
                KickStarter.playerInteraction.UpdateInteraction();

                foreach (Highlight highlight in highlights)
                {
                    highlight._Update();
                }

                if (KickStarter.settingsManager.hotspotDetection == HotspotDetection.MouseOver && KickStarter.settingsManager.scaleHighlightWithMouseProximity)
                {
                    if (gameState == GameState.Normal)
                    {
                        foreach (Hotspot hotspot in hotspots)
                        {
                            hotspot.SetProximity(true);
                        }
                    }
                    else
                    {
                        foreach (Hotspot hotspot in hotspots)
                        {
                            hotspot.SetProximity(false);
                        }
                    }
                }
            }

            KickStarter.actionListManager.UpdateActionListManager();

            if (!movementIsOff)
            {
                foreach (DragBase dragBase in dragBases)
                {
                    dragBase.UpdateMovement();
                }

                if (gameState == GameState.Normal && KickStarter.settingsManager && KickStarter.settingsManager.movementMethod != MovementMethod.None)
                {
                    KickStarter.playerMovement.UpdatePlayerMovement();
                }

                KickStarter.playerMovement.UpdateFPCamera();
            }

            if (!interactionIsOff)
            {
                KickStarter.playerInteraction.UpdateInventory();
            }

            if (!cameraIsOff)
            {
                foreach (GameCamera2D gameCamera2D in gameCamera2Ds)
                {
                    gameCamera2D._Update();
                }
            }

            foreach (Sound sound in sounds)
            {
                sound._Update();
            }

            if (HasGameStateChanged())
            {
                if (KickStarter.settingsManager.movementMethod == MovementMethod.UltimateFPS)
                {
                    UltimateFPSIntegration._Update(gameState);
                }
                else if (KickStarter.settingsManager.movementMethod == MovementMethod.FirstPerson)
                {
                    if (gameState == GameState.DialogOptions || gameState == GameState.Normal)
                    {
                        KickStarter.mainCamera.SetFirstPerson();
                    }
                }

                if (gameState != GameState.Paused)
                {
                    AudioListener.pause = false;
                }
            }

            previousUpdateState = gameState;
        }
Example #9
0
        public void SetGameCamera(_Camera newCamera)
        {
            if (newCamera == null)
            {
                return;
            }

            if (attachedCamera != null && attachedCamera is GameCamera25D)
            {
                if (newCamera is GameCamera25D)
                {
                }
                else
                {
                    RemoveBackground();
                }
            }

            if (_camera == null && GetComponent <Camera>())
            {
                _camera = GetComponent <Camera>();
            }
            _camera.ResetProjectionMatrix();
            attachedCamera = newCamera;
            attachedCamera.SetCameraComponent();

            if (attachedCamera && attachedCamera._camera)
            {
                _camera.farClipPlane  = attachedCamera._camera.farClipPlane;
                _camera.nearClipPlane = attachedCamera._camera.nearClipPlane;
                _camera.orthographic  = attachedCamera._camera.orthographic;
            }

            // Set LookAt
            if (attachedCamera is GameCamera)
            {
                GameCamera gameCam = (GameCamera)attachedCamera;
                cursorAffectsRotation = gameCam.followCursor;
                lookAtAmount          = gameCam.cursorInfluence;
            }
            else if (attachedCamera is GameCameraAnimated)
            {
                GameCameraAnimated gameCam = (GameCameraAnimated)attachedCamera;
                if (gameCam.animatedCameraType == AnimatedCameraType.SyncWithTargetMovement)
                {
                    cursorAffectsRotation = gameCam.followCursor;
                    lookAtAmount          = gameCam.cursorInfluence;
                }
                else
                {
                    cursorAffectsRotation = false;
                }
            }
            else
            {
                cursorAffectsRotation = false;
            }

            // Set background
            if (attachedCamera is GameCamera25D)
            {
                GameCamera25D cam25D = (GameCamera25D)attachedCamera;
                cam25D.SetActiveBackground();
            }

            // TransparencySortMode
            if (attachedCamera is GameCamera2D)
            {
                _camera.transparencySortMode = TransparencySortMode.Orthographic;
            }
            else if (attachedCamera)
            {
                if (attachedCamera._camera.orthographic)
                {
                    _camera.transparencySortMode = TransparencySortMode.Orthographic;
                }
                else
                {
                    _camera.transparencySortMode = TransparencySortMode.Perspective;
                }
            }

            // UFPS
            if (KickStarter.settingsManager.movementMethod == MovementMethod.UltimateFPS)
            {
                UltimateFPSIntegration._Update(KickStarter.stateHandler.gameState);
            }
        }
Example #10
0
        public void InitialiseObjects(bool createFolders = true)
        {
            if (createFolders)
            {
                CreateFolder("_Cameras");
                CreateFolder("_Cutscenes");
                CreateFolder("_DialogueOptions");
                CreateFolder("_Interactions");
                CreateFolder("_Lights");
                CreateFolder("_Logic");
                CreateFolder("_Moveables");
                CreateFolder("_Navigation");
                CreateFolder("_NPCs");
                CreateFolder("_Sounds");
                CreateFolder("_SetGeometry");
                CreateFolder("_UI");

                // Create subfolders
                CreateSubFolder("_Cameras", "_GameCameras");

                CreateSubFolder("_Logic", "_ArrowPrompts");
                CreateSubFolder("_Logic", "_Conversations");
                CreateSubFolder("_Logic", "_Containers");
                CreateSubFolder("_Logic", "_Hotspots");
                CreateSubFolder("_Logic", "_Triggers");

                CreateSubFolder("_Moveables", "_Tracks");

                CreateSubFolder("_Navigation", "_CollisionCubes");
                CreateSubFolder("_Navigation", "_CollisionCylinders");
                CreateSubFolder("_Navigation", "_Markers");
                CreateSubFolder("_Navigation", "_NavMeshSegments");
                CreateSubFolder("_Navigation", "_NavMesh");
                CreateSubFolder("_Navigation", "_Paths");
                CreateSubFolder("_Navigation", "_PlayerStarts");
                CreateSubFolder("_Navigation", "_SortingMaps");
            }

            // Delete default main camera
            if (GameObject.FindWithTag(Tags.mainCamera))
            {
                GameObject oldMainCam = GameObject.FindWithTag(Tags.mainCamera);

                // Untag UFPS Camera
                if (UltimateFPSIntegration.IsUFPSCamera(oldMainCam.GetComponent <Camera>()))
                {
                    oldMainCam.tag = "Untagged";
                    Debug.Log("Untagged UFPS camera '" + oldMainCam.name + "' as MainCamera, to make way for Adventure Creator MainCamera.");
                }
                else if (oldMainCam.GetComponent <MainCamera>() == null)
                {
                    if (oldMainCam.GetComponent <Camera>())
                    {
                        oldMainCam.AddComponent <MainCamera>();

                        string     camPrefabfileName = assetFolder + "Automatic" + Path.DirectorySeparatorChar.ToString() + "MainCamera.prefab";
                        GameObject camPrefab         = (GameObject)AssetDatabase.LoadAssetAtPath(camPrefabfileName, typeof(GameObject));
                        Texture2D  prefabFadeTexture = camPrefab.GetComponent <MainCamera>().fadeTexture;

                        oldMainCam.GetComponent <MainCamera>().Initialise(prefabFadeTexture);

                        PutInFolder(GameObject.FindWithTag(Tags.mainCamera), "_Cameras");
                        Debug.Log("'" + oldMainCam.name + "' has been converted to an Adventure Creator MainCamera.");
                    }
                    else
                    {
                        Debug.Log("Removed old MainCamera '" + oldMainCam.name + "' from scene, as it had no Camera component.");
                        DestroyImmediate(oldMainCam);
                    }
                }
            }

            // Create main camera if none exists
            SettingsManager settingsManager = AdvGame.GetReferences().settingsManager;

            if (!GameObject.FindWithTag(Tags.mainCamera))
            {
                GameObject mainCamOb = AddPrefab("Automatic", "MainCamera", false, false, false);
                PrefabUtility.DisconnectPrefabInstance(mainCamOb);
                PutInFolder(mainCamOb, "_Cameras");
                if (settingsManager && settingsManager.IsUnity2D())
                {
                    Camera.main.orthographic = true;
                }
            }

            // Create Background Camera (if 2.5D)
            if (settingsManager && settingsManager.cameraPerspective == CameraPerspective.TwoPointFiveD)
            {
                CreateSubFolder("_SetGeometry", "_BackgroundImages");
                GameObject newOb = AddPrefab("Automatic", "BackgroundCamera", false, false, false);
                PutInFolder(newOb, "_Cameras");
            }

            // Create Game engine
            AddPrefab("Automatic", "GameEngine", false, false, false);

            // Assign Player Start
            if (KickStarter.sceneSettings && KickStarter.sceneSettings.defaultPlayerStart == null)
            {
                string playerStartPrefab = "PlayerStart";
                if (settingsManager != null && settingsManager.IsUnity2D())
                {
                    playerStartPrefab += "2D";
                }

                PlayerStart playerStart = AddPrefab("Navigation", playerStartPrefab, true, false, true).GetComponent <PlayerStart>();
                KickStarter.sceneSettings.defaultPlayerStart = playerStart;
            }

            // Pathfinding method
            if (settingsManager != null && settingsManager.IsUnity2D())
            {
                KickStarter.sceneSettings.navigationMethod = AC_NavigationMethod.PolygonCollider;
                KickStarter.navigationManager.ResetEngine();
            }
        }
Example #11
0
        private void FixedUpdate()
        {
            if (KickStarter.stateHandler && KickStarter.stateHandler.playerIsOff)
            {
                return;
            }
            if (activePath && !pausePath)
            {
                if (IsTurningBeforeWalking())
                {
                    charState = CharState.Idle;
                }
                else if ((KickStarter.stateHandler && KickStarter.stateHandler.gameState == GameState.Cutscene && !lockedPath) ||
                         (KickStarter.settingsManager && KickStarter.settingsManager.movementMethod == MovementMethod.PointAndClick) ||
                         (KickStarter.settingsManager && KickStarter.settingsManager.movementMethod == MovementMethod.StraightToCursor && KickStarter.settingsManager.singleTapStraight) ||
                         IsMovingToHotspot())
                {
                    charState = CharState.Move;
                }

                if (!lockedPath)
                {
                    CheckIfStuck();
                }
            }
            else if (activePath == null && KickStarter.stateHandler.gameState == GameState.Cutscene && charState == CharState.Move)
            {
                charState = CharState.Decelerate;
            }

            if (isJumping)
            {
                if (IsGrounded())
                {
                    isJumping = false;
                }
            }

            if (isTilting)
            {
                actualTilt = Mathf.Lerp(actualTilt, targetTilt, AdvGame.Interpolate(tiltStartTime, tiltSpeed, MoveMethod.Smooth, null));
                if (Mathf.Abs(targetTilt - actualTilt) < 2f)
                {
                    isTilting = false;
                }
            }

            _FixedUpdate();

            if (IsUFPSPlayer())
            {
                if (isTilting)
                {
                    UltimateFPSIntegration.SetRotation(new Vector2(actualTilt, newRotation.eulerAngles.y));
                }
                else
                {
                    UltimateFPSIntegration.SetPitch(newRotation.eulerAngles.y);
                }
            }
            else if (isTilting)
            {
                UpdateTilt();
            }

            if (IsUFPSPlayer() && activePath != null && charState == CharState.Move)
            {
                UltimateFPSIntegration.Teleport(transform.position);
            }
        }
Example #12
0
        override public float Run()
        {
            if (changeMovementMethod)
            {
                if (KickStarter.settingsManager.IsInFirstPerson() && newMovementMethod != MovementMethod.FirstPerson && newMovementMethod != MovementMethod.UltimateFPS)
                {
                    KickStarter.playerInput.cursorIsLocked = false;
                }
                else if (!KickStarter.settingsManager.IsInFirstPerson() && (newMovementMethod == MovementMethod.FirstPerson || newMovementMethod == MovementMethod.UltimateFPS))
                {
                    KickStarter.playerInput.cursorIsLocked = KickStarter.settingsManager.lockCursorOnStart;
                }

                KickStarter.settingsManager.movementMethod = newMovementMethod;

                if (newMovementMethod == MovementMethod.UltimateFPS)
                {
                    UltimateFPSIntegration.SetCameraState(KickStarter.playerInput.cursorIsLocked);
                }
            }

            if (cursorLock == LockType.Enabled)
            {
                KickStarter.stateHandler.cursorIsOff = false;
            }
            else if (cursorLock == LockType.Disabled)
            {
                KickStarter.stateHandler.cursorIsOff = true;
            }

            if (inputLock == LockType.Enabled)
            {
                KickStarter.stateHandler.inputIsOff = false;
            }
            else if (inputLock == LockType.Disabled)
            {
                KickStarter.stateHandler.inputIsOff = true;
            }

            if (interactionLock == LockType.Enabled)
            {
                KickStarter.stateHandler.interactionIsOff = false;
            }
            else if (interactionLock == LockType.Disabled)
            {
                KickStarter.stateHandler.interactionIsOff = true;
            }

            if (menuLock == LockType.Enabled)
            {
                KickStarter.stateHandler.menuIsOff = false;
            }
            else if (menuLock == LockType.Disabled)
            {
                KickStarter.stateHandler.menuIsOff = true;
            }

            if (movementLock == LockType.Enabled)
            {
                KickStarter.stateHandler.movementIsOff = false;
            }
            else if (movementLock == LockType.Disabled)
            {
                KickStarter.stateHandler.movementIsOff = true;
            }

            if (cameraLock == LockType.Enabled)
            {
                KickStarter.stateHandler.cameraIsOff = false;
            }
            else if (cameraLock == LockType.Disabled)
            {
                KickStarter.stateHandler.cameraIsOff = true;
            }

            if (triggerLock == LockType.Enabled)
            {
                KickStarter.stateHandler.triggerIsOff = false;
            }
            else if (triggerLock == LockType.Disabled)
            {
                KickStarter.stateHandler.triggerIsOff = true;
            }

            if (playerLock == LockType.Enabled)
            {
                KickStarter.stateHandler.playerIsOff = false;
            }
            else if (playerLock == LockType.Disabled)
            {
                KickStarter.stateHandler.playerIsOff = true;
            }

            if (saveLock == LockType.Disabled)
            {
                KickStarter.playerMenus.lockSave = true;
            }
            else if (saveLock == LockType.Enabled)
            {
                KickStarter.playerMenus.lockSave = false;
            }

            return(0f);
        }