Beispiel #1
0
    protected override void OnCreate()
    {
        base.OnCreate();

        gameDataSystem           = World.GetOrCreateSystem <GameDataSystem>();
        preTransformGroupBarrier = World.GetOrCreateSystem <PreTransformGroupBarrier>();
    }
 public void Pull()
 {
     this.screen.AddLine("Pulling...");
     GameDataSystem.InitializeAsync(() => {
         this.screen.AddLine("Pull completed.");
         this.Version();
     });
 }
Beispiel #3
0
 private void CreateSystem()
 {
     environmentSystem = new EnvironmentSystem(); //环境
     roleSystem        = new RoleSystem();        //角色系统
     aISystem          = new AISystem();          //AI
     eventSystem       = new EventSystem();       //事件系统
     functionSystem    = new FunctionSystem();    //功能系统
     uISystem          = new UISystem();          //UI系统
     inputSystem       = new InputSystem();       //输入系统
     gameDataSystem    = new GameDataSystem();    //游戏数据系统
 }
        protected override void OnInspectorGUI(GameDataSettings settings, GameDataServiceItem item, System.Action onReset, GUISkin skin)
        {
            if (settings == null)
            {
                return;
            }

            var data = FlowSystem.GetData();

            if (data == null)
            {
                return;
            }

            GUILayout.Label("URL:");
            var newKey = GUILayout.TextArea(settings.url);

            if (newKey != settings.url)
            {
                settings.url = newKey;
                UnityEditor.EditorUtility.SetDirty(settings);
            }

            UnityEditor.EditorGUI.BeginDisabledGroup(item.processing);
            if (GUILayout.Button(item.processing == true ? "Loading..." : "Load", skin.button) == true)
            {
                if (item.processing == false)
                {
                    item.processing = true;

                    // Connecting
                    this.OnEditorAuth(item.authKey, (result) => {
                        //UnityEditor.EditorApplication.delayCall += () => {

                        this.StartCoroutine(this.GetData(settings.url, (res) => {
                            if (res.hasError == false)
                            {
                                GameDataSystem.TryToSaveCSV(res.data);
                            }

                            item.processing = false;
                        }));

                        //};
                    });
                }
            }
            UnityEditor.EditorGUI.EndDisabledGroup();
        }
        public override IEnumerator Auth(string key)
        {
            var settings = this.serviceManager.settings as GameDataSettings;

            return(this.GetData(settings.url, (result) => {
                if (result.hasError == false)
                {
                    GameDataSystem.TryToSaveCSV(result.data);
                }
                else
                {
                    GameDataSystem.TryToLoadCache();
                }
            }));
        }
Beispiel #6
0
        public override System.Collections.Generic.IEnumerator <byte> Auth(string key, ServiceItem serviceItem)
        {
            var settings = this.serviceManager.settings as GameDataSettings;

            return(this.GetData(settings, (result) => {
                if (result.hasError == false)
                {
                    GameDataSystem.TryToSaveCSV(result.data);
                }
                else
                {
                    Debug.LogError(string.Format("[ GameData.GoogleService ] CSV GetData error: {0}", result.errorText));
                    GameDataSystem.TryToLoadCache();
                }
            }));
        }
        public bool Get()
        {
#if UNITY_EDITOR
            if (Application.isPlaying == false)
            {
                return(GameDataSystem.Get(this));
            }
#endif

            if (this.cache.HasValue == true)
            {
                return(this.cache.Value);
            }

            this.cache = GameDataSystem.Get(this);
            return(this.cache.Value);
        }
Beispiel #8
0
        public override void OnInspectorGUI()
        {
            this.DrawServices <GameDataServiceItem>();

            CustomGUI.Splitter();

            GUILayout.Label("Versions", EditorStyles.boldLabel);

            EditorGUI.BeginDisabledGroup(true);

            var currentVersions = GameDataSystem.GetVersionsList();
            var currentVersion  = GameDataSystem.GetCurrentVersion();

            foreach (var ver in currentVersions)
            {
                GUILayout.Toggle(currentVersion == ver, ver.ToString());
            }

            EditorGUI.EndDisabledGroup();
        }
    protected override void OnCreate()
    {
        base.OnCreate();

        EntityQueryDesc queryDesc = new EntityQueryDesc
        {
            All  = new ComponentType[] { ComponentType.ReadOnly <Character>() },
            None = new ComponentType[] { ComponentType.ReadOnly <PlayerCharacter>() }
        };

        zombiesQuery = EntityManager.CreateEntityQuery(queryDesc);

        gameDataSystem      = World.GetOrCreateSystem <GameDataSystem>();
        preTransformBarrier = World.GetOrCreateSystem <PreTransformGroupBarrier>();

        LastSpawnTime    = new NativeArray <float>(1, Allocator.Persistent);
        LastSpawnTime[0] = -999f;

        random = new Random();
        random.InitState(10);
    }
