Пример #1
0
        IEnumerator RestartGameProcedure()
        {
            audioManager.Fadeout();

            Time.timeScale = 1;
            fading         = true;
            Vector3 newPos = Camera.main.transform.position;

            newPos.z += 5; // TODO: fix
            blackFade.transform.position = newPos;

            PersistentEngine.SetPause(false);

            yield return(new WaitForSeconds(1.5f));

            if (PersistentEngine.GetDemo())
            {
                PersistentEngine.SetState("Global level", 1);
                PersistentEngine.SetState("Global loadingLevel", 1, true);
            }
            else
            {
                PersistentEngine.SetState("Global level", 1);
                PersistentEngine.SetState("Global loadingLevel", 1, true);
            }
            SceneManager.LoadScene("loadingScreen");
        }
Пример #2
0
 // Update is called once per frame
 void Update()
 {
     if (advCamera)
     {
         if (lastCameraSize != advCamera.cameraSize)
         {
             if (PersistentEngine.IsMobileScreen())
             {
                 myTransform.localScale = Vector3.one * 0.6f * (advCamera.cameraSize / originalCameraSize);
             }
             else
             {
                 myTransform.localScale = Vector3.one * 0.5f * (advCamera.cameraSize / originalCameraSize);// + Vector3.one * 0.1f;
             }
             lastCameraSize = advCamera.cameraSize;
         }
         if (isFlipped && lastIsFlipped != isFlipped)
         {
             myTransform.localScale = new Vector3(-myTransform.localScale.x, myTransform.localScale.y, myTransform.localScale.z);
             lastIsFlipped          = isFlipped;
         }
         else if (lastIsFlipped != isFlipped)
         {
             myTransform.localScale = new Vector3(-myTransform.localScale.x, myTransform.localScale.y, myTransform.localScale.z);
             lastIsFlipped          = isFlipped;
         }
     }
 }
Пример #3
0
        IEnumerator InitialisePlayerArrival()
        {
            string arrivalDoor = PersistentEngine.GetArrivalDoor();

            foreach (DoorBetweenLevels door in GameObject.FindObjectsOfType <DoorBetweenLevels>())
            {
                doors[door.levelPath] = door;
            }

            if (!string.IsNullOrEmpty(arrivalDoor) && !staticCharacter)
            {
                yield return(StartCoroutine(EnterRoom(arrivalDoor)));

                yield return(null);
            }
            else
            {
                if (advCamera != null && advCamera.followElroy)
                {
                    advCamera.transform.position = transform.position + Vector3.up * advCamera.yFollowOffset;
                }

                if (!staticCharacter)
                {
                    ChangeState(State.IdleDiagonalFront);
                }
            }

            yield return(null);
        }
Пример #4
0
        public IEnumerator ShowDialog(string line1, string line2, string line3, string line4, string line5)
        {
            yield return(null);

            if (calcFunctions)
            {
                if (PersistentEngine.IsMobileScreen())
                {
                    defBgPos.y = (-advCamera.cameraSize + defCamSizeForCalc) * multiplierSmall;
                }
                else
                {
                    defBgPos.y = (-advCamera.cameraSize + defCamSizeForCalc) * multiplierLarge;
                }
                offsetBackground = (advCamera.cameraSize - defCamSizeForCalc) * secondMultiplier + addedOffest;
            }

            SetEnabled(true);

            SetLines(line1, line2, line3, line4, line5);
            lineSelected = -1;

            while (lineSelected == -1)
            {
                yield return(new WaitForSeconds(0.5f));
            }

            SetEnabled(false);
        }
Пример #5
0
        private void LoadLevelInternal(int level)
        {
            PersistentEngine.SetState("Global level", level);
            PersistentEngine.SetState("Global loadingLevel", level, true);

            SceneManager.LoadScene(level);
        }
Пример #6
0
        public IEnumerator LeaveRoomImmediate(DoorBetweenLevels door)
        {
            heldItem   = combiningItem = null;
            targetItem = null;
            if (door.zoomoutCircleTransformPosition != null)
            {
                SetInCutScene(true, CutsceneTools.Type.ZoomOut, door.zoomoutCircleTransformPosition.position, false, 0.0001f);
            }
            else
            {
                SetInCutScene(true, CutsceneTools.Type.ZoomOut, transform.position + door.zoomoutCircleOffset, false, 0.0001f);
            }

            PersistentEngine.SetArrivalDoor(SceneManager.GetActiveScene().path);

            audioManager.Fadeout();

            scene.arrivalCave = -1;

            if (door.GetLevelIndex() == -1)
            {
                LoadLevelInternal(0);
            }
            else
            {
                LoadLevelInternal(door.GetLevelIndex());
            }

            yield return(null);
        }
