Esempio n. 1
0
        public static EventBoard CreateNewEventboard()
        {
            var _path = EditorUtility.SaveFilePanel("Create new eventboard", Application.dataPath, "eventboard", "asset");

            if (string.IsNullOrEmpty(_path))
            {
                return(null);
            }

            var _name = System.IO.Path.GetFileName(_path);

            if (_path.StartsWith(Application.dataPath))
            {
                _path = "Assets" + _path.Substring(Application.dataPath.Length);
            }

            EventBoard ebasset = ScriptableObject.CreateInstance <EventBoard>();

            AssetDatabase.CreateAsset(ebasset, _path);
            AssetDatabase.SaveAssets();

            EditorUtility.FocusProjectWindow();

            Selection.activeObject = ebasset;

            return(ebasset);
        }
        public async Task <IHttpActionResult> DeleteEventBoard(int id)
        {
            // 인증 필요

            PetterResultType <EventBoard> petterResultType = new PetterResultType <EventBoard>();
            List <EventBoard>             eventBoards      = new List <EventBoard>();
            EventBoard eventBoard = await db.EventBoards.FindAsync(id);

            if (eventBoard == null)
            {
                return(NotFound());
            }

            eventBoard.StateFlag       = StateFlags.Delete;
            eventBoard.DateDeleted     = DateTime.Now;
            db.Entry(eventBoard).State = EntityState.Modified;

            await db.SaveChangesAsync();

            eventBoards.Add(eventBoard);
            petterResultType.IsSuccessful = true;
            petterResultType.JsonDataSet  = eventBoards;

            return(Ok(petterResultType));
        }
        public void RaiseEvent(EventBoard _eventboard, string eventName, params object[] parameterValues)
        {
            if (_eventboard == null)
            {
                return;
            }

            this.eventBoard = _eventboard;

            if (string.IsNullOrWhiteSpace(eventName))
            {
                return;
            }

            EventBoard.Event foundEvent = FindEventByName(eventName);

            if (foundEvent != null)
            {
                OrderedDictionary <Guid, FRVariable> eventParameters = BuildParameterList(foundEvent.parameters, parameterValues);

                if (foundEvent.parameters.Keys.Count != eventParameters.Keys.Count)
                {
                }

                foundEvent.Raise(eventParameters);
            }
        }
Esempio n. 4
0
        // Editor node initialization
        public override void Init(Graph _graph, Node _node)
        {
            base.Init(_graph, _node);
            // Load custom icon
            icon = EditorHelpers.LoadIcon("eventIcon.png");

            // possibility to hide the default node inspector. Set to false normally.
            disableDefaultInspector    = true;
            disableVariableInspector   = true;
            disableDrawCustomInspector = false;

            // Automatically subscribe to first event in first eventboard
            if (rootGraph.eventboards.Count > 0)
            {
                var eb = rootGraph.eventboards.Keys.Select(x => x.ToString()).ToArray();
                eventBoard = rootGraph.eventboards[Guid.Parse(eb[0])].eventboard;
                if (eventBoard.events != null && eventBoard.events.Count > 0)
                {
                    var _ebKeys = eventBoard.events.Keys.Select(x => x.ToString()).ToArray();
                    lastSelectedEventID = _ebKeys[0];
                    selectedEventID     = _ebKeys[0];
                    lastSelectedEB      = 0;
                    eventBoard.events[Guid.Parse(_ebKeys[0])].RegisterCallEventNode(this);
                }
            }

            nodeRect = new Rect(nodeRect.x, nodeRect.y, 150, 60);
        }
Esempio n. 5
0
        public void DrawNodeInspector(EventBoard _eventBoard, string _currentSelected, out string _selectedID, out int _selectedIDInt)
        {
            if (editorSkin == null)
            {
                editorSkin = EditorHelpers.LoadSkin();
            }

            _selectedID = _currentSelected;


            var _index = 0;

            foreach (var e in _eventBoard.events.Keys)
            {
                if (!string.IsNullOrEmpty(_currentSelected))
                {
                    if (e == Guid.Parse(_currentSelected))
                    {
                        break;
                    }
                }

                _index++;
            }

            _selectedIDInt = _index;             //_currentSelectedIDInt;

            Guid _tmp = Guid.Empty;

            if (!string.IsNullOrEmpty(_currentSelected))
            {
                _tmp = Guid.Parse(_currentSelected);
            }

            if (_eventBoard != null && _eventBoard.events != null && _eventBoard.events.Keys.Count > 0)
            {
                using (new GUILayout.VerticalScope(editorSkin.GetStyle("Box")))
                {
                    GUILayout.Label("Select event:", "boldLabel");

                    var _ebKeys  = _eventBoard.events.Keys.Select(x => x.ToString()).ToArray();
                    var _ebNames = _eventBoard.events.Values.Select(x => x.name != null ? x.name.ToString() : "empty").ToArray();

                    _selectedIDInt = EditorGUILayout.Popup(_selectedIDInt, _ebNames);

                    if (_selectedIDInt >= 0 && _selectedIDInt < _ebKeys.Length)
                    {
                        _selectedID = _ebKeys[_selectedIDInt];
                    }
                }
            }
        }
