示例#1
0
    void LoadAssistantUIModel(GameObject obj)
    {
        if (obj == null)
        {
            return;
        }

        AssetCacheMgr.GetUIInstance("RTTModel.prefab", (prefab, guid, go) =>
        {
            GameObject goTmp = (GameObject)go;
            goTmp.transform.localPosition = new Vector3(1000, 1000, 1000);

            obj.transform.parent = goTmp.transform;
            goTmp.name           = "AssistantRTTModel";

            Camera rttCam = goTmp.GetComponentsInChildren <Camera>(true)[0];
            rttCam.transform.localEulerAngles = new Vector3(25, 180, 0);
            rttCam.transform.localPosition    = new Vector3(0, 2.5f, 2);
            UIViewport vp = rttCam.GetComponentsInChildren <UIViewport>(true)[0];

            vp.topLeft      = m_goRTTModelTopLeft.transform;
            vp.bottomRight  = m_goRTTModelBottomRight.transform;
            vp.sourceCamera = GameObject.Find("Camera").GetComponentsInChildren <Camera>(true)[0];



            m_goRTTModel = goTmp;
            obj.transform.localPosition = Vector3.zero;
            //ShowAssistantRTTModel(false);
        });
    }
示例#2
0
        static Vector3 DragVector(Vector2 mouse, _data data, UIViewport viewport)
        {
            var position  = data.dragStartPoint;
            var direction = data.dragAxis;

            Matrix4x4.Invert(viewport.mvp, out var invMvp);

            (Vector4 p0, Vector4 p1) = ClipLineX(position, position + direction, viewport.mvp);
            p0 /= p0.W;
            p1 /= p1.W;
            Vector4 dragUnit = (p1 - p0);

            dragUnit /= new Vector2(dragUnit.X, dragUnit.Y).Length();

            Vector2 mouseProj = (mouse - viewport.leftTop) / viewport.size;

            mouseProj.X = mouseProj.X * 2 - 1;
            mouseProj.Y = 1 - mouseProj.Y * 2;

            Vector2 mouseProj1 = (data.dragScreenStartPoint - viewport.leftTop) / viewport.size;

            mouseProj1.X = mouseProj1.X * 2 - 1;
            mouseProj1.Y = 1 - mouseProj1.Y * 2;

            float l = Vector2.Dot(mouseProj - mouseProj1, new Vector2(dragUnit.X, dragUnit.Y));

            p0 += l * dragUnit;

            Vector4 result = Vector4.Transform(p0, invMvp);

            result /= result.W;
            return(new Vector3(result.X, result.Y, result.Z));
        }
示例#3
0
 public void ResetViewPort(int vocation)
 {
     if (ModelShowCaseLogicManager.Instance.ViewportList.ContainsKey(vocation))
     {
         UIViewport viewport = ModelShowCaseLogicManager.Instance.ViewportList[vocation];
         viewport.topLeft     = left;
         viewport.bottomRight = right;
     }
 }
示例#4
0
        public MapGameState(FortressGame game)
            : base(game)
        {
            Game = game;
            MapView    view     = new MapView(game.Session.Map);
            UIViewport viewport = new UIViewport(0, 0, game.Width, game.Height, view, game);

            UI.Add(viewport);
        }
示例#5
0
        protected override void Initialize()
        {
            base.Initialize();
            BattleMap     testMap  = new BattleMap(40, 40);
            BattleMapView view     = new BattleMapView(testMap);
            UIViewport    viewport = new UIViewport(0, 0, GraphicsDevice.DisplayMode.Width, GraphicsDevice.DisplayMode.Height, view, this);

            ActiveState.UI.Add(viewport);

            LoadData();
        }
示例#6
0
        public BattleGameState(ShooterGame game)
            : base(game)
        {
            Game    = game;
            Map     = new GameMap();
            MapView = new GameMapView(this);
            UIViewport mapViewport = new UIViewport(0, 0, UI.Width, UI.Height, MapView, game);

            mapViewport.IsAlwaysAtBottom = true;

            UI.Add(mapViewport);
        }