Пример #7
0
        bool EvalExpression(string expression)
        {
            int i = -1;

            int i1 = expression.IndexOf("=");
            int i2 = expression.IndexOf("<");
            int i3 = expression.IndexOf(">");

            if (i1 != -1)
            {
                i = i1;
            }
            if (i2 != -1)
            {
                i = i2;
            }
            if (i3 != -1)
            {
                i = i3;
            }

            int?worldval = PersistentEngine.GetState(expression.Substring(0, i));

            if (worldval == null)
            {
                return(false);
            }

            string cmpvalstr = expression.Substring(i + 1);
            int    cmpval    = -1;

            try
            {
                cmpval = Int32.Parse(cmpvalstr);
            }
            catch
            {
                return(false);
            }

            int worldvalnotnull = (int)worldval;

            if (i1 != -1) // operator =
            {
                return(cmpval == worldvalnotnull);
            }
            else
            if (i2 != -1) // operator =
            {
                return(worldvalnotnull < cmpval);
            }
            else
            if (i3 != -1) // operator =
            {
                return(worldvalnotnull > cmpval);
            }

            return(false);
        }
Пример #8
0
        public static void ContinueFromSavedGame(int slot)
        {
            audioManager.Fadeout();

            PersistentEngine.SetState("Global Savegame", slot, true);

            PersistentEngine g = GameObject.Find("Global").GetComponent <PersistentEngine>();

            g.ContinueGame();
        }
Пример #9
0
        public static void StartLevel(int levelNumber)
        {
            audioManager.Fadeout();
            PersistentEngine g = GameObject.Find("Global").GetComponent <PersistentEngine>();

            RemoveAllSavedData();
            PersistentEngine.SetState("Global level", levelNumber);
            PersistentEngine.SetState("Global loadingLevel", levelNumber, true);
            PersistentEngine.SetPause(false);
            g.StartSelectedLevel();
        }
Пример #10
0
 IEnumerator OnApplicationPause(bool paused)
 {
     if (paused && SceneManager.GetActiveScene().buildIndex != 0)
     {
         PersistentEngine.SaveState();
     }
     else
     {
     }
     yield return(null);
 }
Пример #11
0
        // Use this for initialization
        void Start()
        {
            int?level = PersistentEngine.GetState("Global loadingLevel");

            if (level < 10)
            {
                level = 15;
            }

            level++;
        }
Пример #12
0
        IEnumerator Start()
        {
            Application.backgroundLoadingPriority = ThreadPriority.High;

            int?level = PersistentEngine.GetState("Global loadingLevel");

            Debug.Log("LoadingScene: level " + level.ToString());

            SceneManager.LoadScene((int)level);

            yield return(null);
        }
Пример #13
0
 public void recalculateHiddenOffset()
 {
     if (advCamera)
     {
         hiddenOffset = 0.35f * advCamera.cameraSize / advCamera.transform.localScale.x;
         if (PersistentEngine.IsMobileScreen())
         {
             hiddenOffset = hiddenOffset * 1.5f;
         }
         if (positionOk && isHidden)
         {
             positionOffset = new Vector3(-hiddenOffset, positionOffset.y, 0);
         }
     }
 }
Пример #14
0
        IEnumerator ContinueGameProcedure()
        {
            Time.timeScale = 1;
            state.Clear();

            Initialize();

            PersistentEngine.SetPause(false);

            Time.timeScale = 1;

            SceneManager.LoadScene("loadingScreen");

            yield return(null);
        }
Пример #15
0
        IEnumerator StartSelectedLevelProc()
        {
            audioManager.Fadeout();

            Time.timeScale = 1;
            fading         = true;
            Vector3 newPos = Camera.main.transform.position;

            newPos.z += 5;
            blackFade.transform.position = newPos;
            PersistentEngine.SetPause(false);
            yield return(new WaitForSeconds(1.5f));

            SceneManager.LoadScene("loadingScreen");
        }
