예제 #1
0
        private void SetInfo(FileObject fileObject)
        {
            playerGestureDatas.Clear();
            string json = ASCIIEncoding.UTF8.GetString(fileObject.Buffet);

            if (JsonCheckTool.IsJson(json))
            {
                playerGestureDatas = Newtonsoft.Json.JsonConvert.DeserializeObject <List <PlayerGestureData> >(json);
            }

            if (isOpenSetGesturePanel)
            {
                Canvas canvas = new GameObject("[SetCanvas]").AddComponent <Canvas>();
                GameObject.DontDestroyOnLoad(canvas.gameObject);
                canvas.renderMode = RenderMode.ScreenSpaceOverlay;
                canvas.gameObject.AddComponent <CanvasScaler>();
                canvas.gameObject.AddComponent <GraphicRaycaster>();
                canvas.sortingOrder = 100;
                if (!FindObjectOfType <EventSystem>())
                {
                    EventSystem eventSystem = new GameObject("EventSystem").AddComponent <EventSystem>();
                    eventSystem.gameObject.AddComponent <StandaloneInputModule>();
                }
                SourcesManager.LoadSources <SetGesturePanel>("SetGesturePanel", canvas.transform);
            }
        }
예제 #2
0
    /// <summary>
    /// 创建面板
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="windowTypeEnum"></param>
    /// <returns></returns>
    public static T CreatePanel <T>(Transform parent) where T : BasePanel
    {
        T t = default(T);

        T[] ts = Resources.LoadAll <T>("UIPanel");
        if (ts.Length > 0)
        {
            t = SourcesManager.LoadSources <T>(ts[0], parent);
        }
        else
        {
            Debug.Log("资源中不存在" + t.GetType().Name);
        }
        return(t);
    }
예제 #3
0
        /// <summary>
        /// 设置面板
        /// </summary>
        /// <param name="_eventWindows"></param>
        public void SetPanel(EventWindows _eventWindows)
        {
            transform.localScale = Vector3.one;
            eventWindows         = _eventWindows;
            foreach (var item in PlayerManager.Instance.gestureEvents)
            {
                bool isF = false;
                for (int i = 0; i < eventWindows.events.Count; i++)
                {
                    if (eventWindows.events[i].playerGestureEventInfo.eventName == item.eventName && eventWindows.events[i].playerGestureEventInfo.eventDetailed == item.eventDetailed)
                    {
                        isF = true;
                        break;
                    }
                }
                if (isF)
                {
                    continue;
                }
                Event @event;
                if (_events.Count > 0)
                {
                    @event = _events[0];
                    @event.transform.parent     = Content;
                    @event.transform.localScale = Vector3.one;
                    _events.Remove(@event);
                }
                else
                {
                    @event = SourcesManager.LoadSources <Event>("Event", Content.transform);
                }
                @event.Init(item, eventWindows);
                @event.eventButton.OnClick.AddListener(() =>
                {
                    Detailed.transform.localScale = Vector3.one;
                    value.text             = @event.playerGestureEventInfo.eventDetailed;
                    playerGestureEventInfo = @event.playerGestureEventInfo;

                    ReturnEventButton(@event);
                });
                events.Add(@event);
            }
        }
예제 #4
0
    /// <summary>
    /// 创建面板
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="windowTypeEnum"></param>
    /// <returns></returns>
    public static T CreatePanel <T>(WindowTypeEnum windowTypeEnum, UIPanelStateEnum panelStateEnum = UIPanelStateEnum.Open) where T : BasePanel
    {
        T t = default(T);

        t = GetPanel <T>(windowTypeEnum);
        if (t == null)
        {
            T[] ts = Resources.LoadAll <T>("UIPanel");
            if (ts.Length > 0)
            {
                t = SourcesManager.LoadSources <T>(ts[0], windowsDic[windowTypeEnum].transform);
                if (!PanelDic.ContainsKey(windowTypeEnum))
                {
                    PanelDic.Add(windowTypeEnum, new List <BasePanel> {
                        t
                    });
                }
                else
                {
                    PanelDic[windowTypeEnum].RemoveNull();
                    PanelDic[windowTypeEnum].Add(t);
                }
            }
            else
            {
                Debug.Log("资源中不存在" + t.GetType().Name);
            }
        }
        switch (panelStateEnum)
        {
        case UIPanelStateEnum.Open:
            t.Open();
            break;

        case UIPanelStateEnum.Hide:
            t.Hide();
            break;

        default:
            break;
        }
        return(t);
    }
예제 #5
0
        //封装手势按钮天机方法,返回当前按钮
        private Gesture AddGesture(PlayerGestureData playerGesture)
        {
            Gesture gesture = SourcesManager.LoadSources <Gesture>("Gesture", Content);//在对象池中生成

            gestures.Add(gesture);
            gesture.Init(playerGesture, this);//初始化按钮
            gesture.gestureButton.OffChoice.AddListener(() =>
            {
                gestureWindows.Recovery();
                selectionWindow.Recovery();
                eventWindows.Recovery();
            });//添加按钮事件
            gesture.gestureButton.OnChoice.AddListener(() =>
            {
                gestureWindows.Recovery();
                eventWindows.Recovery();
                selectionWindow.SetPanel(gesture);
            });
            return(gesture);
        }
예제 #6
0
        /// <summary>
        /// 封装的添加事件按钮
        /// </summary>
        /// <param name="_playerGestureEventInfo"></param>
        public void AddEvent(PlayerGestureEventInfo _playerGestureEventInfo)
        {
            PlayerGestureEventInfo playerGestureEventInfo = new PlayerGestureEventInfo();

            playerGestureEventInfo.eventDetailed = _playerGestureEventInfo.eventDetailed;
            playerGestureEventInfo.eventName     = _playerGestureEventInfo.eventName;
            playerGestureEventInfo.gestureName   = gesture.playerGestureData.playerGestureInfo.GestureName;
            //playerGestureEventInfo.isFindGesture = _playerGestureEventInfo.isFindGesture;
            playerGestureEventInfo.playerIndex = _playerGestureEventInfo.playerIndex;
            Event @event;

            if (_events.Count > 0)
            {
                @event = _events[0];
                @event.transform.parent     = Content;
                @event.transform.localScale = Vector3.one;
                _events.Remove(@event);
            }
            else
            {
                @event = SourcesManager.LoadSources <Event>("Event", Content);
            }
            @event.Init(playerGestureEventInfo, this);
            @event.eventButton.OffChoice.AddListener(() =>
            {
                eventInfoWindows.transform.localScale = Vector3.zero;
            });
            @event.eventButton.OnChoice.AddListener(() =>
            {
                eventInfoWindows.transform.localScale = Vector3.one;
                eventInfoWindows.SetPanel(@event, this);
            });
            events.Add(@event);
            PlayerGestureManager.Instance.ReturnGestureEvent(@event.playerGestureEventInfo);
            ReturnEventButton(@event);
            //for (int i = 0; i < events.Count; i++)
            //{

            //    Debug.Log(events[i].playerGestureEventInfo.playerIndex);
            //}
        }