Esempio n. 6
0
        public void OnEnable()
        {
            if (target == null)
            {
                return;
            }

            if (variableSceneTypes.Keys.Count == 0 || variableSceneTypes == null)
            {
                GetAvailableVariableTypes.GetFlowReactorVariableTypes(out variableSceneTypes);
            }

            eventBoard = (EventBoard)target;
        }
    // Use this for initialization
    void Start()
    {
        functionManager = new FunctionManager();
        functionManager.AddFunction(MoneyFunction);
        functionManager.AddFunction(SourceFunction);
        functionManager.AddFunction(RoundFunction);
        functionManager.AddFunction(PositionFunction);
        functionManager.AddFunction(StealFunction);
        functionManager.AddFunction(ReplaceFunction);

        cardFactory     = this.GetComponent <CardFactory>();
        gameMap         = this.GetComponent <GameMap>();
        act             = this.GetComponent <InterActive>();
        ui              = this.GetComponent <Uicontroller>();
        eventController = this.GetComponent <EventController>();

        eventBoard = this.GetComponentInChildren <EventBoard>();
        eventBoard.leftbuttonEvent += OnMapEffect;

        ticketUI            = ticketUIObj.GetComponent <TicketUI>();
        ticketUI.StockOver += OnStockOver;
        ticketCamera.SetActive(false);
        //ticketUIObj.SetActive(false);

        //注册监听事件
        //设置玩家头像
        int count = 0;

        foreach (var player in players)
        {
            //.................................设置玩家角色......................................新增(采用后删掉)
            int roleNum = PlayerPrefs.GetInt("roleNum" + count.ToString());
            player.setRole(roleImage[roleNum]);
            player.roleName = count;
            player.PD       = player.LoadDataFromJson("/PlayerData" + count.ToString() + ".json");
            count++;
            //.....................................................................................................
            //player.gameController = this;
            player.MoveOver  += OnMoveOver;
            player.SkillOver += OnSkillOver;
        }

        StartGame();
    }
Esempio n. 8
0
 public Eventboards()
 {
     eventboard = null;
 }
        public async Task <IHttpActionResult> PostEventBoard()
        {
            PetterResultType <EventBoard> petterResultType = new PetterResultType <EventBoard>();
            List <EventBoard>             eventBoards      = new List <EventBoard>();
            List <EventBoardFile>         eventBoardFiles  = new List <EventBoardFile>();

            EventBoard eventBoard = new EventBoard();

            if (Request.Content.IsMimeMultipartContent())
            {
                string folder = HostingEnvironment.MapPath(UploadPath.EventBoardPath);
                Utilities.CreateDirectory(folder);

                var provider = await Request.Content.ReadAsMultipartAsync();

                foreach (var content in provider.Contents)
                {
                    string fieldName = content.Headers.ContentDisposition.Name.Trim('"');
                    if (!string.IsNullOrEmpty(content.Headers.ContentDisposition.FileName))
                    {
                        EventBoardFile eventBoardFile = new Models.EventBoardFile();
                        var            file           = await content.ReadAsByteArrayAsync();

                        string fileName = Utilities.additionFileName(content.Headers.ContentDisposition.FileName.Trim('"'));

                        if (!FileExtension.EventBoardExtensions.Any(x => x.Equals(Path.GetExtension(fileName.ToLower()), StringComparison.OrdinalIgnoreCase)))
                        {
                            petterResultType.IsSuccessful = false;
                            petterResultType.JsonDataSet  = null;
                            petterResultType.ErrorMessage = ResultErrorMessage.FileTypeError;
                            return(Ok(petterResultType));
                        }

                        string fullPath = Path.Combine(folder, fileName);
                        File.WriteAllBytes(fullPath, file);
                        string thumbnamil = Path.GetFileNameWithoutExtension(fileName) + "_thumbnail" + Path.GetExtension(fileName);

                        Utilities.ResizeImage(fullPath, thumbnamil, FileSize.EventBoardWidth, FileSize.EventBoardHeight, ImageFormat.Png);

                        // 이벤트게시판 대표 이미지
                        if (fieldName == FieldName.EventFieldName)
                        {
                            eventBoard.FileName = fileName;
                            eventBoard.FilePath = UploadPath.EventBoardPath.Replace("~", "");
                        }

                        eventBoardFile.FileName = fileName;
                        eventBoardFile.FilePath = UploadPath.EventBoardPath.Replace("~", "");

                        eventBoardFiles.Add(eventBoardFile);
                    }
                    else
                    {
                        string str = await content.ReadAsStringAsync();

                        string item = HttpUtility.UrlDecode(str);

                        #region switch case
                        switch (fieldName)
                        {
                        case "MemberNo":
                            eventBoard.MemberNo = int.Parse(item);
                            break;

                        case "Title":
                            eventBoard.Title = item;
                            break;

                        case "Content":
                            eventBoard.Content = item;
                            break;

                        default:
                            break;
                        }
                        #endregion switch case
                    }
                }

                eventBoard.StateFlag    = StateFlags.Use;
                eventBoard.DateCreated  = DateTime.Now;
                eventBoard.DateModified = DateTime.Now;

                // 이벤트게시판 등록
                db.EventBoards.Add(eventBoard);
                int num = await this.db.SaveChangesAsync();

                // 이벤트게시판 파일 등록
                foreach (var item in eventBoardFiles)
                {
                    item.EventBoardNo = eventBoard.EventBoardNo;
                }
                db.EventBoardFiles.AddRange(eventBoardFiles);
                int num1 = await this.db.SaveChangesAsync();

                eventBoards.Add(eventBoard);
                petterResultType.IsSuccessful = true;
                petterResultType.JsonDataSet  = eventBoards;
            }
            else
            {
                petterResultType.IsSuccessful = false;
                petterResultType.JsonDataSet  = null;
            }

            return(Ok(petterResultType));
        }
