Пример #1
0
 private void Update()
 {
     if (EventManager.CurrentEvent == EventManager.Events.ChooseResources)
     {
         isReadyToTakeTask = true;
     }
     else
     {
         isReadyToTakeTask = false;
     }
     if (isReadyToTakeTask)
     {
         if (mouseMonitor == null)
         {
             mouseMonitor = GameObject.FindObjectOfType <MouseMonitor>().GetComponent <MouseMonitor>();
         }
         if (mouseMonitor.currentSelectedGameObject != null && !isTaskAlreadyCreate(mouseMonitor.currentSelectedGameObject))
         {
             if (mouseMonitor.currentGameObject.GetComponent <ResourceContainer>() != null && mouseMonitor.currentGameObject.GetComponent <ResourceContainer>().HasResources())
             {
                 PrepareToTakeTask(mouseMonitor.currentGameObject);
             }
         }
     }
     if (isHasFreeTask() && FindFreeWorker() != null)
     {
         SetWorkerTaskInQueue(FindFreeWorker());
     }
 }
Пример #2
0
    ///////////////////////////////////////////////////////////////////////////////////////

    private void Awake()
    {
        loadingTasksManager = GetComponent <LoadingTasksManager>();

        mouseMonitorSystem = new MouseMonitor();
        ChartEditor.Instance.RegisterPersistentSystem(ChartEditor.State.Editor, mouseMonitorSystem);
    }
Пример #3
0
    ///////////////////////////////////////////////////////////////////////////////////////

    private void Awake()
    {
        loadingTasksManager = GetComponent <LoadingTasksManager>();
        updateManager       = new ApplicationUpdateManager(Application.version);

        mouseMonitorSystem = new MouseMonitor();
        ChartEditor.Instance.RegisterPersistentSystem(ChartEditor.State.Editor, mouseMonitorSystem);
        ChartEditor.Instance.RegisterPersistentSystem(ChartEditor.State.Playing, mouseMonitorSystem);
        ChartEditor.Instance.RegisterPersistentSystem(ChartEditor.State.Menu, mouseMonitorSystem);
    }
Пример #4
0
        public UI(UIConfig config)
        {
            DefaultFont = config.DefaultFont;
            RootPanel.SetBounds(config.Bounds);
            RootPanel.SetFont(config.DefaultFont);
            Inputs       = config.Inputs;
            SceneManager = config.SceneManager;
            Catalog      = config.Catalog;

            if (config.DefaultBackground != null)
            {
                DefaultBackground = config.DefaultBackground;
            }

            MouseMonitor    = new MouseMonitor();
            KeyboardMonitor = new KeyboardMonitor();
            GamepadMonitor  = new GamepadMonitor();
        }