示例#7
0
 static public int get_fullSize(IntPtr l)
 {
     try {
         UIViewport self = (UIViewport)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.fullSize);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
    private void ResizeViewport()
    {
        SingleModelController smc = model.GetComponent <SingleModelController>();
        UIViewport            vp  = smc.surroundCamera.GetComponent <UIViewport>();

        if (vp != null)
        {
            vp.sourceCamera = sourceCamera.GetComponent <Camera>();
            vp.topLeft      = topLeft.transform;
            vp.bottomRight  = bottomRight2.transform;
        }
    }
示例#9
0
    protected override void AwakeImpl()
    {
        base.AwakeImpl();

        m_ViewSpriteTr = transform.FindChild("ListBaseSprite");
        m_ViewScale    = m_ViewSpriteTr.localScale;
        m_TopLeft      = transform.FindChild("ListBaseSprite/TopLeft");
        m_BottomRight  = transform.FindChild("ListBaseSprite/BottomRight");
        //m_DragCamera = transform.FindChild("ListBaseSprite").GetComponent<UIDragCamera>();
        NvGameUIManager mgr = Singlton.getInstance("NvGameUIManager") as NvGameUIManager;

        m_UICamera = mgr.GameUICamera;

        m_ListPrefab = Resources.Load("UI Prefabs/Prefabs/Controls/UIListView") as GameObject;
        m_ListView   = GameObject.Instantiate(m_ListPrefab) as GameObject;
        //rename list view
        m_ListView.name = listName;
        Transform listviewCamera = m_ListView.transform.FindChild("UIListViewCamera");

        //Transform listviewCamera = m_ListView.transform.FindChild("UIListViewCamera" );
        //m_ListViewCamera = listviewCamera.GetComponent<UIDraggableCamera>();
        //rename list view draggable camera
        //m_ListViewCamera.name = listName + "Camera";
        //set draggable camera to drag camera
        //m_DragCamera.draggableCamera = m_ListViewCamera;
        m_ListViewViewport = listviewCamera.GetComponent <UIViewport>();
        //set viewport camera
        m_ListViewViewport.sourceCamera = m_UICamera;
        m_ListViewLink            = m_ListView.transform.FindChild("Link");
        m_ListViewLink.localScale = Utility.GetScreenRatio();
        Transform listOffset = m_ListView.transform.FindChild("Link/Anchor/ListOffset");

        listOffset.transform.localPosition = new Vector3(dragCameraDistance, dragCameraDistance, listOffset.transform.localPosition.z);
        m_ListViewTable  = listOffset.GetComponent <UITable>();
        m_listViewAnchor = m_ListView.transform.FindChild("Link/Anchor").GetComponent <UIAnchor>();
        //m_DragPanel = m_ListView.transform.FindChild("Link/Anchor/ListOffset").GetComponent<UIDraggablePanel>();
        //set ui layer camera to list view anchor
        m_listViewAnchor.uiCamera = m_UICamera;
        //set slider bar
        if (horizontalScrollBar != null)
        {
            m_horizontalScrollBar = horizontalScrollBar.GetComponent <UIScrollBar>();
            //m_DragPanel.scale = new Vector3( 1.0f, 0.0f, 0.0f );
            //m_DragPanel.horizontalScrollBar = m_horizontalScrollBar;
        }
        if (verticalScrollBar != null)
        {
            m_verticalScrollBar = verticalScrollBar.GetComponent <UIScrollBar>();
            //m_DragPanel.scale = new Vector3( 0.0f, 1.0f, 0.0f );
            //m_DragPanel.verticalScrollBar = m_verticalScrollBar;
        }
    }
示例#10
0
 static public int set_sourceCamera(IntPtr l)
 {
     try {
         UIViewport         self = (UIViewport)checkSelf(l);
         UnityEngine.Camera v;
         checkType(l, 2, out v);
         self.sourceCamera = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#11
0
 static public int set_fullSize(IntPtr l)
 {
     try {
         UIViewport    self = (UIViewport)checkSelf(l);
         System.Single v;
         checkType(l, 2, out v);
         self.fullSize = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#12
0
        protected override void Initialize()
        {
            base.Initialize();
            Data     = new GameData();
            RNG      = new Random();
            Textures = new TextureAtlasManager(this);
            LoadBiomes();

            PlanetSurface     surface  = new PlanetSurface(200, 100, Data, RNG);
            PlanetSurfaceView view     = new PlanetSurfaceView(this, surface);
            UIViewport        viewport = new UIViewport(0, 0, GraphicsDevice.DisplayMode.Width, GraphicsDevice.DisplayMode.Height, view, this);

            ActiveState.UI.Add(viewport);
        }
示例#13
0
 static public int set_bottomRight(IntPtr l)
 {
     try {
         UIViewport            self = (UIViewport)checkSelf(l);
         UnityEngine.Transform v;
         checkType(l, 2, out v);
         self.bottomRight = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#14
0
    void Start()
    {
        item.SetActive(false);
        UIViewport port = ApplicationEntry.Instance.ui3DCamera.GetComponent <UIViewport> ();

        ApplicationEntry.Instance.ui3DCamera.transform.position = new Vector3(0.25f, 0.28f, -1.5f);
        ApplicationEntry.Instance.ui3DCamera.fieldOfView        = 29;
        port.topLeft     = TopLeft;
        port.bottomRight = BottomRight;
        grid             = GetComponentInChildren <UIGrid> ();
        babylist         = GamePlayer.Instance.babies_list_;
        AddItems(babylist);
        UIManager.SetButtonEventHandler(closeBtn.gameObject, EnumButtonEvent.OnClick, OnClickClosebtn, 0, 0);
        isBattle = GamePlayer.Instance.isInBattle;
    }
示例#15
0
    static int get_topLeft(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIViewport            obj = (UIViewport)o;
            UnityEngine.Transform ret = obj.topLeft;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index topLeft on a nil value"));
        }
    }
示例#16
0
    static int get_bottomRight(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIViewport            obj = (UIViewport)o;
            UnityEngine.Transform ret = obj.bottomRight;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index bottomRight on a nil value" : e.Message));
        }
    }
示例#17
0
    static int get_sourceCamera(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIViewport         obj = (UIViewport)o;
            UnityEngine.Camera ret = obj.sourceCamera;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index sourceCamera on a nil value" : e.Message));
        }
    }
示例#18
0
    static int set_bottomRight(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIViewport            obj  = (UIViewport)o;
            UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.CheckUnityObject(L, 2, typeof(UnityEngine.Transform));
            obj.bottomRight = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index bottomRight on a nil value" : e.Message));
        }
    }
示例#19
0
    static int set_sourceCamera(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIViewport         obj  = (UIViewport)o;
            UnityEngine.Camera arg0 = (UnityEngine.Camera)ToLua.CheckUnityObject(L, 2, typeof(UnityEngine.Camera));
            obj.sourceCamera = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index sourceCamera on a nil value" : e.Message));
        }
    }
示例#20
0
    static int get_fullSize(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIViewport obj = (UIViewport)o;
            float      ret = obj.fullSize;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index fullSize on a nil value" : e.Message));
        }
    }
示例#21
0
    static int set_fullSize(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIViewport obj  = (UIViewport)o;
            float      arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
            obj.fullSize = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index fullSize on a nil value" : e.Message));
        }
    }
