Esempio n. 1
0
        public void Initialize(PuzzleEditor Editor, Transform DrawerSystem, List <string> options, ModeUI.ModeUI mode)
        {
            this.Editor = Editor;
            this.Mode   = mode;

            Transform drawer = DrawerSystem.Find("Drawer");

            this.OpenButton  = drawer.Find("OpenDrawer").gameObject;
            this.CloseButton = drawer.Find("CloseDrawer").gameObject;

            this.Inside = drawer.Find("Inside");

            this.OptionPrefab = Resources.Load(FileHelper.OPTION_PATH);

            this.QuickSelect = drawer.Find("QuickSelect");
            this.QuickItems  = new Queue <string>(QUICK_MAX);
            this.QuickObjs   = new Queue <GameObject>(QUICK_MAX);

            this.DrawerOpen = false;
            this.Animator   = drawer.GetComponent <Animator>();

            this.Populate(options);

            this.AudioManager = FindObjectOfType <AudioManager>();
        }
Esempio n. 2
0
        public UIController(PuzzleEditor editor, SelectionSystem selection, Mode.Mode mode,
                            GameController controller, Transform canvas)
        {
            this.Editor     = editor;
            this.Selection  = selection;
            this.Mode       = mode;
            this.Controller = controller;

            this.Initialize(canvas);
        }
Esempio n. 3
0
        public void Initialize(PuzzleEditor editor, string item, Text text, Draggable draggable, bool ableToEdit)
        {
            this.Editor  = editor;
            this.CanEdit = ableToEdit;

            this.Resource = this.Editor.GetResource(item);
            if (this.Resource != null)
            {
                this.Resource.DefineUI(text, draggable, ableToEdit);
            }
        }
Esempio n. 4
0
        public static GameObject CreateOption(PuzzleEditor editor, DrawerController controller,
                                              Object prefab, Transform parent, string name, bool ableToEdit)
        {
            GameObject newObj = (GameObject)GameObject.Instantiate(prefab, parent);

            newObj.name = name;

            Initialize(editor, controller, newObj.transform, ableToEdit, name);

            return(newObj);
        }
Esempio n. 5
0
        public SelectionSystem(PuzzleEditor editor, SelectionManager manager, GameController controller)
        {
            this.Editor     = editor;
            this.Manager    = manager;
            this.Controller = controller;

            this.SingleClick = false;

            this.Manager.Initialize(this.Controller);

            this.Editor.Selection = this;
        }
Esempio n. 6
0
        private static void Initialize(PuzzleEditor editor, DrawerController controller, Transform newObj, bool ableToEdit, string name)
        {
            GameObject buttons = newObj.Find("PlusMinus").gameObject;

            Transform resource = newObj.Find("Resource");
            Transform sprite   = resource.Find("Sprite");

            Text   amountText = resource.Find("Amount").GetComponent <Text>();
            Option optionScp  = newObj.GetComponent <Option>();

            Draggable draggable = sprite.GetComponent <Draggable>();

            InitializeButtons(buttons, ableToEdit);
            InitiliazeSprite(sprite, name);
            draggable.Initialize(controller, optionScp);
            optionScp.Initialize(editor, name, amountText, draggable, ableToEdit);
        }
Esempio n. 7
0
    public override void OnInspectorGUI()
    {
        _databaseComponent = target as DatabaseComponent;

        #region ReloadAll

        if (GUILayout.Button("ReloadAll"))
        {
            // read all categories
            var categories = ServerEditor.Get <List <Category> >(@"Categories", "Download categories", "Download");

            if (categories == null)
            {
                return;
            }

            _databaseComponent.SetCategories(categories);

            // read all puzzles
            List <Puzzle> puzzles = ServerEditor.Get <List <Puzzle> >(@"Puzzles", "Download puzzles", "Download");

            if (puzzles == null)
            {
                return;
            }

            _databaseComponent.SetPuzzles(puzzles);

            // create game objects
            _databaseComponent.ReloadAll();
        }


        #endregion

        #region UpdateData All

        if (GUILayout.Button("UpdateData All"))
        {
            // Update categories
            var categoryComponents = _databaseComponent.GetComponentsInChildren <CategoryComponent>();

            foreach (var categoryComponent in categoryComponents)
            {
                if (categoryComponent.Dirty)
                {
                    CategoryEditor.UpdateServer(categoryComponent);
                }
            }

            //Update puzzles
            var puzzleComponents = _databaseComponent.GetComponentsInChildren <PuzzleComponent>();

            foreach (var puzzleComponent in puzzleComponents)
            {
                if (puzzleComponent.Dirty)
                {
                    PuzzleEditor.UpdateServer(puzzleComponent);
                }
            }
        }

        #endregion

        #region Sync localDB

        if (GUILayout.Button("Sync All with localDB"))
        {
            // read all categories
            var categories = ServerEditor.Get <List <Category> >(@"Categories", "Download categories", "Download");

            if (categories == null)
            {
                return;
            }

            // read all puzzles
            List <Puzzle> puzzles = ServerEditor.Get <List <Puzzle> >(@"Puzzles", "Download puzzles", "Download");

            if (puzzles == null)
            {
                return;
            }

            LocalDBController.DeleteAll <Category>();
            LocalDBController.DeleteAll <Puzzle>();

            foreach (Category category in categories)
            {
                LocalDBController.InsertOrReplace(category);
            }

            foreach (Puzzle puzzle in puzzles)
            {
                LocalDBController.InsertOrReplace(puzzle);
            }
        }

        #endregion
    }
Esempio n. 8
0
 public EditorUI(GameController controller, PuzzleEditor editor, SelectionSystem selection,
                 Mode.Mode mode, Transform canvas) :
     base(controller, editor, selection, mode, canvas)
 {
 }