Exemple #1
0
        public void Start()
        {
            // Load data file
            _ec = ErrorController.Instance;
            _dc = DataController.Instance;

            saveInfo = new SaveInfo();

            if (!_dc.LoadData<SaveInfo>(ref saveInfo))
            {
                _dc.AddData(saveInfo);
                _dc.SaveAll();
            }

            // Check window elements

            if (ActionButtons.Length != SaveInfo.SavesCount)
            {
                _ec.PushError("Bad number of load buttons.", this, ErrorType.Error, true);
                return;
            }

            // Disable control buttons

            StartButton.GetComponent<Button>().interactable = false;

            DeleteButton.GetComponent<Button>().interactable = false;
            DeleteButton.GetComponentInChildren<Text>().text = _deleteButtonText;
            DeleteButton.GetComponent<Button>().onClick.AddListener(() => DeleteGame());

            // Set actions to buttons

            for (int i = 0; i < ActionButtons.Length; i++)
            {
                Button button = ActionButtons[i].GetComponent<Button>();
                int index = i;

                if (button == null)
                {
                    _ec.PushError("Bad element in action buttons list.", this, ErrorType.Error, true);
                    return;
                }

                button.onClick.AddListener(() => ActionButtonClick(index));
                button.GetComponentInChildren<Text>().text = saveInfo.Info[i].IsNewGame ? "Start new game" : saveInfo.Info[i].Name;
            }
        }
Exemple #2
0
        void Start()
        {
            _complited = false;
            _crash = false;

            saveInfo = DataController.Instance.GetData<SaveInfo>() as SaveInfo;
            terrain = FindObjectOfType<Terrain>();
            StartCoroutine(LoadingBarShow());

            switch (saveInfo.Current.TerrainSize)
            {
                case WorldSize.small:
                    size = 512;
                    break;
                case WorldSize.medium:
                    size = 1024;
                    break;
                case WorldSize.large:
                    size = 2048;
                    break;
                case WorldSize.huge:
                    size = 4096;
                    break;
            }

            if (saveInfo.Current.IsNewGame)
                loadThread = new Thread(Generate);
            else
                loadThread = new Thread(Load);

            loadThread.IsBackground = true;
            loadThread.Start();

            StartCoroutine(LoaderChecker());
        }