private void Awake()
        {
            Canvas          canvas  = GetComponent <Canvas>();
            DatabaseGeneral general = DatabaseGeneral.Load();

            Camera mainCamera = (HookCamera.Instance != null
                ? HookCamera.Instance.Get <Camera>()
                : Camera.main
                                 );

            if (canvas != null && general != null)
            {
                switch (general.generalRenderMode)
                {
                case DatabaseGeneral.GENERAL_SCREEN_SPACE.ScreenSpaceOverlay:
                    canvas.renderMode = RenderMode.ScreenSpaceOverlay;
                    break;

                case DatabaseGeneral.GENERAL_SCREEN_SPACE.ScreenSpaceCamera:
                    canvas.renderMode  = RenderMode.ScreenSpaceCamera;
                    canvas.worldCamera = mainCamera;
                    break;
                }
            }
        }
Beispiel #2
0
        // EXECUTABLE: ----------------------------------------------------------------------------

        public override bool InstantExecute(GameObject target, IAction[] actions, int index)
        {
            AudioMixerGroup mixer = null;

            switch (this.audioMixer)
            {
            case AudioMixerType.DefaultSoundMixer:
                mixer = DatabaseGeneral.Load().soundAudioMixer;
                break;

            case AudioMixerType.Custom:
                mixer = this.mixerGroup;
                break;
            }

            AudioManager.Instance.PlaySound3D(
                this.audioClip,
                this.fadeIn,
                this.position.GetPosition(target),
                this.spatialBlend,
                this.pitch.GetValue(target),
                this.volume,
                mixer
                );

            return(true);
        }
Beispiel #3
0
        // PUBLIC METHODS: ------------------------------------------------------------------------

        public Vector2 GetDirection()
        {
            if (this.general == null)
            {
                this.general = DatabaseGeneral.Load();
            }

            if (this.general == null || this.general.touchstickMode == Mode.Continuous)
            {
                return(this.direction);
            }

            float   magnitude = this.direction.magnitude;
            Vector3 result    = this.direction.normalized;

            if (magnitude >= 0.75f)
            {
                return(result * 1f);
            }
            if (magnitude >= 0.1f)
            {
                return(result * 0.5f);
            }

            return(Vector2.zero);
        }
Beispiel #4
0
        public void Save(int profile)
        {
            if (this.onSave != null)
            {
                this.onSave.Invoke(profile);
            }
            if (this.storage == null)
            {
                this.storage = new List <Storage>();
            }
            if (this.data == null)
            {
                this.data = new Dictionary <string, object>();
            }

            this.SetCurrentProfile(profile);

            if (DatabaseGeneral.Load().saveScenes)
            {
                object saveData = this.scenesData.GetSaveData();
                this.data[this.scenesData.GetUniqueName()] = saveData;
            }

            for (int i = this.storage.Count - 1; i >= 0; --i)
            {
                IGameSave item = this.storage[i].target;
                if (item == null)
                {
                    this.storage.RemoveAt(i);
                    continue;
                }

                object saveData = item.GetSaveData();
                if (saveData == null)
                {
                    continue;
                }

                if (!saveData.GetType().IsSerializable)
                {
                    throw new NonSerializableException(saveData.GetType().ToString());
                }

                this.data[item.GetUniqueName()] = saveData;
            }

            List <string> keys = new List <string>();

            foreach (KeyValuePair <string, object> item in this.data)
            {
                string serializedSaveData = JsonUtility.ToJson(item.Value, false);
                string key = this.GetKeyName(profile, item.Key);

                keys.Add(key);
                DatabaseGeneral.Load().GetDataProvider().SetString(key, serializedSaveData);
            }

            this.keysData.Update(profile, keys);
        }
Beispiel #5
0
        public void Delete(int profile)
        {
            Data          data     = this.GetCurrentKeys(profile);
            IDataProvider provider = DatabaseGeneral.Load().GetDataProvider();

            foreach (string key in data.keys)
            {
                provider.DeleteKey(key);
            }
            provider.DeleteKey(this.GetKey(profile));
        }
Beispiel #6
0
        // PRIVATE METHODS: -----------------------------------------------------------------------

        private static void Enable()
        {
            EditorPrefs.SetBool(KEY_TOOLBAR_ENABLED, true);
            SceneView.onSceneGUIDelegate += OnPaintToolbar;

            DatabaseGeneral general = DatabaseGeneral.Load();

            MOVE_OFFSET_X = general.toolbarPositionX;
            MOVE_OFFSET_Y = general.toolbarPositionY;

            SceneView.RepaintAll();
        }
Beispiel #7
0
        // PRIVATE METHODS: -----------------------------------------------------------------------

        private void OnSave(int profile)
        {
            if (!this.profiles.ContainsKey(profile))
            {
                this.profiles.Add(profile, new Profile());
            }

            this.profiles[profile].date = DateTime.Now.ToString(DATE_FMT);
            DatabaseGeneral
            .Load()
            .GetDataProvider()
            .SetString(STORE_KEYFMT, JsonUtility.ToJson(this.profiles));
        }
