Exemplo n.º 1
0
        private void ShowWordsInside_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item       = (MenuItem)sender;
            string   simplified = item.Tag.ToString();

            UiLayer.ShowWordsInside_SidePanel(simplified);
        }
Exemplo n.º 2
0
    /// <summary>
    /// 显示Ui, 以及关联Ui
    /// </summary>
    /// <param name="type"></param>
    /// <param name="layer"></param>
    /// <param name="dataList"></param>
    /// <returns></returns>
    private BaseUi Show(Type type, UiLayer layer = UiLayer.Normal, params object[] dataList)
    {
        HideMutex(type, layer);

        List <Type> linkedList = UiRelations.Instance.GetLinkedList(type);

        if (linkedList == null || linkedList.Count <= 0)
        {
            return(null);
        }
        BaseUi mainUi   = null;
        Type   tempType = linkedList[0];

        linkedList.RemoveAt(0);
        linkedList.Add(tempType);
        for (int i = 0; i < linkedList.Count; i++)
        {
            BaseUi ui = GetUiCreateWhenNotFind(linkedList[i]);
            if (ui != null)
            {
                if (ui.GetType() == type)
                {
                    if (layer != UiLayer.Normal)
                    {
                        ui.layer = layer;
                    }
                    mainUi = ui;
                }
                ui.Show(dataList);
            }
        }
        return(mainUi);
    }
Exemplo n.º 3
0
 private void SearchBar_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         UiLayer.ShowResult();
     }
 }
Exemplo n.º 4
0
        private void ShowDecompositionTree_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item      = (MenuItem)sender;
            char     character = item.Tag.ToString()[0];

            if (character.IsNotExtraCharacter())
            {
                UiLayer.ShowDecompositionTreeOfCharacter(character);
            }
        }
Exemplo n.º 5
0
        private void CharactersWithComponent_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item      = (MenuItem)sender;
            char     component = item.Tag.ToString()[0];

            if (component.IsNotExtraCharacter())
            {
                UiLayer.ShowCharsWithComponent_SidePanel(component);
            }
        }
Exemplo n.º 6
0
    public void ReenableInteractionOnLayersBelow(UiLayer uiLayer)
    {
        GameObject inputBlocker;

        if (_inputBlockerDictionary.TryGetValue(uiLayer, out inputBlocker))
        {
            _inputBlockerDictionary.Remove(uiLayer);
            Destroy(inputBlocker);
        }
    }
Exemplo n.º 7
0
        private void WordsWithCharacter_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item      = (MenuItem)sender;
            char     character = item.Tag.ToString()[0];

            if (character.IsNotExtraCharacter())
            {
                UiLayer.ShowWordsWithCharacter_SidePanel(character);
            }
        }
Exemplo n.º 8
0
 private int GetLayerIndex(UiLayer layer)
 {
     for (int i = 0; i < layers.Length; i++)
     {
         if (layers[i] == layer)
         {
             return(i);
         }
     }
     return(0);
 }
Exemplo n.º 9
0
    /// <summary>
    /// 创建层
    /// </summary>
    /// <param name="layer"></param>
    /// <param name="goParent"></param>
    /// <param name="depthStart"></param>
    private void CreateNewLayer(UiLayer layer, GameObject goParent, int depthStart)
    {
        GameObject go = GameObjectUtility.CreateGameObject();

        go.name = layer.ToString();
        go.AddComponent <UIPanel>().depth = depthStart;
        GameObjectUtility.AddUiChild(goParent, go);
        go.layer          = LayerMask.NameToLayer(layer.ToString());
        layerGoDic[layer] = go;
        CreateLayerCamera(layer, LayerMask.NameToLayer(layer.ToString()), go);
    }