示例#22
0
    static int set_topLeft(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIViewport            obj  = (UIViewport)o;
            UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 2);
            obj.topLeft = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index topLeft on a nil value"));
        }
    }
示例#23
0
    public void Init()
    {
        if (null == gameObject.GetComponent <UIViewport>())
        {
            gameObject.AddComponent <UIViewport>();
        }

        UIViewport UiViewPort = gameObject.GetComponent <UIViewport>();

        if (UiViewPort && m_TopLeft && m_BottomRight)
        {
            UiViewPort.topLeft     = m_TopLeft.transform;
            UiViewPort.bottomRight = m_BottomRight.transform;
            if (UICamera.mainCamera)
            {
                UiViewPort.sourceCamera = UICamera.mainCamera;
            }
        }
    }
示例#24
0
        public ShipDesignerGameState(SpaceGame game)
            : base(game)
        {
            game.Resized += OnResized;

            Map = new ShipDesignerMap(game.Data);
            ShipDesignerMapView mapView     = new ShipDesignerMapView(Map);
            UIViewport          mapViewport = new UIViewport(96, 0, UI.Width - 96, UI.Height, mapView, game);

            mapViewport.IsAlwaysAtBottom = true;
            ShipDesignerModuleView moduleView     = new ShipDesignerModuleView(Map);
            UIViewport             moduleViewport = new UIViewport(0, 0, 96, UI.Height, moduleView, game);

            moduleViewport.IsAlwaysAtBottom = true;

            SpriteData     testSprite = game.Data.Sprites["TestIcon"];
            UIButtonSimple testButton = new UIButtonSimple(
                mapViewport.Bounds.Right - testSprite.Width * 4, mapViewport.Bounds.Bottom - testSprite.Height, testSprite.Width, testSprite.Height,
                Map.TestShip, testSprite.Base);
            //testButton.Tooltip = "Test the ship";

            SpriteData     newSprite = game.Data.Sprites["NewIcon"];
            UIButtonSimple newButton = new UIButtonSimple(
                mapViewport.Bounds.Right - newSprite.Width * 3, mapViewport.Bounds.Bottom - newSprite.Height, newSprite.Width, newSprite.Height,
                Map.NewShip, newSprite.Base);
            //newButton.Tooltip = "Create a new ship";

            SpriteData     saveSprite = game.Data.Sprites["SaveIcon"];
            UIButtonSimple saveButton = new UIButtonSimple(
                mapViewport.Bounds.Right - saveSprite.Width * 2, mapViewport.Bounds.Bottom - saveSprite.Height, saveSprite.Width, saveSprite.Height,
                Map.SaveShip, saveSprite.Base);
            //saveButton.Tooltip = "Save the current ship";

            SpriteData     loadSprite = game.Data.Sprites["LoadIcon"];
            UIButtonSimple loadButton = new UIButtonSimple(
                mapViewport.Bounds.Right - loadSprite.Width, mapViewport.Bounds.Bottom - loadSprite.Height, loadSprite.Width, loadSprite.Height,
                Map.LoadShip, loadSprite.Base);

            //loadButton.Tooltip = "Load a ship";

            UI.Add(testButton, newButton, saveButton, loadButton, moduleViewport, mapViewport);
        }