Пример #5
0
        public void GameRender(FrameEventArgs e)
        {
            /* Terrain */
            GameInfo.Battlefield.Draw();

            /* Lookat */
            Vector2d mousepos;

            if (MouseMonitor.GetMousePosition(Gameview, out mousepos))
            {
                GraphicsManager.DrawLine(new Vector3d(mousepos.X, mousepos.Y, 0), new Vector3d(mousepos.X, mousepos.Y, 1), Color.White);
            }

            if (GameInfo.Me.ID == 0)
            {
                Gameview.Position = new Vector3d(2.5, -0.5, 4);
                Gameview.LookAt(2.5, 2.5, 0);
            }
            else
            {
                Gameview.Position = new Vector3d(2.5, 7.5, 4);
                Gameview.LookAt(2.5, 4.5, 0);
            }
        }
    protected override void Update()
    {
        if (!block)
        {
            UpdateSnappedPos();
            MouseMonitor mouseMonitor = editor.services.mouseMonitorSystem;

            if (Input.GetMouseButtonDown(0))
            {
                mousePos                = Input.mousePosition;
                mouseDownOverUI         = MouseMonitor.IsUIUnderPointer();
                clickedSelectableObject = mouseMonitor.currentSelectableUnderMouse;

                // Reset if the user is making a new selection or deselecting the old
                if (!clickedSelectableObject && !Globals.modifierInputActive && !Globals.secondaryInputActive && !mouseDownOverUI)
                {
                    editor.selectedObjectsManager.currentSelectedObject = null;
                }

                if (editor.services.mouseMonitorSystem.world2DPosition != null && !mouseMonitor.currentSelectableUnderMouse && !MouseMonitor.IsUIUnderPointer())
                {
                    InitGroupSelect();
                }
            }
            else if (Input.GetMouseButtonUp(0))
            {
                clickedSelectableObject = null;
            }

            // Dragging mouse for group select
            if (userDraggingSelectArea && Input.GetMouseButton(0) && !clickedSelectableObject && !mouseDownOverUI)
            {
                if (editor.services.mouseMonitorSystem.world2DPosition != null)
                {
                    endWorld2DPos   = (Vector2)editor.services.mouseMonitorSystem.world2DPosition;
                    endWorld2DPos.y = editor.currentSong.TickToWorldYPosition(objectSnappedChartPos);

                    endWorld2DChartPos = objectSnappedChartPos;
                }

                UpdateSelectionAreaVisual(draggingArea.transform, initWorld2DPos, endWorld2DPos);
            }

            // Dragging mouse for group move
            else if (Input.GetMouseButton(0) && mousePos != Input.mousePosition && editor.selectedObjectsManager.currentSelectedObjects.Count > 0 && clickedSelectableObject && !mouseDownOverUI &&
                     !Globals.modifierInputActive && !Globals.secondaryInputActive)
            {
                // Find anchor point
                int anchorPoint = SongObjectHelper.NOTFOUND;

                if (clickedSelectableObject)
                {
                    for (int i = 0; i < editor.selectedObjectsManager.currentSelectedObjects.Count; ++i)
                    {
                        if (editor.selectedObjectsManager.currentSelectedObjects[i].controller != null && editor.selectedObjectsManager.currentSelectedObjects[i].controller.gameObject == clickedSelectableObject)
                        {
                            anchorPoint = i;
                            break;
                        }
                    }
                }

                groupMove.StartMoveAction(editor.selectedObjectsManager.currentSelectedObjects, anchorPoint, true);
            }

            // User has finished creating a group selection area
            if (Input.GetMouseButtonUp(0) && userDraggingSelectArea)
            {
                if (startWorld2DChartPos > endWorld2DChartPos)
                {
                    if (addMode)
                    {
                        AddToSelection(ScanArea(initWorld2DPos, endWorld2DPos, endWorld2DChartPos, startWorld2DChartPos));
                    }
                    else
                    {
                        RemoveFromSelection(ScanArea(initWorld2DPos, endWorld2DPos, endWorld2DChartPos, startWorld2DChartPos));
                    }
                }
                else
                {
                    if (addMode)
                    {
                        AddToSelection(ScanArea(initWorld2DPos, endWorld2DPos, startWorld2DChartPos, endWorld2DChartPos));
                    }
                    else
                    {
                        RemoveFromSelection(ScanArea(initWorld2DPos, endWorld2DPos, startWorld2DChartPos, endWorld2DChartPos));
                    }
                }
                SelfAreaDisable();
                userDraggingSelectArea = false;
            }

            // Check for deselection of all objects
            if (Input.GetMouseButtonUp(0) && !mouseMonitor.currentSelectableUnderMouse && !MouseMonitor.IsUIUnderPointer() && mousePos == Input.mousePosition && !Globals.modifierInputActive)
            {
                editor.selectedObjectsManager.currentSelectedObject = null;
                mousePos = Vector3.zero;
            }
        }
        else
        {
            block = true;
        }

        if (block && !Input.GetMouseButton(0))
        {
            block = false;
        }
    }
Пример #7
0
 private void Start()
 {
     mouseMonitor = this.gameObject.GetComponent <MouseMonitor>();
 }