Exemplo n.º 10
0
 /// <summary>
 /// 给UiPnlModelBackground添加点击事件
 /// </summary>
 /// <param name="ui"></param>
 private void AddClickEvent(BaseUi ui)
 {
     if (ui.model && ui.autoClickHide)
     {
         UiLayer layer                 = ui.layer;
         UiPnlModelBackground back     = ui.modelBackground.GetComponent <UiPnlModelBackground>();
         BoxCollider          collider = UiUtility.AddIfMissing <BoxCollider>(back.spriteBack.gameObject);
         collider.isTrigger = true;
         UIEventListener.Get(back.spriteBack.gameObject).onClick = go => ui.Hide();
         UiModelTool.ChangeTransformLayer(ui.modelBackground.gameObject, layer.ToString());
     }
 }
Exemplo n.º 11
0
        public MainWindow()
        {
            InitializeComponent();

            //Needed to be able to print asian characters to the console
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            UiLayer.SetWindow(this);
            UiLayer.InitializeStatistics();
            UiLayer.InitializeSentenceExamples();
            UiLayer.ShowSomeRandomWords();
        }
Exemplo n.º 12
0
 /// <summary>
 /// ui显示方法, 调用BaseUi的显示方法
 /// </summary>
 /// <param name="ui"></param>
 /// <param name="layer"></param>
 /// <param name="dataList"></param>
 /// <returns></returns>
 private BaseUi Show(BaseUi ui, UiLayer layer = UiLayer.Normal, params object[] dataList)
 {
     HideMutex(ui.GetType(), layer);
     if (ui != null)
     {
         if (layer != UiLayer.Normal)
         {
             ui.layer = layer;
         }
         ui.Show(dataList);
     }
     return(ui);
 }
Exemplo n.º 13
0
    /// <summary>
    /// 初始化所有层
    /// </summary>
    private void InitLayers()
    {
        layerGoDic     = new Dictionary <UiLayer, GameObject>();
        layerCameraDic = new Dictionary <string, Camera>();
        List <UiLayer> layers = new List <UiLayer>();

        for (UiLayer i = UiLayer.TopMost; i >= UiLayer.BottomMost; i--)
        {
            layers.Add(i);
            CreateNewLayer(i, uiRootGo, (int)i * 1000);
        }
        autoDepth = new UiAutoDepth(layers.ToArray());
    }
Exemplo n.º 14
0
        public bool GetLayer <TLayer>(out UiLayer layer) where TLayer : UiLayer
        {
            layer = null;

            layer = layers.Find(l => l is TLayer);

            if (layer == null)
            {
                Debug.Log($"layer {nameof(TLayer)} not found");
            }

            return(layer);
        }
Exemplo n.º 15
0
    /// <summary>
    /// 显示UI特效
    /// </summary>
    /// <param name="effect"></param>
    /// <param name="layerName"></param>
    public static void ShowEffect(TextureEffect effect, UiLayer layerName = UiLayer.Tips)
    {
        string    layer  = Enum.GetName(typeof(UiLayer), layerName);
        Transform parent = _uiBind.CanvasParentList[layerName];

        if (parent == null)
        {
            Debug.LogError("ShowUIView 层级错误,使用了存在不存在的层:" + layer);
            return;
        }
        effect.transform.SetLayer(Layers.Ui);
        effect.gameObject.transform.SetParent(parent, false);
    }
Exemplo n.º 16
0
 private void AutoResetDepth(UiLayer layer = UiLayer.All)
 {
     if (layer == UiLayer.All)
     {
         for (int i = 0; i < layers.Length; i++)
         {
             ResetSingleDepth(layers[i]);
         }
     }
     else
     {
         ResetSingleDepth(layer);
     }
 }
Exemplo n.º 17
0
 /// <summary>
 /// 每次重置把深度距离缩小10倍
 /// </summary>
 /// <param name="layer"></param>
 private void ResetSpace(UiLayer layer)
 {
     if (layerDataDic.ContainsKey(layer))
     {
         if (layerDataDic[layer].space <= 1)
         {
             LoggerManager.Instance.Error("UiAutoDepth's UILayer {0} space is out of range.", layer);
         }
         else
         {
             layerDataDic[layer].space /= 10;
         }
     }
 }