示例#25
0
 public static void DrawCube(ImDrawListPtr drawList, UIViewport viewport)
 {
     for (int i = 0; i < 4; i++)
     {
         float signY = ((i & 2) - 1);
         float signZ = (((i << 1) & 2) - 1);
         Draw3DLine(drawList, new Vector3(1, signY, signZ), new Vector3(-1, signY, signZ), viewport, 0xffffffff);
     }
     for (int i = 0; i < 4; i++)
     {
         float signX = ((i & 2) - 1);
         float signZ = (((i << 1) & 2) - 1);
         Draw3DLine(drawList, new Vector3(signX, 1, signZ), new Vector3(signX, -1, signZ), viewport, 0xffffffff);
     }
     for (int i = 0; i < 4; i++)
     {
         float signX = ((i & 2) - 1);
         float signY = (((i << 1) & 2) - 1);
         Draw3DLine(drawList, new Vector3(signX, signY, 1), new Vector3(signX, signY, -1), viewport, 0xffffffff);
     }
 }
示例#26
0
    static int set_sourceCamera(IntPtr L)
    {
        object     o   = LuaScriptMgr.GetLuaObject(L, 1);
        UIViewport obj = (UIViewport)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name sourceCamera");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index sourceCamera on a nil value");
            }
        }

        obj.sourceCamera = (Camera)LuaScriptMgr.GetUnityObject(L, 3, typeof(Camera));
        return(0);
    }
示例#27
0
    static int set_bottomRight(IntPtr L)
    {
        object     o   = LuaScriptMgr.GetLuaObject(L, 1);
        UIViewport obj = (UIViewport)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name bottomRight");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index bottomRight on a nil value");
            }
        }

        obj.bottomRight = (Transform)LuaScriptMgr.GetUnityObject(L, 3, typeof(Transform));
        return(0);
    }
示例#28
0
    static int get_bottomRight(IntPtr L)
    {
        object     o   = LuaScriptMgr.GetLuaObject(L, 1);
        UIViewport obj = (UIViewport)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name bottomRight");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index bottomRight on a nil value");
            }
        }

        LuaScriptMgr.Push(L, obj.bottomRight);
        return(1);
    }