Esempio n. 10
0
        public void DrawDefaultGUI(GraphEditor _editor, EventBoard _eventBoard)
        {
            if (editorSkin == null)
            {
                editorSkin = EditorHelpers.LoadSkin();
            }

            if (settings == null)
            {
                settings = FREditorSettings.GetOrCreateSettings();
            }

            using (new GUILayout.VerticalScope(editorSkin.GetStyle("Box")))
            {
                GUILayout.Label("Event name:");

                using (new GUILayout.HorizontalScope())
                {
                    newEventName = GUILayout.TextField(newEventName);

                    if (GUILayout.Button("Add Event"))
                    {
                        if (_eventBoard.events == null)
                        {
                            _eventBoard.events = new FlowReactor.OrderedDictionary.OrderedDictionary <Guid, EventBoard.Event>();
                        }

                        _eventBoard.AddNewEvent(newEventName);
                        newEventName = "";
                    }
                }
            }

            if (_eventBoard.events == null)
            {
                return;
            }
            if (_eventBoard.events.Keys.Count == 0)
            {
                return;
            }

            var _events       = _eventBoard.events.Keys.ToList();
            var _statsFoldout = new List <bool>(new bool[_events.Count]);



            GUILayout.Label("Events:", "boldLabel");

            EditorHelpers.DrawUILine();

            try{
                for (int e = 0; e < _events.Count; e++)
                {
                    using (new GUILayout.HorizontalScope("toolbar"))
                    {
                        GUILayout.Space(10);
                        _eventBoard.events[_events[e]].foldout = EditorGUILayout.Foldout(_eventBoard.events[_events[e]].foldout, _eventBoard.events[_events[e]].name);

                        if (e > 0)
                        {
                            if (GUILayout.Button("▲", "toolbarButton", GUILayout.Width(20)))
                            {
                                var _e = _eventBoard.events[_events[e]];
                                _eventBoard.events.RemoveAt(e);
                                _eventBoard.events.Insert(e - 1, _events[e], _e);
                            }
                        }

                        if (e < _events.Count - 1)
                        {
                            if (GUILayout.Button("▼", "toolbarButton", GUILayout.Width(20)))
                            {
                                var _e = _eventBoard.events[_events[e]];
                                _eventBoard.events.RemoveAt(e);
                                _eventBoard.events.Insert(e + 1, _events[e], _e);
                            }
                        }

                        if (GUILayout.Button("x", "toolbarButton", GUILayout.Width(20)))
                        {
                            _eventBoard.events.Remove(_events[e]);
                        }
                    }

                    if (_eventBoard.events[_events[e]].foldout)
                    {
                        using (new GUILayout.VerticalScope(editorSkin.GetStyle("Box")))
                        {
                            var _noCallEventNodes     = false;
                            var _noEventListenerNodes = false;
                            if (_eventBoard.events[_events[e]].callEventNodes != null)
                            {
                                if (_eventBoard.events[_events[e]].callEventNodes.Count == 0)
                                {
                                    _noCallEventNodes = true;
                                }
                            }
                            else
                            {
                                _noCallEventNodes = true;
                            }

                            if (_eventBoard.events[_events[e]].listenerEventNodes != null)
                            {
                                if (_eventBoard.events[_events[e]].listenerEventNodes.Count == 0)
                                {
                                    _noEventListenerNodes = true;
                                }
                            }
                            else
                            {
                                _noEventListenerNodes = true;
                            }

                            if (_noCallEventNodes && _noEventListenerNodes)
                            {
                                EditorGUILayout.HelpBox("Event is not being used in any graph", MessageType.Warning);
                            }

                            using (new GUILayout.HorizontalScope())                     //editorSkin.GetStyle("Box")))
                            {
                                //GUILayout.Label("Event:");
                                _eventBoard.events[_events[e]].name = GUILayout.TextField(_eventBoard.events[_events[e]].name);

                                if (Application.isPlaying)
                                {
                                    if (GUILayout.Button("Call Event", "miniButton"))
                                    {
                                        _eventBoard.events[_events[e]].Raise(null);
                                    }
                                }

                                //if (GUILayout.Button("x", GUILayout.Width(20)))
                                //{
                                //	_eventBoard.events.Remove(_events[e]);
                                //}
                            }

                            using (new GUILayout.HorizontalScope())
                            {
                                GUILayout.Space(20);

                                using (new GUILayout.VerticalScope(editorSkin.GetStyle("BoxLine")))
                                {
                                    if (GUILayout.Button("Add Parameter", "miniButton"))
                                    {
                                        if (_eventBoard.events[_events[e]].parameters == null)
                                        {
                                            _eventBoard.events[_events[e]].parameters = new FlowReactor.OrderedDictionary.OrderedDictionary <Guid, FRVariable>();
                                        }

                                        var menu = new GenericMenu();

                                        foreach (var key in variableSceneTypes.Keys)
                                        {
                                            var _data = new GenericMenuData();
                                            _data.type              = variableSceneTypes[key];
                                            _data.selected          = e;
                                            _data.typeName          = key;
                                            _data.currentEventBoard = _eventBoard;
                                            menu.AddItem(new GUIContent(key), false, AddVariableCallback, _data);
                                        }

                                        menu.ShowAsContext();
                                    }

                                    if (_eventBoard.events[_events[e]].parameters != null)
                                    {
                                        foreach (var p in _eventBoard.events[_events[e]].parameters.Keys)
                                        {
                                            using (new GUILayout.HorizontalScope())
                                            {
                                                GUILayout.Label(_eventBoard.events[_events[e]].parameters[p].typeName, GUILayout.MaxWidth(100));

                                                _eventBoard.events[_events[e]].parameters[p].name = GUILayout.TextField(_eventBoard.events[_events[e]].parameters[p].name);



                                                if (GUILayout.Button("x", "miniButton", GUILayout.Width(20)))
                                                {
                                                    _eventBoard.events[_events[e]].parameters.Remove(p);
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            using (new GUILayout.HorizontalScope())
                            {
                                GUILayout.Space(20);
                                _eventBoard.events[_events[e]].connectedNodeFoldout = EditorGUILayout.Foldout(_eventBoard.events[_events[e]].connectedNodeFoldout, "Connected nodes");
                            }
                            if (_eventBoard.events[_events[e]].connectedNodeFoldout)
                            {
                                using (new GUILayout.HorizontalScope())
                                {
                                    GUILayout.Space(20);
                                    DrawMap(_editor, _eventBoard, _events[e]);
                                }
                            }
                        }
                    }

                    //if (Application.isPlaying && _eventBoard.events[_events[e]].eventListeners != null)
                    //{
                    //	_statsFoldout[e] = EditorGUILayout.Toggle("Stats", _statsFoldout[e]);
                    //	if (_statsFoldout[e])
                    //	{
                    //		using (new GUILayout.VerticalScope())
                    //		{
                    //			GUILayout.Label("Listeners registered to " + _eventBoard.events[_events[e]].name + " :", "boldLabel");

                    //			if (_eventBoard.events[_events[e]].eventListeners != null)
                    //			{
                    //				GUILayout.Label("Listener count: " + _eventBoard.events[_events[e]].eventListeners.Count.ToString());
                    //			}

                    //			for (int l = 0; l < _eventBoard.events[_events[e]].eventListeners.Count; l ++)
                    //			{
                    //				//GUILayout.Label(l.ToString() + " : " + eventBoard.events[_events[e]].eventListeners[l]);
                    //				GUILayout.Label(l.ToString() + " : " + _eventBoard.events[_events[e]].eventListeners[l].graphOwner.name + " - " + _eventBoard.events[_events[e]].eventListeners[l].name);
                    //			}

                    //			if (_eventBoard.events[_events[e]].eventComponentListeners != null)
                    //			{
                    //				GUILayout.Label("-----");
                    //				GUILayout.Label("Scene listeners", "boldLabel");

                    //				GUILayout.Label("Listener count: " + _eventBoard.events[_events[e]].eventComponentListeners.Count.ToString());


                    //				for (int l = 0; l < _eventBoard.events[_events[e]].eventComponentListeners.Count; l ++)
                    //				{
                    //					GUILayout.Label(l.ToString() + " : " + _eventBoard.events[_events[e]].eventComponentListeners[l].name);
                    //				}
                    //			}

                    //		}
                    //	}
                    //}
                }
            }
            catch
            {
            }

            EditorUtility.SetDirty(_eventBoard);
        }
Esempio n. 11
0
        // Display all registered call event nodes and event listener nodes
        public void DrawMap(GraphEditor _editor, EventBoard _eventBoard, Guid _event)
        {
                        #if FLOWREACTOR_DEBUG
            GUI.contentColor = Color.yellow;
            if (GUILayout.Button("clear"))
            {
                _eventBoard.events[_event].callEventNodes     = new List <FlowReactor.Nodes.Node>();
                _eventBoard.events[_event].listenerEventNodes = new List <FlowReactor.Nodes.Node>();
            }
            GUI.contentColor = Color.white;
                        #endif


            using (new GUILayout.VerticalScope(editorSkin.GetStyle("BoxLine")))
            {
                //GUILayout.Label("Call event nodes:");

                if (_eventBoard.events[_event].callEventNodes != null)
                {
                    using (new GUILayout.VerticalScope())
                    {
                        for (int i = 0; i < _eventBoard.events[_event].callEventNodes.Count; i++)
                        {
                            if (_editor != null)
                            {
                                if (_editor.rootGraph == _eventBoard.events[_event].callEventNodes[i].node.rootGraph)
                                {
                                    using (new GUILayout.HorizontalScope())
                                    {
                                        GUI.contentColor = _eventBoard.events[_event].callEventNodes[i].node.color;

                                        if (GUILayout.Button(_eventBoard.events[_event].callEventNodes[i].node.name + " : " + _eventBoard.events[_event].callEventNodes[i].node.rootGraph.name + " / " + _eventBoard.events[_event].callEventNodes[i].node.graphOwner.name, FlowReactorEditorStyles.graphExplorerButton, GUILayout.ExpandWidth(true)))
                                        {
                                            _editor.GotoNode(_eventBoard.events[_event].callEventNodes[i].node);
                                        }

                                        GUI.contentColor = Color.white;
                                    }
                                }
                                else
                                {
                                    GUI.contentColor = _eventBoard.events[_event].callEventNodes[i].node.color;
                                    GUILayout.Label(eventBoard.events[_event].callEventNodes[i].node.name + " : " + _eventBoard.events[_event].callEventNodes[i].node.rootGraph.name + " / " + _eventBoard.events[_event].callEventNodes[i].node.graphOwner.name);
                                    GUI.contentColor = Color.white;
                                }
                            }
                            else
                            {
                                if (_eventBoard.events[_event].callEventNodes[i] == null)
                                {
                                    // graph doesn't exist
                                    _eventBoard.events[_event].callEventNodes.RemoveAt(i);
                                }
                                else
                                {
                                    GUI.contentColor = _eventBoard.events[_event].callEventNodes[i].node.color;
                                    GUILayout.Label(_eventBoard.events[_event].callEventNodes[i].node.name + " : " + _eventBoard.events[_event].callEventNodes[i].node.rootGraph.name + " / " + _eventBoard.events[_event].callEventNodes[i].node.graphOwner.name);
                                    GUI.contentColor = Color.white;
                                }
                            }
                        }
                    }
                }

                //}

                //GUILayout.Space(5);

                //GUI.color = settings.GetColor("eventNodeColor");
                //using (new GUILayout.VerticalScope(editorSkin.GetStyle("FRVariable")))
                //{
                //GUI.color = Color.white;
                //GUILayout.Label("Event listener nodes:");
                if (_eventBoard.events[_event].listenerEventNodes != null)
                {
                    using (new GUILayout.VerticalScope())
                    {
                        for (int i = 0; i < _eventBoard.events[_event].listenerEventNodes.Count; i++)
                        {
                            if (_editor != null)
                            {
                                if (_editor.rootGraph == _eventBoard.events[_event].listenerEventNodes[i].node.rootGraph)
                                {
                                    using (new GUILayout.HorizontalScope())
                                    {
                                        GUI.contentColor = _eventBoard.events[_event].listenerEventNodes[i].node.color;

                                        if (GUILayout.Button(_eventBoard.events[_event].listenerEventNodes[i].node.name + " : " + _eventBoard.events[_event].listenerEventNodes[i].node.rootGraph.name + " / " + _eventBoard.events[_event].listenerEventNodes[i].node.graphOwner.name, FlowReactorEditorStyles.graphExplorerButton, GUILayout.ExpandWidth(true)))
                                        {
                                            _editor.GotoNode(_eventBoard.events[_event].listenerEventNodes[i].node);
                                        }
                                        GUI.contentColor = Color.white;
                                    }
                                }
                                else
                                {
                                    GUI.contentColor = _eventBoard.events[_event].listenerEventNodes[i].node.color;
                                    GUILayout.Label(_eventBoard.events[_event].listenerEventNodes[i].node.name + " : " + _eventBoard.events[_event].listenerEventNodes[i].node.rootGraph.name + " / " + _eventBoard.events[_event].listenerEventNodes[i].node.graphOwner.name);
                                    GUI.contentColor = Color.white;
                                }
                            }
                            else
                            {
                                if (_eventBoard.events[_event].listenerEventNodes[i] == null)
                                {
                                    // graph doesn't exist
                                    _eventBoard.events[_event].listenerEventNodes.RemoveAt(i);
                                }
                                else
                                {
                                    GUI.contentColor = _eventBoard.events[_event].listenerEventNodes[i].node.color;
                                    GUILayout.Label(_eventBoard.events[_event].listenerEventNodes[i].node.name + " : " + _eventBoard.events[_event].listenerEventNodes[i].node.rootGraph.name + " / " + _eventBoard.events[_event].listenerEventNodes[i].node.graphOwner.name);
                                    GUI.contentColor = Color.white;
                                }
                            }
                        }
                    }
                }
            }
        }
 public void Initialize(EventBoard eventBoard)
 {
     this.eventBoard = eventBoard;
 }
Esempio n. 13
0
        public override void DrawCustomInspector()
        {
            if (rootGraph.eventboards.Count == 0)
            {
                EditorGUILayout.HelpBox("No eventboard available in this graph", MessageType.Info);
                return;
            }


            var eb = rootGraph.eventboards.Keys.Select(x => x.ToString()).ToArray();


            if (lastSelectedEB != selectedEB)
            {
                RegisterNode();
            }


            var options = new string[rootGraph.eventboards.Keys.Count];
            var index   = 0;

            foreach (var board in rootGraph.eventboards.Keys)
            {
                if (rootGraph.eventboards[board].eventboard == null)
                {
                    options[index] = "empty";
                }
                else
                {
                    options[index] = rootGraph.eventboards[board].eventboard.name;
                }

                index++;
            }

            if (eventBoardPopup == null)
            {
                eventBoardPopup = new PopUps.GenericStringPopup(options, out selectedEB);
            }

            EditorGUI.BeginChangeCheck();
            using (new GUILayout.VerticalScope(editorSkin.GetStyle("Box")))
            {
                GUILayout.Label("Eventboard:");

                //selectedEB = EditorGUILayout.Popup(selectedEB, ebNames, EditorStyles.popup);

                var _rect = GUILayoutUtility.GetLastRect();
                if (GUILayout.Button(options[selectedEB]))
                {
                    PopupWindow.Show(_rect, eventBoardPopup);
                }
            }

            selectedEB = eventBoardPopup._selected;

            if (eb == null || eb.Length == 0)
            {
                EditorGUILayout.HelpBox("Create or assign a new eventboard", MessageType.Info);
                return;
            }


            if (selectedEB < eb.Length)
            {
                if (rootGraph.eventboards[Guid.Parse(eb[selectedEB])].eventboard != null)
                {
                    if (editor == null || rootGraph.eventboards[Guid.Parse(eb[selectedEB])].eventboard != eventBoard)
                    {
                        eventBoard = rootGraph.eventboards[Guid.Parse(eb[selectedEB])].eventboard;

                        editor = UnityEditor.Editor.CreateEditor(eventBoard) as EventBoardEditor;
                    }

                    if (editor == null)
                    {
                        return;
                    }


                    editor.DrawNodeInspector(eventBoard, selectedEventID, out selectedEventID, out selectedEventIDInt);
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                RegisterNode();
            }


            // EVENT PARAMETERS
            ///////////////////

            if (eventBoard != null && eventBoard.events.Keys.Count > 0)
            {
                GUILayout.Label("Send event parameters:");

                Guid _id = Guid.Empty;

                if (Guid.TryParse(selectedEventID, out _id))
                {
                    if (eventBoard.events.ContainsKey(Guid.Parse(selectedEventID)))
                    {
                        foreach (var ep in eventBoard.events[Guid.Parse(selectedEventID)].parameters.Keys)
                        {
                            var _exists = false;
                            foreach (var p in parameters.Keys)
                            {
                                if (p == ep)
                                {
                                    _exists = true;
                                }
                            }
                            if (!_exists)
                            {
                                Refresh();
                            }
                        }

                        var _parameterKeyList = parameters.Keys.ToList();
                        foreach (var p in _parameterKeyList)
                        {
                            var _exists = false;
                            foreach (var ep in eventBoard.events[Guid.Parse(selectedEventID)].parameters.Keys)
                            {
                                if (p == ep)
                                {
                                    _exists = true;
                                }
                            }
                            if (!_exists)
                            {
                                parameters.Remove(p);
                            }
                        }

                        foreach (var p in parameters.Keys)
                        {
                            using (new GUILayout.HorizontalScope(editorSkin.GetStyle("Box")))
                            {
                                //GUILayout.Label(parameters[p].name);
                                FRVariableGUIUtility.DrawVariable(parameters[p].name, parameters[p], this, false, editorSkin);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 14
0
        public override void DrawCustomInspector()
        {
            base.DrawCustomInspector();

            using (new GUILayout.VerticalScope("Box"))
            {
                GUILayout.Label("Tween ID:", "boldLabel");
                tweenID = GUILayout.TextField(tweenID, GUILayout.Height(18));
            }

            using (new GUILayout.VerticalScope("Box"))
            {
                GUILayout.Label("On Tween Complete Event", "boldLabel");

                useOnTweenCompleteEvent = GUILayout.Toggle(useOnTweenCompleteEvent, "Enable");

                if (useOnTweenCompleteEvent)
                {
                    var eb     = rootGraph.eventboards.Keys.Select(x => x.ToString()).ToArray();
                    var ebName = rootGraph.eventboards.Values.Select(x => x.eventboard != null ? x.eventboard.name.ToString() : "empty").ToArray();

                    GUILayout.Label("Eventboard:");

                    selectedEB = EditorGUILayout.Popup(selectedEB, ebName);

                    if (eb != null || eb.Length > 0)
                    {
                        if (selectedEB < eb.Length)
                        {
                            if (rootGraph.eventboards[Guid.Parse(eb[selectedEB])].eventboard != null)
                            {
                                if (editor == null || rootGraph.eventboards[Guid.Parse(eb[selectedEB])].eventboard != eventBoard)
                                {
                                    eventBoard = rootGraph.eventboards[Guid.Parse(eb[selectedEB])].eventboard;

                                    editor = UnityEditor.Editor.CreateEditor(eventBoard) as EventBoardEditor;
                                }

                                if (editor != null)
                                {
                                    editor.DrawNodeInspector(eventBoard, selectedEventID, out selectedEventID, out selectedEventIDInt);
                                }
                            }
                        }
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("Create or assign a new eventboard", MessageType.Info);
                    }
                }
            }


            GUILayout.Label("Tween Sequence:");

            using (new GUILayout.VerticalScope("TextArea"))
            {
                if (GUILayout.Button("Add"))
                {
                    tweenSequence.Add(new Sequence());
                }

                var _totalDuration = 0f;

                for (int s = 0; s < tweenSequence.Count; s++)
                {
                    using (new GUILayout.VerticalScope("Box"))
                    {
                        using (new GUILayout.HorizontalScope("Toolbar"))
                        {
                            if (s - 1 >= 0)
                            {
                                if (tweenSequence[s].tweenState == Sequence.TweenState.append)
                                {
                                    GUILayout.Label("starts at: " + _totalDuration.ToString());
                                }
                                else
                                {
                                    GUILayout.Label("starts at: " + tweenSequence[s].insertTime);
                                }
                            }
                            else
                            {
                                if (tweenSequence[s].tweenState == Sequence.TweenState.append)
                                {
                                    GUILayout.Label("starts at: 0");
                                }
                                else
                                {
                                    GUILayout.Label("starts at: " + tweenSequence[s].insertTime);
                                }
                            }

                            GUILayout.FlexibleSpace();

                            if (GUILayout.Button("<", "ToolbarButton", GUILayout.Width(25)))
                            {
                            }

                            if (GUILayout.Button(">", "ToolbarButton", GUILayout.Width(25)))
                            {
                            }

                            if (GUILayout.Button("x", "ToolbarButton", GUILayout.Width(25)))
                            {
                                tweenSequence.RemoveAt(s);

                                return;
                            }
                        }

                        using (new GUILayout.HorizontalScope())
                        {
                            tweenSequence[s].tweenState = (Sequence.TweenState)EditorGUILayout.EnumPopup("", tweenSequence[s].tweenState, GUILayout.Width(100));

                            if (tweenSequence[s].tweenState == Sequence.TweenState.insert)
                            {
                                tweenSequence[s].insertTime = EditorGUILayout.FloatField(tweenSequence[s].insertTime);
                            }
                        }

                        using (new GUILayout.HorizontalScope())
                        {
                            tweenSequence[s].tweenObject = (Sequence.TweenObject)EditorGUILayout.EnumPopup("", tweenSequence[s].tweenObject, GUILayout.Width(100));

                            switch (tweenSequence[s].tweenObject)
                            {
                            case Sequence.TweenObject.floatValue:
                                var _varFloat = tweenSequence[s].GetType().GetField("floatValue").GetValue(tweenSequence[s]) as FRVariable;
                                FRVariableGUIUtility.DrawVariable("floatValue", _varFloat, this, false, editorSkin);
                                //FRVariableGUIUtility.DrawVariable(tweenSequence[s].GetType().GetField("floatValue"), tweenSequence[s].floatValue, this, editorSkin);
                                break;

                            case Sequence.TweenObject.intValue:
                                var _varInt = tweenSequence[s].GetType().GetField("intValue").GetValue(tweenSequence[s]) as FRVariable;
                                FRVariableGUIUtility.DrawVariable("intValue", _varInt, this, false, editorSkin);
                                //FRVariableGUIUtility.DrawVariable(tweenSequence[s].GetType().GetField("intValue"), tweenSequence[s].intValue, this, editorSkin);
                                break;

                            case Sequence.TweenObject.gameObject:
                                var _varGO = tweenSequence[s].GetType().GetField("gameObject").GetValue(tweenSequence[s]) as FRVariable;
                                FRVariableGUIUtility.DrawVariable("gameObject", _varGO, this, false, editorSkin);
                                //FRVariableGUIUtility.DrawVariable(tweenSequence[s].GetType().GetField("gameObject"), tweenSequence[s].gameObject, this, editorSkin);
                                break;

                            case Sequence.TweenObject.image:
                                var _varImage = tweenSequence[s].GetType().GetField("image").GetValue(tweenSequence[s]) as FRVariable;
                                FRVariableGUIUtility.DrawVariable("image", _varImage, this, false, editorSkin);
                                //FRVariableGUIUtility.DrawVariable(tweenSequence[s].GetType().GetField("image"), tweenSequence[s].image, this, editorSkin);
                                break;

                            case Sequence.TweenObject.rectTransform:
                                var _varRect = tweenSequence[s].GetType().GetField("rectTransform").GetValue(tweenSequence[s]) as FRVariable;
                                FRVariableGUIUtility.DrawVariable("rectTransform", _varRect, this, false, editorSkin);
                                //FRVariableGUIUtility.DrawVariable(tweenSequence[s].GetType().GetField("rectTransform"), tweenSequence[s].rectTransform, this, editorSkin);
                                break;

                            case Sequence.TweenObject.canvasGroup:
                                var _varCG = tweenSequence[s].GetType().GetField("canvasGroup").GetValue(tweenSequence[s]) as FRVariable;
                                FRVariableGUIUtility.DrawVariable("canvasGroup", _varCG, this, false, editorSkin);
                                //FRVariableGUIUtility.DrawVariable(tweenSequence[s].GetType().GetField("canvasGroup"), tweenSequence[s].canvasGroup, this, editorSkin);
                                break;
                            }
                        }


                        using (new GUILayout.HorizontalScope())
                        {
                            switch (tweenSequence[s].tweenObject)
                            {
                            case Sequence.TweenObject.floatValue:

                                tweenSequence[s].tweenMethodVariables = (Sequence.TweenMethodVariables)EditorGUILayout.EnumPopup("", tweenSequence[s].tweenMethodVariables, GUILayout.Width(100));

                                FRVariableGUIUtility.DrawVariable(tweenSequence[s].targetFloat, this, false, editorSkin);

                                break;

                            case Sequence.TweenObject.intValue:

                                tweenSequence[s].tweenMethodVariables = (Sequence.TweenMethodVariables)EditorGUILayout.EnumPopup("", tweenSequence[s].tweenMethodVariables, GUILayout.Width(100));

                                FRVariableGUIUtility.DrawVariable(tweenSequence[s].targetInt, this, false, editorSkin);

                                break;

                            case Sequence.TweenObject.gameObject:
                                tweenSequence[s].tweenMethodTransform = (Sequence.TweenMethodTransform)EditorGUILayout.EnumPopup("", tweenSequence[s].tweenMethodTransform, GUILayout.Width(100));

                                FRVariableGUIUtility.DrawVariable(tweenSequence[s].target, this, false, editorSkin);
                                break;

                            case Sequence.TweenObject.image:
                                tweenSequence[s].tweenMethodImage = (Sequence.TweenMethodImage)EditorGUILayout.EnumPopup("", tweenSequence[s].tweenMethodImage, GUILayout.Width(100));

                                switch (tweenSequence[s].tweenMethodImage)
                                {
                                case Sequence.TweenMethodImage.DOColor:

                                    FRVariableGUIUtility.DrawVariable(tweenSequence[s].targetColor, this, false, editorSkin);
                                    break;

                                default:

                                    FRVariableGUIUtility.DrawVariable(tweenSequence[s].targetFloat, this, false, editorSkin);
                                    break;
                                }


                                break;

                            case Sequence.TweenObject.rectTransform:
                                tweenSequence[s].tweenMethodTransform = (Sequence.TweenMethodTransform)EditorGUILayout.EnumPopup("", tweenSequence[s].tweenMethodTransform, GUILayout.Width(100));
                                //tweenSequence[s].target = EditorGUILayout.Vector3Field("",tweenSequence[s].target);

                                switch (tweenSequence[s].tweenMethodTransform)
                                {
                                case Sequence.TweenMethodTransform.DOSizeDelta:
                                    FRVariableGUIUtility.DrawVariable(tweenSequence[s].targetVector2, this, false, editorSkin);
                                    break;

                                default:
                                    FRVariableGUIUtility.DrawVariable(tweenSequence[s].target, this, false, editorSkin);
                                    break;
                                }
                                break;

                            case Sequence.TweenObject.canvasGroup:
                                tweenSequence[s].tweenMethodCanvas = (Sequence.TweenMethodCanvas)EditorGUILayout.EnumPopup("", tweenSequence[s].tweenMethodCanvas, GUILayout.Width(100));
                                //tweenSequence[s].target.Value.x = EditorGUILayout.FloatField(tweenSequence[s].target.Value.x);
                                FRVariableGUIUtility.DrawVariable(tweenSequence[s].targetFloat, this, false, editorSkin);
                                break;
                            }
                        }


                        using (new GUILayout.HorizontalScope())
                        {
                            tweenSequence[s].easeType = (Ease)EditorGUILayout.EnumPopup("", tweenSequence[s].easeType, GUILayout.Width(100));
                            tweenSequence[s].duration = EditorGUILayout.FloatField(tweenSequence[s].duration);
                        }
                    }

                    if (tweenSequence[s].tweenState == Sequence.TweenState.append)
                    {
                        _totalDuration += tweenSequence[s].duration;
                    }
                    else
                    {
                        _totalDuration += tweenSequence[s].duration + tweenSequence[s].insertTime;
                    }
                }
            }
        }