private IEnumerator LoadStorage()
        {
            achievementData = ScriptableObject.CreateInstance <AchievementData>();
            GeneralStorageSystem.LoadFile(achievementData, "Achievements");

            if (isInfiniteScene())
            {
                if (achievementData.infinitePlayerPos != Vector3.zero)
                {
                    player.gameObject.SetActive(false);
                    player.transform.position = achievementData.infinitePlayerPos;
                    player.gameObject.SetActive(true);
                    Player.OnPlayerMove(achievementData.infinitePlayerPos);
                }

                skyDome.Cycle = achievementData.timeCycle;

                var infiniteWorld = FindObjectOfType <InfiniteWorld>();
                infiniteWorld.StartCoroutine(infiniteWorld.UpdateWorld());
            }

            yield return(new WaitForEndOfFrame());

            player.inventorySystem.inventoryStorageList = achievementData.inventoryStorageList;
            player.inventorySystem.UpdateInvetoryUI();

            CraftSystem.Instance.craftInventoryList = achievementData.craftStorageList;
            CraftSystem.Instance.UpdateInvetoryUI();
        }
        public void SaveStorage()
        {
            if (isInfiniteScene())
            {
                achievementData.infinitePlayerPos = player.transform.position;
                achievementData.timeCycle         = skyDome.Cycle;
            }

            achievementData.inventoryStorageList = player.inventorySystem.inventoryStorageList;
            achievementData.craftStorageList     = CraftSystem.Instance.craftInventoryList;
            GeneralStorageSystem.SaveFile(achievementData, "Achievements");
        }
Beispiel #3
0
        private void Start()
        {
            PlotBtn.onClick.AddListener(() => {
                LoadingEffect.SetActive(true);
                SceneManager.LoadScene("SampleScene");
            });

            SurvivalBtn.onClick.AddListener(() => {
                LoadingEffect.SetActive(true);
                SceneManager.LoadScene("InfiniteScene");
            });

            ExitBtn.onClick.AddListener(() => {
                Application.Quit();
            });

            TouchToggle.onValueChanged.AddListener(val => {
                Util.isTouchingScreen = val;
                PlayerPrefs.SetString("Touching", val.ToString());

                var text = TouchToggle.transform.Find("Label").GetComponent <Text> ();

                if (val)
                {
                    text.text = "触屏控制";
                }
                else
                {
                    text.text = "键鼠控制";
                }
            });

            var isTouching = PlayerPrefs.GetString("Touching", true.ToString()) == true.ToString();

            TouchToggle.isOn = isTouching;

            if (PlayerPrefs.HasKey("Plot"))
            {
                SurvivalBtn.interactable = true;
            }

            CleanData.onClick.AddListener(() => {
                PlayerPrefs.DeleteAll();
                GeneralStorageSystem.DeleteFolder();
            });

#if UNITY_EDITOR
            SurvivalBtn.interactable = true;
            SurvivalBtn.colors       = new ColorBlock()
            {
                normalColor = Color.red
            };
#else
            CleanData.interactable = false;
#endif

#if UNITY_IOS
            var isIpad = Device.generation.ToString().ToLower().Contains("ipad");

            if (isIpad)
            {
                var screenWidth  = PlayerPrefs.GetInt("ScreenWidth", Screen.width);
                var screenHeight = PlayerPrefs.GetInt("ScreenHeight", Screen.height);

                if (!PlayerPrefs.HasKey("ScreenWidth"))
                {
                    PlayerPrefs.SetInt("ScreenWidth", screenWidth);
                    PlayerPrefs.SetInt("ScreenHeight", screenHeight);
                }
                Screen.SetResolution(Mathf.RoundToInt(screenWidth * 0.6f), Mathf.RoundToInt(screenHeight * 0.6f), true);
            }
#endif
        }