Exemplo n.º 18
0
        private void CharacterAndPinyin_MouseUp(object sender, RoutedEventArgs e)
        {
            MouseButtonEventArgs ev = (MouseButtonEventArgs)e;

            if (ev.ChangedButton == MouseButton.Left)
            {
                TextBlock textBlock = (TextBlock)sender;
                char      character = textBlock.Text[0];
                if (character.IsNotExtraCharacter())
                {
                    UiLayer.ShowDecompositionTreeOfCharacter(character);
                    UiLayer.ShowCharsWithComponent_SidePanel(character);
                    UiLayer.ShowWordsWithCharacter_SidePanel(character);
                }
            }
        }
Exemplo n.º 19
0
 private void ResetSingleDepth(UiLayer layer)
 {
     if (uiDic.ContainsKey(layer))
     {
         List <UIPanel> list = uiDic[layer];
         if (list != null && list.Count > 0)
         {
             int start = (int)layer * DefaultLayerDepth + 1;
             for (int i = 0; i < list.Count; i++)
             {
                 list[i].depth = start;
                 ResetPanelsDepthInPanel(list[i].transform, list[i].depth);
                 ResetUiModelBackgroundDepth(list[i], list[i].depth);
                 start += layerDataDic[layer].space;
             }
         }
     }
 }
Exemplo n.º 20
0
    /// <summary>
    /// 添加一个显示的ui
    /// </summary>
    /// <param name="ui"></param>
    /// <param name="layer"></param>
    public void Add(UIPanel ui, UiLayer layer)
    {
        if (ui != null && uiDic.ContainsKey(layer) && (!uiDic[layer].Contains(ui)))
        {
            uiDic[layer].Add(ui);
            if (layerDic.ContainsKey(ui))
            {
                LoggerManager.Instance.Warn("Layer dictionary contained ui nameed {0}", ui.name);
            }
            else
            {
                layerDic.Add(ui, layer);
            }
            ui.transform.SetAsLastSibling();

            LayerData layerData = layerDataDic[layer];
            if (uiDic[layer].Count > 1) // 一层2个Ui的深度初始化
            {
                ui.depth = uiDic[layer][uiDic[layer].Count - 2].depth + layerData.space;
                if (ui.depth >= layerData.endDepth)
                {
                    AutoResetDepth(layer);
                }
            }
            else
            {
                ui.depth = layerData.startDepth; // 一层1个Ui的深度初始化
            }

            ResetPanelsDepthInPanel(ui.transform, ui.depth);
            ResetUiModelBackgroundDepth(ui, ui.depth);

            List <UIPanel> panelListInLayer = uiDic[layer];
            int            count            = panelListInLayer.Count;
            if (count >= 2)
            {
                BaseUi baseUi = GetBaseUiByPanel(panelListInLayer[count - 2]);
                if (baseUi != null)
                {
                    baseUi.Overlaid(); // 被覆盖的Ui进行覆盖操作
                }
            }
        }
    }
Exemplo n.º 21
0
 public void Remove(UIPanel ui)
 {
     if (ui != null && layerDic.ContainsKey(ui))
     {
         UiLayer        layer     = layerDic[ui];
         List <UIPanel> panelList = uiDic[layer];
         int            count     = panelList.Count;
         if (count >= 2)
         {
             BaseUi baseUi = GetBaseUiByPanel(panelList[count - 2]);
             if (baseUi != null)
             {
                 baseUi.RemoveOverlay();
             }
         }
         uiDic[layer].Remove(ui);
         layerDic.Remove(ui);
     }
 }
Exemplo n.º 22
0
    public void SortShowingUi(List <BaseUi> uiList)
    {
        var sortingUis = new List <BaseUi>();

        for (int i = 0; i < layers.Length; i++)
        {
            UiLayer layer = layers[i];
            sortingUis.Clear();
            for (int j = 0; j < uiList.Count; j++)
            {
                BaseUi ui = uiList[i];
                if (ui.layer == layer)
                {
                    sortingUis.Add(ui);
                }
            }
            SortLayerUi(sortingUis);
        }
    }
Exemplo n.º 23
0
    /// <summary>
    ///  创建每一层的摄像机
    /// </summary>
    /// <param name="layer"></param>
    /// <param name="layerMask"></param>
    /// <param name="cameraParent"></param>
    private void CreateLayerCamera(UiLayer layer, int layerMask, GameObject cameraParent)
    {
        GameObject go = GameObjectUtility.CreateGameObject();

        go.name = layer + "Camera";
        Camera   camera   = go.AddComponent <Camera>();
        UICamera uiCamera = go.AddComponent <UICamera>();

        uiCamera.eventReceiverMask = (1 << layerMask);
        uiCamera.allowMultiTouch   = false;
        camera.clearFlags          = CameraClearFlags.Depth;
        camera.cullingMask         = (1 << layerMask);
        camera.orthographic        = true;
        camera.orthographicSize    = 1f;
        camera.nearClipPlane       = -10f;
        camera.farClipPlane        = 10f;
        camera.depth = (int)layer;
        GameObjectUtility.AddUiChild(cameraParent, go);
        camera.transform.localPosition = new Vector3(0, 0, -10f);
        layerCameraDic.Add(layer.ToString(), camera);
    }
Exemplo n.º 24
0
    private static void ShowUiView(UiInstance view, UiLayer layerName)
    {
        if (view == null)
        {
            Debug.LogError("ShowUiView View Is null, layer:" + layerName);
            return;
        }
        string layer = Enum.GetName(typeof(UiLayer), layerName);

        var parent = _uiBind.CanvasParentList[layerName];

        if (parent == null)
        {
            Debug.LogError("ShowUIView 层级错误,使用了存在不存在的层:" + layer);
            return;
        }

        view.transform.SetParent(parent, false);
        view.transform.SetAsLastSibling();
        view.gameObject.SetActiveSafe(true);
    }
Exemplo n.º 25
0
    public void DisableInteractionOnLayersBelow(UiLayer uiLayer)
    {
        RectTransform layerTransform;

        if (_layerDictionary.TryGetValue(uiLayer, out layerTransform))
        {
            GameObject inputBlocker;
            if (_inputBlockerDictionary.TryGetValue(uiLayer, out inputBlocker) == false)
            {
                inputBlocker = new GameObject("Input Blocker");
                inputBlocker.transform.SetParent(layerTransform, false);
                inputBlocker.transform.SetAsFirstSibling();
                RectTransform rectTransform = inputBlocker.AddComponent <RectTransform>();
                rectTransform.sizeDelta = GetComponent <RectTransform>().sizeDelta;
                // inputBlocker.AddComponent<Button>();
                Image image = inputBlocker.AddComponent <Image>();
                image.color = new Color(0.0f, 0.0f, 0.0f, 0.0f);
                _inputBlockerDictionary.Add(uiLayer, inputBlocker);
            }
        }
    }
Exemplo n.º 26
0
 public void Clear(UiLayer layer = UiLayer.All)
 {
     if (layerDic != null)
     {
         layerDic.Clear();
     }
     InitLayerData();
     if (layer == UiLayer.All)
     {
         foreach (var item in uiDic)
         {
             item.Value.Clear();
         }
     }
     else
     {
         if (uiDic.ContainsKey(layer))
         {
             uiDic[layer].Clear();
         }
     }
 }
Exemplo n.º 27
0
    private static void SetDeltaInfo2(UiLayer layer, Canvas canvas, Vector2 size, float safeHeightRadio, float bottomGiveY)
    {
        var rect = canvas.GetComponent(typeof(RectTransform)) as RectTransform;

        if (rect == null)
        {
            return;
        }

        var s = size;

        s.y           *= safeHeightRadio;
        s.y           -= bottomGiveY;
        rect.sizeDelta = s;

        var pos = Vector3.zero;
        var a   = size.y - rect.sizeDelta.y;

        pos.y -= a / 2;
        pos.y += bottomGiveY;
        rect.anchoredPosition = pos;
    }
Exemplo n.º 28
0
    public static void R <T>(string viewPath, UiLayer layer, UiLoadType loadType) where T : UiInstance
    {
        var fullName = typeof(T).FullName;

        if (fullName != null && RegisteredUi.ContainsKey(fullName))
        {
            return;
        }
        var uiInfo = new UiInfo
        {
            Type     = typeof(T),
            ViewPath = viewPath,
            Layer    = layer,
            LoadType = loadType,
        };
        var name = typeof(T).FullName;

        if (name != null)
        {
            RegisteredUi[name] = uiInfo;
        }
    }
Exemplo n.º 29
0
    public void CloseAllUiByUiLayer(UiLayer layer)
    {
        List <BaseUi> boBeHideUi = null;

        foreach (var ui in UiRelations.Instance.UiDic.Values)
        {
            if (ui.layer == layer && ui.IsShowing && ui.IsVisible)
            {
                if (boBeHideUi == null)
                {
                    boBeHideUi = new List <BaseUi>();
                }
                boBeHideUi.Add(ui);
            }
        }

        if (boBeHideUi != null)
        {
            for (int i = 0; i < boBeHideUi.Count; i++)
            {
                boBeHideUi[i].Hide();
            }
        }
    }
Exemplo n.º 30
0
    void SetLogicUiLayerByObjectLayer()
    {
        int     layer      = gameObject.layer;
        UiLayer logicLayer = UiLayer.Normal;

        if (layer == LayerMask.NameToLayer(UiLayer.TopMost.ToString()))
        {
            logicLayer = UiLayer.TopMost;
        }
        else if (layer == LayerMask.NameToLayer(UiLayer.Top.ToString()))
        {
            logicLayer = UiLayer.Top;
        }
        else if (layer == LayerMask.NameToLayer(UiLayer.ShelterModel.ToString()))
        {
            logicLayer = UiLayer.ShelterModel;
        }
        else if (layer == LayerMask.NameToLayer(UiLayer.UiModel.ToString()))
        {
            logicLayer = UiLayer.UiModel;
        }
        else if (layer == LayerMask.NameToLayer(UiLayer.Normal.ToString()))
        {
            logicLayer = UiLayer.Normal;
        }
        else if (layer == LayerMask.NameToLayer(UiLayer.Bottom.ToString()))
        {
            logicLayer = UiLayer.Bottom;
        }
        else if (layer == LayerMask.NameToLayer(UiLayer.BottomMost.ToString()))
        {
            logicLayer = UiLayer.BottomMost;
        }

        this.layer = logicLayer;
    }
Exemplo n.º 31
0
        /// <summary>
        /// Initializes class and components
        /// </summary>
        protected override void Initialize()
        {
            this.Components.Add(this.colorStream);

            // Create the avatar animator
            this.animator = new AvatarAnimator(this);
            //this.Components.Add(this.animator);

            // Add XUI Component
            _G.Game = this;

            // add core components
            Components.Add(new GamerServicesComponent(this));

            // add layers
            UiLayer = new UiLayer(this);
            _G.UI = UiLayer;

            // add other components
            _G.GameInput = new GameInput((int)E_GameButton.Count, (int)E_GameAxis.Count);
            GameControls.Setup(); // initialise mappings

            camera = new Camera(this);
            camera.Position = Vector3.Forward * 12;

            this.Services.AddService(typeof(Camera), this.camera);

            List<Camera> kinectCamera = new List<Camera>();
            kinectCamera.Add(new Camera(this));
            kinectCamera[0].Position = Vector3.Zero;
            kinectCamera[0].View = Matrix.CreateLookAt(
                   new Vector3(0.0f, 0.0f, 0.0f),
                   new Vector3(0.0f, 0.0f, 1.0f),
                   Vector3.Down);
            this.Services.AddService(typeof(List<Camera>), kinectCamera);

            this.Components.Add(camera);

            base.Initialize();
        }
Exemplo n.º 32
0
    protected override void Initialize()
    {
        // TODO: Add your initialization logic here

            _G.Game = this;

            // add core components
            Components.Add(new GamerServicesComponent(this));

            // add layers
            UiLayer = new UiLayer();
            _G.UI = UiLayer;

            // add other components
            _G.GameInput = new GameInput((int)E_GameButton.Count, (int)E_GameAxis.Count);
            GameControls.Setup(); // initialise mappings

            //Highscore
            LoadHighscore();

            //State Actions
            stateManager = new StateManager();
            stateManager.InitializeAction(State.TITLE, Keys.Escape, State.EXIT);

            stateManager.InitializeAction(State.PLAY, Keys.Escape, State.PAUSE);
            stateManager.InitializeAction(State.PAUSE, Keys.Escape, State.PLAY);
            stateManager.InitializeAction(State.OPTIONS, Keys.Escape, State.TITLE);
            stateManager.InitializeAction(State.VIEWGAMES, Keys.Escape, State.TITLE);
            stateManager.InitializeAction(State.END, Keys.Escape, State.EXIT);
            stateManager.InitializeAction(State.END, Keys.Enter, State.PLAY);

            //Menu Actions
            menuManager = new MenuManager();
                //Title
            TitleScreen = new MenuScreen(GraphicsDevice.Viewport.Bounds, Game1.State.TITLE);
            TitleScreen.FontColor = Color.Yellow;
            TitleScreen.AddStateMenuItem("Play", State.PLAY);
            TitleScreen.AddStateMenuItem("Create Game", State.PLAY);
            TitleScreen.AddStateMenuItem("Join Game", State.VIEWGAMES);
            TitleScreen.AddStateMenuItem("Options", State.OPTIONS);
            TitleScreen.AddStateMenuItem("Exit", State.EXIT);
                //Pause
            PauseScreen = new MenuScreen(GraphicsDevice.Viewport.Bounds, Game1.State.PAUSE);
            PauseScreen.FontColor = Color.Red;
            PauseScreen.AddTitel("PAUSED");
            PauseScreen.AddStateMenuItem("Resume", State.PLAY);
            PauseScreen.AddStateMenuItem("Menu", State.TITLE);
            PauseScreen.AddStateMenuItem("Exit", State.EXIT);
                //Options
            OptionScreen = new MenuScreen(GraphicsDevice.Viewport.Bounds, Game1.State.OPTIONS);
            OptionScreen.FontColor = Color.Red;
            OptionScreen.AddTitel("OPTIONS");
            OptionScreen.AddSettingMenuItem("Tank speed", new ChangeableFloat(Settings.TankSpeed));
                //End
            EndScreen = new MenuScreen(GraphicsDevice.Viewport.Bounds, Game1.State.END);
            EndScreen.FontColor = Color.Red;
            EndScreen.XAlignment = 50;
            EndScreen.AddTitel("PAUSED");
                //View Games
            ViewGamesScreen = new ViewGamesGameScreen(GraphicsDevice.Viewport.Bounds, Game1.State.VIEWGAMES);
            ViewGamesScreen.FontColor = Color.Yellow;
            ViewGamesScreen.AddTitel("Current Games");

                    //Insert
            menuManager.AddMenuScreen(TitleScreen);
            menuManager.AddMenuScreen(PauseScreen);
            menuManager.AddMenuScreen(OptionScreen);
            menuManager.AddMenuScreen(EndScreen);
            menuManager.AddMenuScreen(ViewGamesScreen);

            //base.Initialize();
            LoadContent();
    }
Exemplo n.º 33
0
    // Initialize
    protected override void Initialize()
    {
        _G.Game = this;

        // add core components
        Components.Add( new GamerServicesComponent( this ) );

        // add layers
        UiLayer = new UiLayer();
        _G.UI = UiLayer;

        // add other components
        _G.GameInput = new GameInput( (int)E_GameButton.Count, (int)E_GameAxis.Count );
        GameControls.Setup(); // initialise mappings

        base.Initialize();
    }