Beispiel #8
0
        // CONSTRUCTORS: --------------------------------------------------------------------------

        public SavesData(SaveLoadManager manager)
        {
            string data = DatabaseGeneral
                          .Load()
                          .GetDataProvider()
                          .GetString(STORE_KEYFMT, String.Empty);

            if (!string.IsNullOrEmpty(data))
            {
                this.profiles = JsonUtility.FromJson <Profiles>(data);
            }

            manager.onSave += this.OnSave;
        }
Beispiel #9
0
        // PRIVATE METHODS: -----------------------------------------------------------------------

        private Data GetCurrentKeys(int profile)
        {
            IDataProvider provider = DatabaseGeneral.Load().GetDataProvider();

            if (provider == null)
            {
                return(new Data());
            }

            string strKeys = provider.GetString(this.GetKey(profile));

            return(string.IsNullOrEmpty(strKeys)
                ? new Data()
                : JsonUtility.FromJson <Data>(strKeys));
        }
        // INITIALIZERS: --------------------------------------------------------------------------

        protected override void OnCreate()
        {
            DontDestroyOnLoad(gameObject);

            GameObject prefab = DatabaseGeneral.Load().prefabTouchstick;

            if (prefab == null)
            {
                prefab = Resources.Load <GameObject>(RESOURCE_PATH);
            }

            GameObject instance = Instantiate <GameObject>(prefab, transform);

            this.touchStick = instance.GetComponentInChildren <TouchStick>();
        }
Beispiel #11
0
        // PRIVATE METHODS: -----------------------------------------------------------------------

        private static void Enable()
        {
            EditorPrefs.SetBool(KEY_TOOLBAR_ENABLED, true);

            #if UNITY_2019_2_OR_NEWER
            SceneView.duringSceneGui += OnPaintToolbar;
            #else
            SceneView.onSceneGUIDelegate += OnPaintToolbar;
            #endif

            DatabaseGeneral general = DatabaseGeneral.Load();
            MOVE_OFFSET_X = general.toolbarPositionX;
            MOVE_OFFSET_Y = general.toolbarPositionY;

            SceneView.RepaintAll();
        }
Beispiel #12
0
        // PRIVATE METHODS: -----------------------------------------------------------------------

        private void LoadItem(IGameSave gameSave, int profile)
        {
            if (gameSave == null)
            {
                return;
            }

            string key            = this.GetKeyName(profile, gameSave.GetUniqueName());
            string serializedData = DatabaseGeneral.Load().GetDataProvider().GetString(key);

            if (!string.IsNullOrEmpty(serializedData))
            {
                Type   type        = gameSave.GetSaveDataType();
                object genericData = JsonUtility.FromJson(serializedData, type);

                gameSave.OnLoad(genericData);
            }
        }
Beispiel #13
0
        // EXECUTABLE: ----------------------------------------------------------------------------

        public override bool InstantExecute(GameObject target, IAction[] actions, int index)
        {
            AudioMixerGroup mixer = null;

            switch (this.audioMixer)
            {
            case AudioMixerType.DefaultMusicMixer:
                mixer = DatabaseGeneral.Load().musicAudioMixer;
                break;

            case AudioMixerType.Custom:
                mixer = this.mixerGroup;
                break;
            }

            AudioManager.Instance.PlayMusic(this.audioClip, this.fadeIn, this.volume, mixer);
            return(true);
        }
Beispiel #14
0
        // CONSTRUCTORS: --------------------------------------------------------------------------

        public void Update(int profile, List <string> keys)
        {
            Data             data = this.GetCurrentKeys(profile);
            HashSet <string> hash = new HashSet <string>(data.keys);

            foreach (string key in keys)
            {
                if (!hash.Contains(key))
                {
                    hash.Add(key);
                }
            }

            DatabaseGeneral.Load().GetDataProvider().SetString(
                this.GetKey(profile),
                JsonUtility.ToJson(new Data(hash))
                );
        }
Beispiel #15
0
        private IEnumerator CoroutineLoad(int profile, Action callback)
        {
            string key            = this.GetKeyName(profile, this.scenesData.GetUniqueName());
            string serializedData = DatabaseGeneral.Load().GetDataProvider().GetString(key);

            if (DatabaseGeneral.Load().saveScenes)
            {
                object genericData = JsonUtility.FromJson(
                    serializedData,
                    this.scenesData.GetSaveDataType()
                    );

                yield return(this.scenesData.OnLoad(genericData));
            }

            for (int i = this.storage.Count - 1; i >= 0; --i)
            {
                IGameSave item = this.storage[i].target;

                if (item == null)
                {
                    this.storage.RemoveAt(i);
                    continue;
                }

                item.ResetData();
                this.LoadItem(item, profile);
            }

            SaveLoadManager.IsLoading       = false;
            SaveLoadManager.IsProfileLoaded = true;

            if (callback != null)
            {
                callback.Invoke();
            }
            if (this.onLoad != null)
            {
                this.onLoad.Invoke(profile);
            }
        }