Ejemplo n.º 1
0
 private void HandleLeftMouseReleased(MoisManager input)
 {
     if (mouseMode == MouseMode.Selection && CityManager.SelectionIsValid())
     {
         Mogre.Pair <bool, Point> result = getPlotCoordsFromScreenPoint(MousePosition(input));
         if (result.first)
         {
             CityManager.UpdateSelectionBox(result.second);
         }
         UpdateSelectionBox();
         CityManager.MakeSelection();
         CityManager.ClearSelection();
         selectionBox.SetVisible(false);
     }
     if ((canZone() || canUnzone()) && CityManager.ScratchZoneIsValid())
     {
         Mogre.Pair <bool, Point> result = getPlotCoordsFromScreenPoint(MousePosition(input));
         if (result.first)
         {
             CityManager.UpdateScratchZoneBox(result.second);
         }
         UpdateScratchZoneBox();
         CityManager.MakeZone();
         CityManager.ClearScratchZone();
         scratchZone.SetVisible(false);
     }
 }
Ejemplo n.º 2
0
        private void HandleMouseMove(MoisManager input)
        {
            Ray mouseRay = GetSelectionRay(input.MousePosX, input.MousePosY);

            Mogre.Pair <bool, float> intersection = mouseRay.Intersects(new Plane(Vector3.UNIT_Y, Vector3.ZERO));
            if (intersection.first && selboxShouldUpate())
            {
                Vector3 intersectionPt = mouseRay.Origin + mouseRay.Direction * intersection.second;
                Point   plotCoord      = CityManager.GetPlotCoords(intersectionPt);
                Vector3 plotCenter     = CityManager.GetPlotCenter(plotCoord);
                cursorPlane.SetPosition(plotCenter.x, plotCenter.y + 1f, plotCenter.z);

                if (mouseMode == MouseMode.PlacingBuilding && tempBuilding != null)
                {
                    tempBuilding.SetPosition(plotCoord.X, plotCoord.Y);
                }

                DebugPanel.SetDebugText(CityManager.GetPlotCoords(intersectionPt).ToString());
            }

            if (input.MouseMoveZ != 0.0f)
            {
                dist += input.MouseMoveZ * 0.002f;
                if (dist < -14.0f)
                {
                    dist = -14.0f;
                }
                if (dist > 0.0f)
                {
                    dist = 0.0f;
                }
            }
        }
Ejemplo n.º 3
0
        private Mogre.Pair <bool, Point> getPlotCoordsFromScreenPoint(Point p)
        {
            Ray mouseRay = GetSelectionRay(p);

            Mogre.Pair <bool, float> intersection = mouseRay.Intersects(new Plane(Vector3.UNIT_Y, Vector3.ZERO));
            if (intersection.first)
            {
                Vector3 intersectionPt = mouseRay.Origin + mouseRay.Direction * intersection.second;
                return(new Mogre.Pair <bool, Point> (true, CityManager.GetPlotCoords(intersectionPt)));
            }
            else
            {
                return(new Mogre.Pair <bool, Point>(false, Point.Empty));
            }
        }
Ejemplo n.º 4
0
        private void HandleLeftMousePressed(MoisManager input)
        {
            if (!StateManager.SupressGameControl)
            {
                if (!ContextMenu.HitTest(MousePosition(input)))
                {
                    ContextMenu.Visible = false;
                    if (canPlaceBuilding())
                    {
                        CityManager.NewBuilding(this.tempBuilding.PlotX, this.tempBuilding.PlotY, this.tempBuilding.Data.Configuration);
                        gConsole.WriteLine("Placing building...");

                        if (!input.IsKeyDown(KeyCode.KC_LSHIFT))
                        {
                            //Then dispose the cursor building as the game will be making a new one very shortly
                            CancelBuildingPlacement();
                            mouseMode = MouseMode.Selection;
                        }
                    }

                    if (canSelect())
                    {
                        Mogre.Pair <bool, Point> result = getPlotCoordsFromScreenPoint(MousePosition(input));
                        if (result.first)
                        {
                            CityManager.SetSelectionOrigin(result.second);
                        }
                    }

                    if (canZone() || canUnzone())
                    {
                        Mogre.Pair <bool, Point> result = getPlotCoordsFromScreenPoint(MousePosition(input));
                        if (result.first)
                        {
                            CityManager.SetScratchZoneOrigin(result.second);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
 private void HandleLeftMouseHeld(MoisManager input)
 {
     if (!StateManager.SupressGameControl)
     {
         if (canSelect())
         {
             Mogre.Pair <bool, Point> result = getPlotCoordsFromScreenPoint(MousePosition(input));
             if (result.first)
             {
                 CityManager.UpdateSelectionBox(result.second);
                 if (CityManager.SelectionIsValid())
                 {
                     UpdateSelectionBox();
                 }
             }
         }
         if (canZone() || canUnzone())
         {
             Mogre.Pair <bool, Point> result = getPlotCoordsFromScreenPoint(MousePosition(input));
             if (result.first)
             {
                 CityManager.UpdateScratchZoneBox(result.second);
                 if (CityManager.ScratchZoneIsValid())
                 {
                     UpdateScratchZoneBox();
                 }
             }
         }
         if (canRoad())
         {
             Mogre.Pair <bool, Point> result = getPlotCoordsFromScreenPoint(MousePosition(input));
             if (result.first)
             {
                 Haswell.Controller.City.CreateRoad(result.second.X, result.second.Y);
             }
         }
     }
 }
Ejemplo n.º 6
0
        private void HandleRightMousePressed(MoisManager input)
        {
            if (!StateManager.SupressGameControl)
            {
                if (ContextMenu.Visible == true && !ContextMenu.HitTest(MousePosition(input)))
                {
                    ContextMenu.Visible = false;
                }
                else
                {
                    ContextMenu.Location = new Point(input.MousePosX, input.MousePosY);

                    Mogre.Pair <bool, Point> result = getPlotCoordsFromScreenPoint(MousePosition(input));
                    if (result.first)
                    {
                        CityManager.UpdateSelectionBox(result.second);
                    }
                    if (canSelect())
                    {
                        UpdateSelectionBox();
                        CityManager.MakeSelection();

                        if (CityManager.GetSelectedBuildings().Count > 0)
                        {
                            ContextMenu.ShowControl("Properties");
                        }
                        else
                        {
                            ContextMenu.HideControl("Properties");
                        }
                    }
                    CityManager.ClearSelection();
                    ContextMenu.Visible = true;
                }
            }
        }