Пример #16
0
 void tryLines2()
 {
     if (calcFunctions)
     {
         if (PersistentEngine.IsMobileScreen())
         {
             defBgPos.y = (-advCamera.cameraSize + defCamSizeForCalc) * multiplierSmall;
         }
         else
         {
             defBgPos.y = (-advCamera.cameraSize + defCamSizeForCalc) * multiplierLarge;
         }
         offsetBackground = (advCamera.cameraSize - defCamSizeForCalc) * secondMultiplier + addedOffest;
     }
     StartCoroutine(ShowDialog("test1", "test2", "", "", ""));
 }
Пример #17
0
        public static void StartNewGame(int slot)
        {
            audioManager.Fadeout();
            PersistentEngine g = GameObject.Find("Global").GetComponent <PersistentEngine>();

            savePath = defaultSavePath.Remove(defaultSavePath.Length - 4);

            savePath = savePath + slot + ".txt";

            currentSlot = slot;

            PersistentEngine.SetState("Global Savegame", slot, true);

            RemoveAllSavedData();
            g.RestartGame();
        }
Пример #18
0
        bool Switch()
        {
            state++;

            if (state > states.Length - 1)
            {
                state = 0;
            }

            switchedFlag = true;

            PersistentEngine.SetState(gameObject.name + "_RotatingState", state);

            ProcessState();

            return(true);
        }
Пример #19
0
        public void LoadState()
        {
            if (!allowSaving)
            {
                return;
            }

            var fields = this.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Where(field => field.IsDefined(typeof(SaveStateAttribute), true));

            foreach (var field in fields)
            {
                if (field.FieldType.IsEnum)
                {
                    if (PersistentEngine.GetState(GetObjectIdentifier(sceneName) + field.Name) != null)
                    {
                        field.SetValue(this, PersistentEngine.GetState(GetObjectIdentifier(sceneName) + field.Name));
                    }
                }
                else
                if (PersistentEngine.IsNumericType(field))
                {
                    if (PersistentEngine.GetState(GetObjectIdentifier(sceneName) + field.Name) != null)
                    {
                        field.SetValue(this, PersistentEngine.GetState(GetObjectIdentifier(sceneName) + field.Name));
                    }
                }
                else
                if (PersistentEngine.IsBooleanType(field))
                {
                    if (PersistentEngine.GetState(GetObjectIdentifier(sceneName) + field.Name) != null)
                    {
                        var val = PersistentEngine.GetState(GetObjectIdentifier(sceneName) + field.Name);
                        GetObjectIdentifier(sceneName);
                        field.SetValue(this, val == 1 ? true : false);
                    }
                }
                else
                if (PersistentEngine.IsStringType(field))
                {
                    var val = PersistentEngine.GetStateStr(GetObjectIdentifier(sceneName) + field.Name);
                    GetObjectIdentifier(sceneName);
                    field.SetValue(this, val);
                }
            }
        }
Пример #20
0
        // Use this for initialization
        void Start()
        {
            advCamera = PersistentEngine.advCamera;
            float cameraSize = 4;

            if (advCamera)
            {
                cameraSize = advCamera.cameraSize;
            }
            else
            {
                cameraSize = PersistentEngine.activeCamera.fieldOfView;
            }

            textStrings         = new string[5];
            colorSelected       = new Color32(255, 168, 48, 255);
            colorIdle           = new Color32(255, 243, 197, 255);
            colorShadowSelected = new Color32(32, 53, 63, 255);
            colorShadowIdle     = new Color32(13, 63, 81, 255);
            bg       = background.transform.parent.transform;
            defBgPos = bg.transform.localPosition;
            if (calcFunctions)
            {
                if (PersistentEngine.IsMobileScreen())
                {
                    defBgPos.y = (-cameraSize + defCamSizeForCalc) * multiplierSmall;
                }
                else
                {
                    defBgPos.y = (-cameraSize + defCamSizeForCalc) * multiplierLarge;
                }
                offsetBackground = (cameraSize - defCamSizeForCalc) * secondMultiplier + addedOffest;
            }

            defTextPosKrat = textPosKrat;
            defTextPosPlus = textPosPlus;
            SetEnabled(false);

            shadowOffsetLeft  *= cameraSize / 0.93f;
            shadowOffsetLeft1 *= cameraSize / 0.93f;
            shadowOffsetLeft2 *= cameraSize / 0.93f;
            shadowOffsetDown  *= cameraSize / 0.93f;
            shadowOffsetDown1 *= cameraSize / 0.93f;
            shadowOffsetDown2 *= cameraSize / 0.93f;
        }
