Ejemplo n.º 1
0
        public void SetScene(Component_Scene scene, bool canChangeUIControl)
        {
            this.scene = scene;

            sceneViewport                          = ParentContainer.Viewport;
            scene.ViewportUpdateBegin             += Scene_ViewportUpdateBegin;
            scene.ViewportUpdateGetCameraSettings += Scene_ViewportUpdateGetCameraSettings;
            scene.RenderEvent                     += Scene_RenderEvent;
            sceneViewport.AttachedScene            = scene;

            //init GameMode
            gameMode = scene.GetComponent <Component_GameMode>(onlyEnabledInHierarchy: true);

            // Load UI screen of the scene.
            if (canChangeUIControl)
            {
                var uiScreen = scene.UIScreen.Value;
                if (uiScreen != null)
                {
                    //if( uiScreen.ParentRoot != scene.ParentRoot )
                    //{
                    var fileName = uiScreen.HierarchyController?.CreatedByResource?.Owner.Name;
                    if (!string.IsNullOrEmpty(fileName) && VirtualFile.Exists(fileName))
                    {
                        uiControl = ResourceManager.LoadSeparateInstance <UIControl>(fileName, false, null);
                        if (uiControl != null)
                        {
                            AddComponent(uiControl);
                        }
                    }
                    //}
                    //else
                    //{
                    //	//!!!!impl?
                    //}
                }
            }
        }
Ejemplo n.º 2
0
 public override bool ObjectInteractionInputMessage(UIControl playScreen, Component_GameMode gameMode, InputMessage message)
 {
     return(base.ObjectInteractionInputMessage(playScreen, gameMode, message));
 }
        private void inputProcess(Component_InputProcessing sender, UIControl playScreen, Component_GameMode gameMode, InputMessage message)
        {
            //mouse down
            var mouseDown = message as InputMessageMouseButtonDown;

            if (mouseDown != null && mouseDown.Button == EMouseButtons.Left)
            {
                last_selected_obj = UTools.GetObjectByCursor(SimulationApp.MainViewport, out ray, out pos);
                if (last_selected_obj != null && pos != null)
                {
                    OnObjectClick?.Invoke(last_selected_obj);
                    //ScreenMessages.Add("pos = " + pos.Value.ToString());
                    //ScreenMessages.Add("Obj = " + (last_selected_obj.TransformV.Position - pos.Value).ToString());
                }
            }
        }