示例#29
0
    static int set_fullSize(IntPtr L)
    {
        object     o   = LuaScriptMgr.GetLuaObject(L, 1);
        UIViewport obj = (UIViewport)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name fullSize");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index fullSize on a nil value");
            }
        }

        obj.fullSize = (float)LuaScriptMgr.GetNumber(L, 3);
        return(0);
    }
示例#30
0
        public static bool HitTest(Vector3 from, Vector3 to, Vector2 mouse, UIViewport viewport, float thickness)
        {
            (Vector2 p0, Vector2 p1) = ScreenClipLine(from, to, viewport.mvp);
            if (p0 == p1)
            {
                return(false);
            }
            Vector2 size = viewport.size;
            Vector2 z0   = p0 * size;
            Vector2 z1   = p1 * size;
            Vector2 a    = mouse - viewport.leftTop;

            float d  = Vector2.Distance(z1, z0);
            float d1 = Vector2.Dot(a - z0, z1 - z0) / d;

            if (d1 < 0 || d1 > d)
            {
                return(false);
            }
            float s = Vector2.DistanceSquared(a, z0) - MathF.Pow(d1, 2);

            return(s <= thickness * thickness);
        }
示例#31
0
    protected override void AwakeImpl()
    {
        base.AwakeImpl();

        m_ViewSpriteTr = transform.FindChild("ListBaseSprite");
        m_ViewScale = m_ViewSpriteTr.localScale;
        m_TopLeft = transform.FindChild("ListBaseSprite/TopLeft");
        m_BottomRight = transform.FindChild("ListBaseSprite/BottomRight");
        //m_DragCamera = transform.FindChild("ListBaseSprite").GetComponent<UIDragCamera>();
        NvGameUIManager mgr = Singlton.getInstance("NvGameUIManager") as NvGameUIManager;
        m_UICamera = mgr.GameUICamera;

        m_ListPrefab = Resources.Load("UI Prefabs/Prefabs/Controls/UIListView") as GameObject;
        m_ListView = GameObject.Instantiate( m_ListPrefab ) as GameObject;
        //rename list view
        m_ListView.name = listName;
        Transform listviewCamera = m_ListView.transform.FindChild("UIListViewCamera");
        //Transform listviewCamera = m_ListView.transform.FindChild("UIListViewCamera" );
        //m_ListViewCamera = listviewCamera.GetComponent<UIDraggableCamera>();
        //rename list view draggable camera
        //m_ListViewCamera.name = listName + "Camera";
        //set draggable camera to drag camera
        //m_DragCamera.draggableCamera = m_ListViewCamera;
        m_ListViewViewport = listviewCamera.GetComponent<UIViewport>();
        //set viewport camera
        m_ListViewViewport.sourceCamera = m_UICamera;
        m_ListViewLink = m_ListView.transform.FindChild("Link");
        m_ListViewLink.localScale = Utility.GetScreenRatio();
        Transform listOffset = m_ListView.transform.FindChild("Link/Anchor/ListOffset");
        listOffset.transform.localPosition = new Vector3 ( dragCameraDistance, dragCameraDistance, listOffset.transform.localPosition.z );
        m_ListViewTable = listOffset.GetComponent<UITable>();
        m_listViewAnchor = m_ListView.transform.FindChild("Link/Anchor").GetComponent<UIAnchor>();
        //m_DragPanel = m_ListView.transform.FindChild("Link/Anchor/ListOffset").GetComponent<UIDraggablePanel>();
        //set ui layer camera to list view anchor
        m_listViewAnchor.uiCamera = m_UICamera;
        //set slider bar
        if ( horizontalScrollBar != null )
        {
            m_horizontalScrollBar = horizontalScrollBar.GetComponent<UIScrollBar>();
            //m_DragPanel.scale = new Vector3( 1.0f, 0.0f, 0.0f );
            //m_DragPanel.horizontalScrollBar = m_horizontalScrollBar;
        }
        if ( verticalScrollBar != null )
        {
            m_verticalScrollBar = verticalScrollBar.GetComponent<UIScrollBar>();
            //m_DragPanel.scale = new Vector3( 0.0f, 1.0f, 0.0f );
            //m_DragPanel.verticalScrollBar = m_verticalScrollBar;
        }
    }