Пример #21
0
        public void SaveState(bool saveFile = false)
        {
            if (!allowSaving)
            {
                return;
            }

            var fields = this.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Where(field => field.IsDefined(typeof(SaveStateAttribute), true));

            foreach (FieldInfo field in fields)
            {
                if (field.FieldType.IsEnum)
                {
                    PersistentEngine.SetState(GetObjectIdentifier(sceneName) + field.Name, (int)field.GetValue(this), saveFile);
                }
                else
                if (PersistentEngine.IsNumericType(field))
                {
                    PersistentEngine.SetState(GetObjectIdentifier(sceneName) + field.Name, (int)field.GetValue(this), saveFile);
                }
                else
                if (PersistentEngine.IsBooleanType(field))
                {
                    var val = (bool)field.GetValue(this) == true ? 1 : 0;
                    GetObjectIdentifier(sceneName);
                    PersistentEngine.SetState(GetObjectIdentifier(sceneName) + field.Name, val, saveFile);
                }
                else if (PersistentEngine.IsStringType(field))
                {
                    var val = field.GetValue(this);
                    GetObjectIdentifier(sceneName);
                    try
                    {
                        PersistentEngine.SetStateStr(GetObjectIdentifier(sceneName) + field.Name, (string)val, saveFile);
                    }
                    catch
                    {
                        PersistentEngine.SetState(GetObjectIdentifier(sceneName) + field.Name, null, saveFile);
                    }
                }
            }
        }
Пример #22
0
        public IEnumerator LeaveRoom(DoorBetweenLevels door, State walkOption = State.WalkSide)
        {
            heldItem   = combiningItem = null;
            targetItem = null;

            if (!staticCharacter)
            {
                if (door.zoomoutCircleTransformPosition != null)
                {
                    Debug.Log("LeaveRoom transfrom pos" + door);
                    SetInCutScene(true, CutsceneTools.Type.ZoomOut, door.zoomoutCircleTransformPosition.position, false, 0.0001f, false);
                }
                else
                {
                    SetInCutScene(true, CutsceneTools.Type.ZoomOut, transform.position + door.zoomoutCircleOffset, false, 0.0001f, false);
                }

                autoPilotTarget = door.outsideOffset + door.gameObject.transform.position;
                autoPilotDelta  = autoPilotTarget - transform.position;
                isInAutopilot   = true;
                autoPilotSpeed  = 1 / 1.5f;
                autoPilotSpeed  = door.walkInOutSpeed;

                ChangeState(walkOption);
                direction = transform.position.x < (autoPilotTarget.x) ? 1 : -1;
                ProcessDirectionAndScale(false);
            }

            PersistentEngine.SetArrivalDoor(SceneManager.GetActiveScene().path);

            audioManager.Fadeout();

            if (!staticCharacter)
            {
                float maxTime   = 1 / autoPilotSpeed;
                float startTime = Time.time;
                float dist      = 100f;
                while (true)
                {
                    dist = Vector3.Distance(transform.position, door.transform.position + door.outsideOffset);
                    if (dist < 0.1f)
                    {
                        break;
                    }
                    if (Time.time - startTime > maxTime)
                    {
                        break;
                    }
                    yield return(new WaitForSeconds(0.02f));
                }
            }
            StartCoroutine(DisableAutopilot(true));
            yield return(StartCoroutine(door.ExitTranslationAnimation()));

            scene.arrivalCave = -1;

            if (door.GetLevelIndex() == -1)
            {
                LoadLevelInternal(0);
            }
            else
            {
                LoadLevelInternal(door.GetLevelIndex());
            }
        }
Пример #23
0
        protected virtual void Initialise()
        {
            PersistentEngine.AddStatefulItem(this);

            LoadState();
        }
Пример #24
0
 protected virtual void InitialiseGlobal()
 {
     sceneName = "globalScene";
     PersistentEngine.AddStatefulItem(this);
     LoadState();
 }