Пример #1
0
 // 注册事件 add by TangJian 2018/05/14 19:25:39
 public void RegisterBuffEvent(BuffEventType buffEventType, Func <BuffData, object[], bool> func)
 {
     if (buffEventDic.ContainsKey(buffEventType))
     {
         buffEventDic.Remove(buffEventType);
     }
     buffEventDic.Add(buffEventType, func);
 }
Пример #2
0
 private void HandleBuffEvents(BuffState buffState, BuffEventType eventType)
 {
     if (buffState.Buff.AffectByEventType.TryGetValue(eventType, out var affects))
     {
         foreach (var affect in affects)
         {
             ApplyAffect(buffState, affect);
         }
     }
 }
Пример #3
0
        // 触发事件 add by TangJian 2018/05/14 19:27:44
        public void TriggerBuffEvent(BuffEventType buffEventType, params object[] objects)
        {
            Func <BuffData, object[], bool> func;

            if (buffEventDic.TryGetValue(buffEventType, out func))
            {
                foreach (var item in roleBuffData.buffDataDic)
                {
                    func(item.Value, objects);
                }
            }
        }
Пример #4
0
        void OnGUI()
        {
            GUIStyle boxStyle = new GUIStyle("box");

            var width  = position.size.x - boxStyle.border.horizontal;
            var height = position.size.y - boxStyle.border.vertical;

            var innerBoxWidth  = width - (boxStyle.padding.horizontal + boxStyle.border.horizontal);
            var innerBoxHeight = height - (boxStyle.padding.vertical + boxStyle.border.vertical);

            MyGUIExtend.Instance.ToolbarButton(new Dictionary <string, Action>
            {
                {
                    "读取", (() => { loadBuff(); })
                },
                {
                    "保存", (() => { saveBuff(); })
                }
            });

            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(width), GUILayout.Height(height));

            // 设置路径, 以及存取数据 add by TangJian 2017/11/15 16:22:45
            EditorGUILayout.BeginHorizontal();

            MyGUIExtend.Instance.Foldout("BuffEditor", "路径信息", (() =>
            {
                EditorGUILayout.LabelField(buffDataFile);
            }));

            EditorGUILayout.EndHorizontal();

            // EditorGUILayout.BeginHorizontal();
            // EditorGUILayout.LabelField(prefabPath);
            // if (MyGUI.Button("制作预制体"))
            // {
            //     saveBuff();
            // }
            // EditorGUILayout.EndHorizontal();

            // 编辑区域 add by TangJian 2017/11/15 16:28:19
            EditorGUILayout.BeginHorizontal();

            // // 列表框 add by TangJian 2017/11/15 16:27:46
            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true));
            listScrollViewPos = EditorGUILayout.BeginScrollView(listScrollViewPos);

            for (int i = buffDataList.Count - 1; i >= 0; i--)
            {
                var item = buffDataList[i];

                EditorGUILayout.BeginHorizontal();
                int Index = MyGUIExtend.Instance.ListSingleButton("BuffEditor", item.id, i, (() => { currBuffData = item; }));

                MyGUIExtend.Instance.Mouse_RightDrop(new Dictionary <string, Action>
                {
                    {
                        "删除", (() => { buffDataList.RemoveAt(Index); })
                    },
                    {
                        "复制", (() =>
                        {
                            var buffData = Tools.Json2Obj <BuffData>(Tools.Obj2Json(buffDataList[Index], true));
                            buffDataList.Add(buffData);
                        })
                    }
                });
                EditorGUILayout.EndHorizontal();
            }

            if (MyGUI.Button("+"))
            {
                buffDataList.Add(new BuffData());
            }

            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();


            // 编辑框 add by TangJian 2017/11/15 16:28:46
            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true));
            editScrollViewPos = EditorGUILayout.BeginScrollView(editScrollViewPos);
            if (currBuffData != null)
            {
                currBuffData.id             = MyGUI.TextFieldWithTitle("id", currBuffData.id);
                currBuffData.name           = MyGUI.TextFieldWithTitle("name", currBuffData.name);
                currBuffData.duration       = MyGUI.FloatFieldWithTitle("duration", currBuffData.duration);
                currBuffData.updateInterval = MyGUI.FloatFieldWithTitle("updateInterval", currBuffData.updateInterval);

                currBuffData.attrData = MyGUI.AttrDataField(currBuffData.attrData);

                //
                currAddBuffEventType = (BuffEventType)MyGUI.EnumPopupWithTitle("事件类型", currAddBuffEventType);
                if (MyGUI.Button("添加"))
                {
                    currBuffData.buffEvents.Add(currAddBuffEventType, new List <ActionData>());
                }

                if (MyGUI.Button("移除"))
                {
                    if (currBuffData.buffEvents.ContainsKey(currAddBuffEventType))
                    {
                        currBuffData.buffEvents.Remove(currAddBuffEventType);
                    }
                }

                List <BuffEventType> needRemoveBuffEventList = new List <BuffEventType>();
                foreach (var buffEvent in currBuffData.buffEvents)
                {
                    List <ActionData> actionDataList = buffEvent.Value;
                    DrawActionList(buffEvent.Key.ToString(), ref actionDataList);
                }

                foreach (var item in needRemoveBuffEventList)
                {
                    currBuffData.buffEvents.Remove(item);
                }
            }

            GUILayout.Space(10);
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();


            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }