예제 #1
0
        public bool LoadFrame()
        {
            WindowCollection windowCollection = GameHelper.LoadUIForm(GUISystem.Instance.RootWindow, "content", "/ui/form/MiniMap.nui");

            if (windowCollection != null)
            {
                miniMap    = (Nexus.GUI.Widgets.UIShapedImageBox)GUISystem.Instance.RootWindow.FindChild("root/UIStaticImage1/UIShapedImageBox1", true);
                coordLabel = (Nexus.GUI.Widgets.UILabel)GUISystem.Instance.RootWindow.FindChild("root/UIStaticImage1/UILabel1", true);
                if (miniMap != null)
                {
                    miniMap.BackgroundRenderComp.ImageLocation = new NResourceLoc("content", "/minimap/minimap.dds");
                    miniMapSize = miniMap.BackgroundRenderComp.Texture.GetOriginalSize();
                    Vector2 center = new Vector2(miniMapSize.x * 0.5f, miniMapSize.y * 0.5f);
                    miniMap.BackgroundRenderComp.TextureRect = new Rect(center.x - minimapRange.x, center.y - minimapRange.y,
                                                                        center.x + minimapRange.x, center.y + minimapRange.y);
                    Vector3 scale = GameEngine.EngineInstance.CurrentLevel.NavigationMapScale;
                    sceneSize.x    = GameEngine.EngineInstance.CurrentLevel.NavigationMapWidth * scale.x;
                    sceneSize.y    = GameEngine.EngineInstance.CurrentLevel.NavigationMapHeight * scale.z;
                    minimapRatio.x = minimapRange.x * 2 / miniMap.Width.offest;
                    minimapRatio.y = minimapRange.y * 2 / miniMap.Height.offest;

                    Icons = NResourceManager.Instance.LoadTextureAtlas(new NResourceLoc("content", "/ui/texAtlas/content1.txa"), EResourceIOMode.Auto, EResourceIOPriority.Normal);
                    if (Icons == null)
                    {
                        return(false);
                    }

                    {
                        NTexAtlasItem item = Icons.GetItem("minimap_6");
                        playerIcon = new Rect(item.UVStart.x, item.UVStart.y, item.UVEnd.x, item.UVEnd.y);
                    }

                    {
                        NTexAtlasItem item = Icons.GetItem("minimap-5");
                        northIcon = new Rect(item.UVStart.x, item.UVStart.y, item.UVEnd.x, item.UVEnd.y);
                    }

                    {
                        NTexAtlasItem item = Icons.GetItem("minimap-5");
                        aroundRoleIcon = new Rect(item.UVStart.x, item.UVStart.y, item.UVEnd.x, item.UVEnd.y);
                    }
                    //------------------------------------------------------
                    miniMap.BackgroundRenderComp.OnRendering += this.OnDraw;

                    Window win = GUISystem.Instance.RootWindow.FindChild("root/UIStaticImage1/UIButton2", true);
                    if (win != null)
                    {
                        win.MouseClicked += this.ZoomIn;
                    }

                    win = GUISystem.Instance.RootWindow.FindChild("root/UIStaticImage1/UIButton3", true);
                    if (win != null)
                    {
                        win.MouseClicked += this.ZoomOut;
                    }

                    win = GUISystem.Instance.RootWindow.FindChild("root/UIStaticImage1/UIButton4", true);
                    if (win != null)
                    {
                        win.MouseClicked += this.OnMinsize;
                    }

                    win = GUISystem.Instance.RootWindow.FindChild("root/UIStaticImage1/UIButton5", true);
                    if (win != null)
                    {
                        win.MouseClicked += this.OnShowWorldMap;
                    }


                    // 添加测试用角色
                    RoleAround a = new RoleAround(1, RoleStandpoint.RoleFriendly); roleAround.Add(a);
                    RoleAround b = new RoleAround(2, RoleStandpoint.RoleNeutrally); roleAround.Add(b);
                    RoleAround c = new RoleAround(3, RoleStandpoint.RoleHostile); roleAround.Add(c);
                    a.Position = new Vector2(500, 400);
                    b.Position = new Vector2(450, 500);
                    c.Position = new Vector2(550, 450);
                }
            }

            return(windowCollection != null);
        }