Beispiel #10
0
        public override void EditorLoad(GameDataSettings settings, GameDataServiceItem item)
        {
            if (item.processing == false)
            {
                item.processing = true;

                // Connecting
                this.OnEditorAuth(item.authKey, (result) => {
                    //UnityEditor.EditorApplication.delayCall += () => {

                    this.StartCoroutine(this.GetData(settings, (res) => {
                        if (res.hasError == false)
                        {
                            GameDataSystem.TryToSaveCSV(res.data);
                        }

                        item.processing = false;
                    }));

                    //};
                });
            }
        }
 public void Version()
 {
     this.screen.AddLine(string.Format("UI.Windows GameData version: \t{0}", GameDataSystem.GetCurrentVersionId()));
 }
        public static void Draw(Rect position, SerializedProperty property, GUIContent label)
        {
            if (Application.isPlaying == false)
            {
                GameDataSystem.TryToLoadCache();
            }

            //property.serializedObject.Update();

            var keyProperty = property.FindPropertyRelative("key");

            if (keyProperty != null)
            {
                //GUILayout.BeginHorizontal();
                {
                    var labelWidth = EditorGUIUtility.labelWidth;
                    var offset     = new Vector2(-23f - 100f - labelWidth, -7f - 16f);

                    var indent = EditorGUI.indentLevel * 16f;

                    GUI.Label(new Rect(position.x + indent, position.y, labelWidth - indent, position.height), label);

                    var buttonRect = new Rect(position.x + labelWidth, position.y, position.width - labelWidth, position.height);

                    var style = ME.Utilities.CacheStyle("GameDataKeyDrawer.TextStyle", "inputField", (name) => {
                        var _style      = new GUIStyle(EditorStyles.textField);
                        _style.richText = true;
                        return(_style);
                    });

                    var keyValue = keyProperty.stringValue;
                    var keyFull  = string.Format("[<color=green><b>{1}</b></color>] {0}", keyValue, GameDataSystem.Get(keyValue, GameDataSystem.DEFAULT_EDITOR_VERSION));
                    if (GUI.Button(buttonRect, keyFull, style) == true)
                    {
                        var     rect   = position;
                        Vector2 vector = GUIUtility.GUIToScreenPoint(new Vector2(position.x, position.y));
                        rect.x = vector.x;
                        rect.y = vector.y;

                        var popup = new Popup()
                        {
                            title = "GameData Keys", screenRect = new Rect(rect.x + labelWidth + offset.x, rect.y + rect.height + offset.y, rect.width - labelWidth - offset.x, 200f), searchText = keyProperty.stringValue, separator = '|'
                        };
                        popup.ItemByPath("None", () => {
                            keyProperty.serializedObject.Update();
                            keyProperty.stringValue = string.Empty;
                            keyProperty.serializedObject.ApplyModifiedProperties();

                            EditorUtility.SetDirty(keyProperty.serializedObject.targetObject);
                        });

                        foreach (var key in GameDataSystem.GetKeys())
                        {
                            var finalKey     = key;
                            var finalKeyFull = string.Format("{0} <color=grey>({1})</color>", finalKey, GameDataSystem.Get(finalKey, GameDataSystem.DEFAULT_EDITOR_VERSION));
                            popup.ItemByPath(finalKeyFull, () => {
                                keyProperty.serializedObject.Update();
                                keyProperty.stringValue = finalKey;
                                keyProperty.serializedObject.ApplyModifiedProperties();

                                EditorUtility.SetDirty(keyProperty.serializedObject.targetObject);
                            });
                        }

                        popup.Show();
                    }

                    var textFieldRect = buttonRect;                    //GUILayoutUtility.GetLastRect();
                    EditorGUIUtility.AddCursorRect(textFieldRect, MouseCursor.Text);

                    const float sizeX = 32f;
                    const float sizeY = 16f;
                    HierarchyEditor.DrawLabel(new Rect(textFieldRect.x + textFieldRect.width - sizeX, textFieldRect.y, sizeX, sizeY), HierarchyEditor.colors.layoutElements, "GD");

                    if (GameDataSystem.ContainsKey(keyProperty.stringValue) == false)
                    {
                        HierarchyEditor.DrawLabel(new Rect(textFieldRect.x + textFieldRect.width - sizeX - 54f, textFieldRect.y, 54f, sizeY), HierarchyEditor.colors.error, "NO KEY");
                    }
                    else
                    {
                        HierarchyEditor.DrawLabel(new Rect(textFieldRect.x + textFieldRect.width - sizeX - 54f, textFieldRect.y, 54f, sizeY), HierarchyEditor.colors.components, GameDataSystem.DEFAULT_EDITOR_VERSION.ToString());
                    }
                }
                //GUILayout.EndHorizontal();
            }

            //property.serializedObject.ApplyModifiedProperties();
        }