Пример #1
0
        public sXYZ_int LNDPos_From_MapPos(sXY_int Horizontal)
        {
            sXYZ_int Result = new sXYZ_int();

            Result.X = Horizontal.X - (int)(Terrain.TileSize.X * App.TerrainGridSpacing / 2.0D);
            Result.Z = ((int)(Terrain.TileSize.Y * App.TerrainGridSpacing / 2.0D)) - Horizontal.Y;
            Result.Y = (int)(GetTerrainHeight(Horizontal));

            return Result;
        }
Пример #2
0
        public clsMap(sXY_int TileSize)
        {
            frmMainLink = new ConnectedListLink<clsMap, frmMain>(this);
            Gateways = new ConnectedList<clsGateway, clsMap>(this);

            Initialize();

            TerrainBlank(TileSize);
            TileType_Reset();
        }
Пример #3
0
 public void SideVChanged(sXY_int Num)
 {
     if ( Num.X > 0 )
     {
         TileChanged(new sXY_int(Num.X - 1, Num.Y));
     }
     if ( Num.X < Map.Terrain.TileSize.X )
     {
         TileChanged(Num);
     }
 }
Пример #4
0
 public void SideHChanged(sXY_int Num)
 {
     if ( Num.Y > 0 )
     {
         TileChanged(new sXY_int(Num.X, Num.Y - 1));
     }
     if ( Num.Y < Map.Terrain.TileSize.Y )
     {
         TileChanged(Num);
     }
 }
Пример #5
0
        public static sIntersectPos GetLinesIntersectBetween(sXY_int A1, sXY_int A2, sXY_int B1, sXY_int B2)
        {
            sIntersectPos Result = new sIntersectPos();

            if ( (A1.X == A2.X & A1.Y == A2.Y) || (B1.X == B2.X & B1.Y == B2.Y) )
            {
                Result.Exists = false;
            }
            else
            {
                double y1dif = 0;
                double x1dif = 0;
                double adifx = 0;
                double adify = 0;
                double bdifx = 0;
                double bdify = 0;
                double m = 0;
                double ar = 0;
                double br = 0;

                y1dif = B1.Y - A1.Y;
                x1dif = B1.X - A1.X;
                adifx = A2.X - A1.X;
                adify = A2.Y - A1.Y;
                bdifx = B2.X - B1.X;
                bdify = B2.Y - B1.Y;
                m = adifx * bdify - adify * bdifx;
                if ( m == 0.0D )
                {
                    Result.Exists = false;
                }
                else
                {
                    ar = (x1dif * bdify - y1dif * bdifx) / m;
                    br = (x1dif * adify - y1dif * adifx) / m;
                    if ( ar <= 0.0D | ar >= 1.0D | br <= 0.0D | br >= 1.0D )
                    {
                        Result.Exists = false;
                    }
                    else
                    {
                        Result.Pos.X = A1.X + (int)(ar * adifx);
                        Result.Pos.Y = A1.Y + (int)(ar * adify);
                        Result.Exists = true;
                    }
                }
            }
            return Result;
        }
Пример #6
0
        public void DrawUnitRectangle(clsUnit Unit, int BorderInsideThickness, sRGBA_sng InsideColour, sRGBA_sng OutsideColour)
        {
            sXY_int PosA = new sXY_int();
            sXY_int PosB = new sXY_int();
            int A = 0;
            int Altitude = Unit.Pos.Altitude - ViewInfo.ViewPos.Y;

            GetFootprintTileRangeClamped(Unit.Pos.Horizontal, Unit.Type.get_GetFootprintSelected(Unit.Rotation), PosA, PosB);
            A = PosA.Y;
            PosA.X = (int)((PosA.X + 0.125D) * App.TerrainGridSpacing - ViewInfo.ViewPos.X);
            PosA.Y = (int)((PosB.Y + 0.875D) * - App.TerrainGridSpacing - ViewInfo.ViewPos.Z);
            PosB.X = (int)((PosB.X + 0.875D) * App.TerrainGridSpacing - ViewInfo.ViewPos.X);
            PosB.Y = (int)((A + 0.125D) * - App.TerrainGridSpacing - ViewInfo.ViewPos.Z);

            GL.Color4(OutsideColour.Red, OutsideColour.Green, OutsideColour.Blue, OutsideColour.Alpha);
            GL.Vertex3(PosB.X, Altitude, Convert.ToInt32(- PosA.Y));
            GL.Vertex3(PosA.X, Altitude, Convert.ToInt32(- PosA.Y));
            GL.Color4(InsideColour.Red, InsideColour.Green, InsideColour.Blue, InsideColour.Alpha);
            GL.Vertex3(PosA.X + BorderInsideThickness, Altitude, Convert.ToInt32(- (PosA.Y + BorderInsideThickness)));
            GL.Vertex3(PosB.X - BorderInsideThickness, Altitude, Convert.ToInt32(- (PosA.Y + BorderInsideThickness)));

            GL.Color4(OutsideColour.Red, OutsideColour.Green, OutsideColour.Blue, OutsideColour.Alpha);
            GL.Vertex3(PosA.X, Altitude, Convert.ToInt32(- PosA.Y));
            GL.Vertex3(PosA.X, Altitude, Convert.ToInt32(- PosB.Y));
            GL.Color4(InsideColour.Red, InsideColour.Green, InsideColour.Blue, InsideColour.Alpha);
            GL.Vertex3(PosA.X + BorderInsideThickness, Altitude, Convert.ToInt32(- (PosB.Y - BorderInsideThickness)));
            GL.Vertex3(PosA.X + BorderInsideThickness, Altitude, Convert.ToInt32(- (PosA.Y + BorderInsideThickness)));

            GL.Color4(OutsideColour.Red, OutsideColour.Green, OutsideColour.Blue, OutsideColour.Alpha);
            GL.Vertex3(PosB.X, Altitude, Convert.ToInt32(- PosB.Y));
            GL.Vertex3(PosB.X, Altitude, Convert.ToInt32(- PosA.Y));
            GL.Color4(InsideColour.Red, InsideColour.Green, InsideColour.Blue, InsideColour.Alpha);
            GL.Vertex3(PosB.X - BorderInsideThickness, Altitude, - (PosA.Y + BorderInsideThickness));
            GL.Vertex3(PosB.X - BorderInsideThickness, Altitude, - (PosB.Y - BorderInsideThickness));

            GL.Color4(OutsideColour.Red, OutsideColour.Green, OutsideColour.Blue, OutsideColour.Alpha);
            GL.Vertex3(PosA.X, Altitude, Convert.ToInt32(- PosB.Y));
            GL.Vertex3(PosB.X, Altitude, Convert.ToInt32(- PosB.Y));
            GL.Color4(InsideColour.Red, InsideColour.Green, InsideColour.Blue, InsideColour.Alpha);
            GL.Vertex3(PosB.X - BorderInsideThickness, Altitude, - (PosB.Y - BorderInsideThickness));
            GL.Vertex3(PosA.X + BorderInsideThickness, Altitude, Convert.ToInt32(- (PosB.Y - BorderInsideThickness)));
        }
Пример #7
0
        private void OpenGL_KeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            clsMap Map = MainMap;

            if ( Map == null )
            {
                return;
            }

            Matrix3DMath.Matrix3D matrixA = new Matrix3DMath.Matrix3D();
            clsViewInfo.clsMouseOver.clsOverTerrain MouseOverTerrain = Map.ViewInfo.GetMouseOverTerrain();

            App.IsViewKeyDown.Keys[(int)e.KeyCode] = true;

            foreach ( Option<KeyboardControl> control in KeyboardManager.OptionsKeyboardControls.Options )
            {
                ((KeyboardControl)(KeyboardManager.KeyboardProfile.get_Value(control))).KeysChanged(App.IsViewKeyDown);
            }

            if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.Undo) )
            {
                string Message = "";
                if ( Map.UndoPosition > 0 )
                {
                    Message = "Undid: " + Map.Undos[Map.UndoPosition - 1].Name;
                    clsMap.clsMessage MapMessage = new clsMap.clsMessage();
                    MapMessage.Text = Message;
                    Map.Messages.Add(MapMessage);
                    Map.UndoPerform();
                    DrawViewLater();
                }
                else
                {
                    Message = "Nothing to undo";
                }
                DisplayUndoMessage(Message);
            }
            if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.Redo) )
            {
                string Message = "";
                if ( Map.UndoPosition < Map.Undos.Count )
                {
                    Message = "Redid: " + Map.Undos[Map.UndoPosition].Name;
                    clsMap.clsMessage MapMessage = new clsMap.clsMessage();
                    MapMessage.Text = Message;
                    Map.Messages.Add(MapMessage);
                    Map.RedoPerform();
                    DrawViewLater();
                }
                else
                {
                    Message = "Nothing to redo";
                }
                DisplayUndoMessage(Message);
            }
            if ( App.IsViewKeyDown.Keys[(int)Keys.ControlKey] )
            {
                if ( e.KeyCode == Keys.D1 )
                {
                    App.VisionRadius_2E = 6;
                }
                else if ( e.KeyCode == Keys.D2 )
                {
                    App.VisionRadius_2E = 7;
                }
                else if ( e.KeyCode == Keys.D3 )
                {
                    App.VisionRadius_2E = 8;
                }
                else if ( e.KeyCode == Keys.D4 )
                {
                    App.VisionRadius_2E = 9;
                }
                else if ( e.KeyCode == Keys.D5 )
                {
                    App.VisionRadius_2E = 10;
                }
                else if ( e.KeyCode == Keys.D6 )
                {
                    App.VisionRadius_2E = 11;
                }
                else if ( e.KeyCode == Keys.D7 )
                {
                    App.VisionRadius_2E = 12;
                }
                else if ( e.KeyCode == Keys.D8 )
                {
                    App.VisionRadius_2E = 13;
                }
                else if ( e.KeyCode == Keys.D9 )
                {
                    App.VisionRadius_2E = 14;
                }
                else if ( e.KeyCode == Keys.D0 )
                {
                    App.VisionRadius_2E = 15;
                }
                App.VisionRadius_2E_Changed();
            }

            if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.ViewMoveType) )
            {
                if ( App.ViewMoveType == App.enumView_Move_Type.Free )
                {
                    App.ViewMoveType = App.enumView_Move_Type.RTS;
                }
                else if ( App.ViewMoveType == App.enumView_Move_Type.RTS )
                {
                    App.ViewMoveType = App.enumView_Move_Type.Free;
                }
            }
            if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.ViewRotateType) )
            {
                App.RTSOrbit = !App.RTSOrbit;
            }
            if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.ViewReset) )
            {
                Map.ViewInfo.FOV_Multiplier_Set(SettingsManager.Settings.FOVDefault);
                if ( App.ViewMoveType == App.enumView_Move_Type.Free )
                {
                    Matrix3DMath.MatrixSetToXAngle(matrixA, Math.Atan(2.0D));
                    Map.ViewInfo.ViewAngleSet_Rotate(matrixA);
                }
                else if ( App.ViewMoveType == App.enumView_Move_Type.RTS )
                {
                    Matrix3DMath.MatrixSetToXAngle(matrixA, Math.Atan(2.0D));
                    Map.ViewInfo.ViewAngleSet_Rotate(matrixA);
                }
            }
            if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.ViewTextures) )
            {
                App.Draw_TileTextures = !App.Draw_TileTextures;
                DrawViewLater();
            }
            if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.ViewWireframe) )
            {
                App.Draw_TileWireframe = !App.Draw_TileWireframe;
                DrawViewLater();
            }
            if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.ViewUnits) )
            {
                App.Draw_Units = !App.Draw_Units;
                int X = 0;
                int Y = 0;
                sXY_int SectorNum = new sXY_int();
                clsMap.clsUnit Unit = default(clsMap.clsUnit);
                clsMap.clsUnitSectorConnection Connection = default(clsMap.clsUnitSectorConnection);
                for ( Y = 0; Y <= Map.SectorCount.Y - 1; Y++ )
                {
                    for ( X = 0; X <= Map.SectorCount.X - 1; X++ )
                    {
                        foreach ( clsMap.clsUnitSectorConnection tempLoopVar_Connection in Map.Sectors[X, Y].Units )
                        {
                            Connection = tempLoopVar_Connection;
                            Unit = Connection.Unit;
                            if ( Unit.Type.Type == clsUnitType.enumType.PlayerStructure )
                            {
                                if ( ((clsStructureType)Unit.Type).StructureBasePlate != null )
                                {
                                    SectorNum.X = X;
                                    SectorNum.Y = Y;
                                    Map.SectorGraphicsChanges.Changed(SectorNum);
                                    break;
                                }
                            }
                        }
                    }
                }
                Map.Update();
                DrawViewLater();
            }
            if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.ViewScriptMarkers) )
            {
                App.Draw_ScriptMarkers = !App.Draw_ScriptMarkers;
                DrawViewLater();
            }
            if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.ViewLighting) )
            {
                if ( App.Draw_Lighting == App.enumDrawLighting.Off )
                {
                    App.Draw_Lighting = App.enumDrawLighting.Half;
                }
                else if ( App.Draw_Lighting == App.enumDrawLighting.Half )
                {
                    App.Draw_Lighting = App.enumDrawLighting.Normal;
                }
                else if ( App.Draw_Lighting == App.enumDrawLighting.Normal )
                {
                    App.Draw_Lighting = App.enumDrawLighting.Off;
                }
                DrawViewLater();
            }
            if ( modTools.Tool == modTools.Tools.TextureBrush )
            {
                if ( MouseOverTerrain != null )
                {
                    if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.Clockwise) )
                    {
                        Map.ViewInfo.Apply_Texture_Clockwise();
                    }
                    if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.CounterClockwise) )
                    {
                        Map.ViewInfo.Apply_Texture_CounterClockwise();
                    }
                    if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.TextureFlip) )
                    {
                        Map.ViewInfo.Apply_Texture_FlipX();
                    }
                    if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.TriFlip) )
                    {
                        Map.ViewInfo.Apply_Tri_Flip();
                    }
                }
            }
            if ( modTools.Tool == modTools.Tools.ObjectSelect )
            {
                if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.UnitDelete) )
                {
                    if ( Map.SelectedUnits.Count > 0 )
                    {
                        clsMap.clsUnit Unit = default(clsMap.clsUnit);
                        foreach ( clsMap.clsUnit tempLoopVar_Unit in Map.SelectedUnits.GetItemsAsSimpleList() )
                        {
                            Unit = tempLoopVar_Unit;
                            Map.UnitRemoveStoreChange(Unit.MapLink.ArrayPosition);
                        }
                        Program.frmMainInstance.SelectedObject_Changed();
                        Map.UndoStepCreate("Object Deleted");
                        Map.Update();
                        Map.MinimapMakeLater();
                        DrawViewLater();
                    }
                }
                if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.UnitMove) )
                {
                    if ( MouseOverTerrain != null )
                    {
                        if ( Map.SelectedUnits.Count > 0 )
                        {
                            Position.XY_dbl Centre = App.CalcUnitsCentrePos(Map.SelectedUnits.GetItemsAsSimpleList());
                            sXY_int Offset = new sXY_int();
                            Offset.X = ((int)(Math.Round(Convert.ToDouble((MouseOverTerrain.Pos.Horizontal.X - Centre.X) / App.TerrainGridSpacing)))) *
                                       App.TerrainGridSpacing;
                            Offset.Y = ((int)(Math.Round(Convert.ToDouble((MouseOverTerrain.Pos.Horizontal.Y - Centre.Y) / App.TerrainGridSpacing)))) *
                                       App.TerrainGridSpacing;
                            clsMap.clsObjectPosOffset ObjectPosOffset = new clsMap.clsObjectPosOffset();
                            ObjectPosOffset.Map = Map;
                            ObjectPosOffset.Offset = Offset;
                            Map.SelectedUnitsAction(ObjectPosOffset);

                            Map.UndoStepCreate("Objects Moved");
                            Map.Update();
                            Map.MinimapMakeLater();
                            Program.frmMainInstance.SelectedObject_Changed();
                            DrawViewLater();
                        }
                    }
                }
                if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.Clockwise) )
                {
                    clsMap.clsObjectRotationOffset ObjectRotationOffset = new clsMap.clsObjectRotationOffset();
                    ObjectRotationOffset.Map = Map;
                    ObjectRotationOffset.Offset = -90;
                    Map.SelectedUnitsAction(ObjectRotationOffset);
                    Map.Update();
                    Program.frmMainInstance.SelectedObject_Changed();
                    Map.UndoStepCreate("Object Rotated");
                    DrawViewLater();
                }
                if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.CounterClockwise) )
                {
                    clsMap.clsObjectRotationOffset ObjectRotationOffset = new clsMap.clsObjectRotationOffset();
                    ObjectRotationOffset.Map = Map;
                    ObjectRotationOffset.Offset = 90;
                    Map.SelectedUnitsAction(ObjectRotationOffset);
                    Map.Update();
                    Program.frmMainInstance.SelectedObject_Changed();
                    Map.UndoStepCreate("Object Rotated");
                    DrawViewLater();
                }
            }

            if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.Deselect) )
            {
                modTools.Tool = modTools.Tools.ObjectSelect;
                DrawViewLater();
            }

            if ( KeyboardManager.KeyboardProfile.Active(KeyboardManager.PreviousTool) )
            {
                modTools.Tool = modTools.PreviousTool;
                DrawViewLater();
            }
        }
Пример #8
0
 public int GetVertexAltitude(sXY_int VertexNum)
 {
     return Terrain.Vertices[VertexNum.X, VertexNum.Y].Height * HeightMultiplier;
 }
Пример #9
0
        public clsMap(clsMap MapToCopy, sXY_int Offset, sXY_int Area)
        {
            frmMainLink = new ConnectedListLink<clsMap, frmMain>(this);
            Gateways = new ConnectedList<clsGateway, clsMap>(this);

            int EndX = 0;
            int EndY = 0;
            int X = 0;
            int Y = 0;

            Initialize();

            //make some map data for selection

            EndX = Math.Min(MapToCopy.Terrain.TileSize.X - Offset.X, Area.X);
            EndY = Math.Min(MapToCopy.Terrain.TileSize.Y - Offset.Y, Area.Y);

            Terrain = new clsTerrain(Area);

            for ( Y = 0; Y <= Terrain.TileSize.Y - 1; Y++ )
            {
                for ( X = 0; X <= Terrain.TileSize.X - 1; X++ )
                {
                    Terrain.Tiles[X, Y].Texture.TextureNum = -1;
                }
            }

            for ( Y = 0; Y <= EndY; Y++ )
            {
                for ( X = 0; X <= EndX; X++ )
                {
                    Terrain.Vertices[X, Y].Height = MapToCopy.Terrain.Vertices[Offset.X + X, Offset.Y + Y].Height;
                    Terrain.Vertices[X, Y].Terrain = MapToCopy.Terrain.Vertices[Offset.X + X, Offset.Y + Y].Terrain;
                }
            }
            for ( Y = 0; Y <= EndY - 1; Y++ )
            {
                for ( X = 0; X <= EndX - 1; X++ )
                {
                    Terrain.Tiles[X, Y].Copy(MapToCopy.Terrain.Tiles[Offset.X + X, Offset.Y + Y]);
                }
            }
            for ( Y = 0; Y <= EndY; Y++ )
            {
                for ( X = 0; X <= EndX - 1; X++ )
                {
                    Terrain.SideH[X, Y].Road = MapToCopy.Terrain.SideH[Offset.X + X, Offset.Y + Y].Road;
                }
            }
            for ( Y = 0; Y <= EndY - 1; Y++ )
            {
                for ( X = 0; X <= EndX; X++ )
                {
                    Terrain.SideV[X, Y].Road = MapToCopy.Terrain.SideV[Offset.X + X, Offset.Y + Y].Road;
                }
            }

            SectorCount.X = (int)(Math.Ceiling((double)(Area.X / Constants.SectorTileSize)));
            SectorCount.Y = (int)(Math.Ceiling((double)(Area.Y / Constants.SectorTileSize)));
            Sectors = new clsSector[SectorCount.X, SectorCount.Y];
            for ( Y = 0; Y <= SectorCount.Y - 1; Y++ )
            {
                for ( X = 0; X <= SectorCount.X - 1; X++ )
                {
                    Sectors[X, Y] = new clsSector(new sXY_int(X, Y));
                }
            }

            sXY_int PosDif = new sXY_int();
            clsUnitAdd NewUnitAdd = new clsUnitAdd();
            NewUnitAdd.Map = this;
            clsUnit NewUnit = default(clsUnit);

            clsGateway Gateway = default(clsGateway);
            foreach ( clsGateway tempLoopVar_Gateway in MapToCopy.Gateways )
            {
                Gateway = tempLoopVar_Gateway;
                GatewayCreate(new sXY_int(Gateway.PosA.X - Offset.X, Gateway.PosA.Y - Offset.Y),
                    new sXY_int(Gateway.PosB.X - Offset.X, Gateway.PosB.Y - Offset.Y));
            }

            PosDif.X = - Offset.X * App.TerrainGridSpacing;
            PosDif.Y = - Offset.Y * App.TerrainGridSpacing;
            clsUnit Unit = default(clsUnit);
            sXY_int NewPos = new sXY_int();
            foreach ( clsUnit tempLoopVar_Unit in MapToCopy.Units )
            {
                Unit = tempLoopVar_Unit;
                NewPos = Unit.Pos.Horizontal + PosDif;
                if ( PosIsOnMap(NewPos) )
                {
                    NewUnit = new clsUnit(Unit, this);
                    NewUnit.Pos.Horizontal = NewPos;
                    NewUnitAdd.NewUnit = NewUnit;
                    NewUnitAdd.Label = Unit.Label;
                    NewUnitAdd.Perform();
                }
            }
        }
Пример #10
0
        public App.sWorldPos GetTileOffsetRotatedWorldPos(sXY_int Tile, sXY_int TileOffsetToRotate)
        {
            App.sWorldPos Result = new App.sWorldPos();

            sXY_int RotatedOffset = new sXY_int();

            RotatedOffset = TileUtil.GetTileRotatedOffset(Terrain.Tiles[Tile.X, Tile.Y].Texture.Orientation, TileOffsetToRotate);
            Result.Horizontal.X = Tile.X * App.TerrainGridSpacing + RotatedOffset.X;
            Result.Horizontal.Y = Tile.Y * App.TerrainGridSpacing + RotatedOffset.Y;
            Result.Altitude = (int)(GetTerrainHeight(Result.Horizontal));

            return Result;
        }
Пример #11
0
        public double GetTerrainHeight(sXY_int Horizontal)
        {
            int X1 = 0;
            int X2 = 0;
            int Y1 = 0;
            int Y2 = 0;
            double InTileX = 0;
            double InTileZ = 0;
            int XG = 0;
            int YG = 0;
            double GradientX = 0;
            double GradientY = 0;
            double Offset = 0;
            double RatioX = 0;
            double RatioY = 0;

            XG = Conversion.Int(Horizontal.X / App.TerrainGridSpacing);
            YG = (int)(Conversion.Int(Horizontal.Y / App.TerrainGridSpacing));
            InTileX = MathUtil.Clamp_dbl(Horizontal.X / App.TerrainGridSpacing - XG, 0.0D, 1.0D);
            InTileZ = MathUtil.Clamp_dbl(Horizontal.Y / App.TerrainGridSpacing - YG, 0.0D, 1.0D);
            X1 = MathUtil.Clamp_int(XG, 0, Terrain.TileSize.X - 1);
            Y1 = MathUtil.Clamp_int(YG, 0, Terrain.TileSize.Y - 1);
            X2 = MathUtil.Clamp_int(XG + 1, 0, Terrain.TileSize.X);
            Y2 = MathUtil.Clamp_int(YG + 1, 0, Terrain.TileSize.Y);
            if ( Terrain.Tiles[X1, Y1].Tri )
            {
                if ( InTileZ <= 1.0D - InTileX )
                {
                    Offset = Terrain.Vertices[X1, Y1].Height;
                    GradientX = Convert.ToDouble(Terrain.Vertices[X2, Y1].Height - Offset);
                    GradientY = Convert.ToDouble(Terrain.Vertices[X1, Y2].Height - Offset);
                    RatioX = InTileX;
                    RatioY = InTileZ;
                }
                else
                {
                    Offset = Terrain.Vertices[X2, Y2].Height;
                    GradientX = Convert.ToDouble(Terrain.Vertices[X1, Y2].Height - Offset);
                    GradientY = Convert.ToDouble(Terrain.Vertices[X2, Y1].Height - Offset);
                    RatioX = 1.0D - InTileX;
                    RatioY = 1.0D - InTileZ;
                }
            }
            else
            {
                if ( InTileZ <= InTileX )
                {
                    Offset = Terrain.Vertices[X2, Y1].Height;
                    GradientX = Convert.ToDouble(Terrain.Vertices[X1, Y1].Height - Offset);
                    GradientY = Convert.ToDouble(Terrain.Vertices[X2, Y2].Height - Offset);
                    RatioX = 1.0D - InTileX;
                    RatioY = InTileZ;
                }
                else
                {
                    Offset = Terrain.Vertices[X1, Y2].Height;
                    GradientX = Convert.ToDouble(Terrain.Vertices[X2, Y2].Height - Offset);
                    GradientY = Convert.ToDouble(Terrain.Vertices[X1, Y1].Height - Offset);
                    RatioX = InTileX;
                    RatioY = 1.0D - InTileZ;
                }
            }
            return (Offset + GradientX * RatioX + GradientY * RatioY) * HeightMultiplier;
        }
Пример #12
0
            public clsTerrain(sXY_int NewSize)
            {
                TileSize = NewSize;

                Vertices = new Vertex[TileSize.X + 1, TileSize.Y + 1];
                Tiles = new Tile[TileSize.X, TileSize.Y];
                SideH = new Side[TileSize.X, TileSize.Y + 1];
                SideV = new Side[TileSize.X + 1, TileSize.Y];
                int X = 0;
                int Y = 0;

                for ( Y = 0; Y <= TileSize.Y - 1; Y++ )
                {
                    for ( X = 0; X <= TileSize.X - 1; X++ )
                    {
                        Tiles[X, Y].Texture.TextureNum = -1;
                        Tiles[X, Y].DownSide = TileUtil.None;
                    }
                }
            }
Пример #13
0
            public clsSector(sXY_int NewPos)
            {
                Units = new ConnectedList<clsUnitSectorConnection, clsSector>(this);

                Pos = NewPos;
            }
Пример #14
0
 public clsMinimapTexture(sXY_int Size)
 {
     this.Size = Size;
     InlinePixels = new sRGBA_sng[Size.X * Size.Y];
 }
Пример #15
0
        protected void TerrainBlank(sXY_int TileSize)
        {
            int X = 0;
            int Y = 0;

            Terrain = new clsTerrain(TileSize);
            SectorCount.X = (int)(Math.Ceiling((double)(Terrain.TileSize.X / Constants.SectorTileSize)));
            SectorCount.Y = (int)(Math.Ceiling((double)(Terrain.TileSize.Y / Constants.SectorTileSize)));
            Sectors = new clsSector[SectorCount.X, SectorCount.Y];
            for ( Y = 0; Y <= SectorCount.Y - 1; Y++ )
            {
                for ( X = 0; X <= SectorCount.X - 1; X++ )
                {
                    Sectors[X, Y] = new clsSector(new sXY_int(X, Y));
                }
            }
        }
Пример #16
0
        public sXY_int GetPosVertexNum(sXY_int Horizontal)
        {
            sXY_int Result = new sXY_int();

            Result.X = (int)(Math.Round((double)(Horizontal.X / App.TerrainGridSpacing)));
            Result.Y = (int)(Math.Round((double)(Horizontal.Y / App.TerrainGridSpacing)));

            return Result;
        }
Пример #17
0
        public sXY_int GetSectorNumClamped(sXY_int SectorNum)
        {
            sXY_int Result = new sXY_int();

            Result.X = MathUtil.Clamp_int(SectorNum.X, 0, SectorCount.X - 1);
            Result.Y = MathUtil.Clamp_int(SectorNum.Y, 0, SectorCount.Y - 1);

            return Result;
        }
Пример #18
0
        public void DrawTileOrientation(sXY_int Tile)
        {
            TileOrientation TileOrientation;
            sXY_int UnrotatedPos = new sXY_int();
            App.sWorldPos Vertex0 = new App.sWorldPos();
            App.sWorldPos Vertex1 = new App.sWorldPos();
            App.sWorldPos Vertex2 = new App.sWorldPos();

            TileOrientation = Terrain.Tiles[Tile.X, Tile.Y].Texture.Orientation;

            UnrotatedPos.X = 32;
            UnrotatedPos.Y = 32;
            Vertex0 = GetTileOffsetRotatedWorldPos(Tile, UnrotatedPos);

            UnrotatedPos.X = 64;
            UnrotatedPos.Y = 32;
            Vertex1 = GetTileOffsetRotatedWorldPos(Tile, UnrotatedPos);

            UnrotatedPos.X = 64;
            UnrotatedPos.Y = 64;
            Vertex2 = GetTileOffsetRotatedWorldPos(Tile, UnrotatedPos);

            GL.Vertex3(Vertex0.Horizontal.X, Vertex0.Altitude, Vertex0.Horizontal.Y);
            GL.Vertex3(Vertex1.Horizontal.X, Vertex1.Altitude, Vertex1.Horizontal.Y);
            GL.Vertex3(Vertex2.Horizontal.X, Vertex2.Altitude, Vertex2.Horizontal.Y);
        }
Пример #19
0
        public double GetTerrainSlopeAngle(sXY_int Horizontal)
        {
            int X1 = 0;
            int X2 = 0;
            int Y1 = 0;
            int Y2 = 0;
            double InTileX = 0;
            double InTileZ = 0;
            int XG = 0;
            int YG = 0;
            double GradientX = 0;
            double GradientY = 0;
            double Offset = 0;
            Position.XYZ_dbl XYZ_dbl = default(Position.XYZ_dbl);
            Position.XYZ_dbl XYZ_dbl2 = default(Position.XYZ_dbl);
            Position.XYZ_dbl XYZ_dbl3 = default(Position.XYZ_dbl);
            Angles.AnglePY AnglePY = default(Angles.AnglePY);

            XG = Conversion.Int(Horizontal.X / App.TerrainGridSpacing);
            YG = (int)(Conversion.Int(Horizontal.Y / App.TerrainGridSpacing));
            InTileX = MathUtil.Clamp_dbl(Horizontal.X / App.TerrainGridSpacing - XG, 0.0D, 1.0D);
            InTileZ = MathUtil.Clamp_dbl(Horizontal.Y / App.TerrainGridSpacing - YG, 0.0D, 1.0D);
            X1 = MathUtil.Clamp_int(XG, 0, Terrain.TileSize.X - 1);
            Y1 = MathUtil.Clamp_int(YG, 0, Terrain.TileSize.Y - 1);
            X2 = MathUtil.Clamp_int(XG + 1, 0, Terrain.TileSize.X);
            Y2 = MathUtil.Clamp_int(YG + 1, 0, Terrain.TileSize.Y);
            if ( Terrain.Tiles[X1, Y1].Tri )
            {
                if ( InTileZ <= 1.0D - InTileX )
                {
                    Offset = Terrain.Vertices[X1, Y1].Height;
                    GradientX = Convert.ToDouble(Terrain.Vertices[X2, Y1].Height - Offset);
                    GradientY = Convert.ToDouble(Terrain.Vertices[X1, Y2].Height - Offset);
                }
                else
                {
                    Offset = Terrain.Vertices[X2, Y2].Height;
                    GradientX = Convert.ToDouble(Terrain.Vertices[X1, Y2].Height - Offset);
                    GradientY = Convert.ToDouble(Terrain.Vertices[X2, Y1].Height - Offset);
                }
            }
            else
            {
                if ( InTileZ <= InTileX )
                {
                    Offset = Terrain.Vertices[X2, Y1].Height;
                    GradientX = Convert.ToDouble(Terrain.Vertices[X1, Y1].Height - Offset);
                    GradientY = Convert.ToDouble(Terrain.Vertices[X2, Y2].Height - Offset);
                }
                else
                {
                    Offset = Terrain.Vertices[X1, Y2].Height;
                    GradientX = Convert.ToDouble(Terrain.Vertices[X2, Y2].Height - Offset);
                    GradientY = Convert.ToDouble(Terrain.Vertices[X1, Y1].Height - Offset);
                }
            }

            XYZ_dbl.X = App.TerrainGridSpacing;
            XYZ_dbl.Y = GradientX * HeightMultiplier;
            XYZ_dbl.Z = 0.0D;
            XYZ_dbl2.X = 0.0D;
            XYZ_dbl2.Y = GradientY * HeightMultiplier;
            XYZ_dbl2.Z = App.TerrainGridSpacing;
            Matrix3DMath.VectorCrossProduct(XYZ_dbl, XYZ_dbl2, ref XYZ_dbl3);
            if ( XYZ_dbl3.X != 0.0D | XYZ_dbl3.Z != 0.0D )
            {
                Matrix3DMath.VectorToPY(XYZ_dbl3, ref AnglePY);
                return MathUtil.RadOf90Deg - Math.Abs(AnglePY.Pitch);
            }
            else
            {
                return 0.0D;
            }
        }
Пример #20
0
        public clsGateway GatewayCreate(sXY_int PosA, sXY_int PosB)
        {
            if ( PosA.X >= 0 & PosA.X < Terrain.TileSize.X &
                 PosA.Y >= 0 & PosA.Y < Terrain.TileSize.Y &
                 PosB.X >= 0 & PosB.X < Terrain.TileSize.X &
                 PosB.Y >= 0 & PosB.Y < Terrain.TileSize.Y ) //is on map
            {
                if ( PosA.X == PosB.X | PosA.Y == PosB.Y ) //is straight
                {
                    clsGateway Gateway = new clsGateway();

                    Gateway.PosA = PosA;
                    Gateway.PosB = PosB;

                    Gateway.MapLink.Connect(Gateways);

                    return Gateway;
                }
                else
                {
                    return null;
                }
            }
            else
            {
                return null;
            }
        }
Пример #21
0
        public bool GetTerrainTri(sXY_int Horizontal)
        {
            int X1 = 0;
            int Y1 = 0;
            double InTileX = 0;
            double InTileZ = 0;
            int XG = 0;
            int YG = 0;

            XG = (int)(Conversion.Int(Horizontal.X / App.TerrainGridSpacing));
            YG = Conversion.Int(Horizontal.Y / App.TerrainGridSpacing);
            InTileX = MathUtil.Clamp_dbl(Horizontal.X / App.TerrainGridSpacing - XG, 0.0D, 1.0D);
            InTileZ = MathUtil.Clamp_dbl(Horizontal.Y / App.TerrainGridSpacing - YG, 0.0D, 1.0D);
            X1 = MathUtil.Clamp_int(XG, 0, Terrain.TileSize.X - 1);
            Y1 = MathUtil.Clamp_int(YG, 0, Terrain.TileSize.Y - 1);
            if ( Terrain.Tiles[X1, Y1].Tri )
            {
                if ( InTileZ <= 1.0D - InTileX )
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
            else
            {
                if ( InTileZ <= InTileX )
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
Пример #22
0
        public clsGateway GatewayCreateStoreChange(sXY_int PosA, sXY_int PosB)
        {
            clsGateway Gateway = default(clsGateway);

            Gateway = GatewayCreate(PosA, PosB);

            clsGatewayChange GatewayChange = new clsGatewayChange();
            GatewayChange.Type = clsGatewayChange.enumType.Added;
            GatewayChange.Gateway = Gateway;
            GatewayChanges.Add(GatewayChange);

            return Gateway;
        }
Пример #23
0
        public sXY_int GetTileSectorNum(sXY_int Tile)
        {
            sXY_int Result = new sXY_int();

            Result.X = Conversion.Int(Tile.X / Constants.SectorTileSize);
            Result.Y = Conversion.Int(Tile.Y / Constants.SectorTileSize);

            return Result;
        }
Пример #24
0
        public void GetFootprintTileRange(sXY_int Horizontal, sXY_int Footprint, sXY_int ResultStart, sXY_int ResultFinish)
        {
            int Remainder = 0;
            sXY_int Centre = GetPosTileNum(Horizontal);
            int Half = 0;

            Half = Math.DivRem(Footprint.X, 2, out Remainder);
            ResultStart.X = Centre.X - Half;
            ResultFinish.X = ResultStart.X + Footprint.X - 1;
            Half = Math.DivRem(Footprint.Y, 2, out Remainder);
            ResultStart.Y = Centre.Y - Half;
            ResultFinish.Y = ResultStart.Y + Footprint.Y - 1;
        }
Пример #25
0
 public void GetTileSectorRange(sXY_int StartTile, sXY_int FinishTile, ref sXY_int ResultSectorStart,
     ref sXY_int ResultSectorFinish)
 {
     ResultSectorStart = GetTileSectorNum(StartTile);
     ResultSectorFinish = GetTileSectorNum(FinishTile);
     ResultSectorStart.X = MathUtil.Clamp_int(ResultSectorStart.X, 0, SectorCount.X - 1);
     ResultSectorStart.Y = MathUtil.Clamp_int(ResultSectorStart.Y, 0, SectorCount.Y - 1);
     ResultSectorFinish.X = MathUtil.Clamp_int(ResultSectorFinish.X, 0, SectorCount.X - 1);
     ResultSectorFinish.Y = MathUtil.Clamp_int(ResultSectorFinish.Y, 0, SectorCount.Y - 1);
 }
Пример #26
0
        public void GetFootprintTileRangeClamped(sXY_int Horizontal, sXY_int Footprint, sXY_int ResultStart, sXY_int ResultFinish)
        {
            int Remainder = 0;
            sXY_int Centre = GetPosTileNum(Horizontal);
            int Half = 0;

            Half = Math.DivRem(Footprint.X, 2, out Remainder);
            ResultStart.X = MathUtil.Clamp_int(Centre.X - Half, 0, Terrain.TileSize.X - 1);
            ResultFinish.X = MathUtil.Clamp_int(ResultStart.X + Footprint.X - 1, 0, Terrain.TileSize.X - 1);
            Half = Math.DivRem(Footprint.Y, 2, out Remainder);
            ResultStart.Y = MathUtil.Clamp_int(Centre.Y - Half, 0, Terrain.TileSize.Y - 1);
            ResultFinish.Y = MathUtil.Clamp_int(ResultStart.Y + Footprint.Y - 1, 0, Terrain.TileSize.Y - 1);
        }
Пример #27
0
        public void MapInsert(clsMap MapToInsert, sXY_int Offset, sXY_int Area, bool InsertHeights, bool InsertTextures, bool InsertUnits,
            bool DeleteUnits, bool InsertGateways, bool DeleteGateways)
        {
            sXY_int Finish = new sXY_int();
            int X = 0;
            int Y = 0;
            sXY_int SectorStart = new sXY_int();
            sXY_int SectorFinish = new sXY_int();
            sXY_int AreaAdjusted = new sXY_int();
            sXY_int SectorNum = new sXY_int();

            Finish.X = Math.Min(Offset.X + Math.Min(Area.X, MapToInsert.Terrain.TileSize.X), Terrain.TileSize.X);
            Finish.Y = Math.Min(Offset.Y + Math.Min(Area.Y, MapToInsert.Terrain.TileSize.Y), Terrain.TileSize.Y);
            AreaAdjusted.X = Finish.X - Offset.X;
            AreaAdjusted.Y = Finish.Y - Offset.Y;

            GetTileSectorRange(new sXY_int(Offset.X - 1, Offset.Y - 1), Finish, ref SectorStart, ref SectorFinish);
            for ( Y = SectorStart.Y; Y <= SectorFinish.Y; Y++ )
            {
                SectorNum.Y = Y;
                for ( X = SectorStart.X; X <= SectorFinish.X; X++ )
                {
                    SectorNum.X = X;
                    SectorGraphicsChanges.Changed(SectorNum);
                    SectorUnitHeightsChanges.Changed(SectorNum);
                    SectorTerrainUndoChanges.Changed(SectorNum);
                }
            }

            if ( InsertHeights )
            {
                for ( Y = 0; Y <= AreaAdjusted.Y; Y++ )
                {
                    for ( X = 0; X <= AreaAdjusted.X; X++ )
                    {
                        Terrain.Vertices[Offset.X + X, Offset.Y + Y].Height = MapToInsert.Terrain.Vertices[X, Y].Height;
                    }
                }
                for ( Y = 0; Y <= AreaAdjusted.Y - 1; Y++ )
                {
                    for ( X = 0; X <= AreaAdjusted.X - 1; X++ )
                    {
                        Terrain.Tiles[Offset.X + X, Offset.Y + Y].Tri = MapToInsert.Terrain.Tiles[X, Y].Tri;
                    }
                }
            }
            if ( InsertTextures )
            {
                for ( Y = 0; Y <= AreaAdjusted.Y; Y++ )
                {
                    for ( X = 0; X <= AreaAdjusted.X; X++ )
                    {
                        Terrain.Vertices[Offset.X + X, Offset.Y + Y].Terrain = MapToInsert.Terrain.Vertices[X, Y].Terrain;
                    }
                }
                bool TriDirection = default(bool);
                for ( Y = 0; Y <= AreaAdjusted.Y - 1; Y++ )
                {
                    for ( X = 0; X <= AreaAdjusted.X - 1; X++ )
                    {
                        TriDirection = Terrain.Tiles[Offset.X + X, Offset.Y + Y].Tri;
                        Terrain.Tiles[Offset.X + X, Offset.Y + Y].Copy(MapToInsert.Terrain.Tiles[X, Y]);
                        Terrain.Tiles[Offset.X + X, Offset.Y + Y].Tri = TriDirection;
                    }
                }
                for ( Y = 0; Y <= AreaAdjusted.Y; Y++ )
                {
                    for ( X = 0; X <= AreaAdjusted.X - 1; X++ )
                    {
                        Terrain.SideH[Offset.X + X, Offset.Y + Y].Road = MapToInsert.Terrain.SideH[X, Y].Road;
                    }
                }
                for ( Y = 0; Y <= AreaAdjusted.Y - 1; Y++ )
                {
                    for ( X = 0; X <= AreaAdjusted.X; X++ )
                    {
                        Terrain.SideV[Offset.X + X, Offset.Y + Y].Road = MapToInsert.Terrain.SideV[X, Y].Road;
                    }
                }
            }

            sXY_int LastTile = new sXY_int();
            LastTile = Finish;
            LastTile.X--;
            LastTile.Y--;
            if ( DeleteGateways )
            {
                int A = 0;
                A = 0;
                while ( A < Gateways.Count )
                {
                    if ( Gateways[A].PosA.IsInRange(Offset, LastTile) || Gateways[A].PosB.IsInRange(Offset, LastTile) )
                    {
                        GatewayRemoveStoreChange(A);
                    }
                    else
                    {
                        A++;
                    }
                }
            }
            if ( InsertGateways )
            {
                sXY_int GateStart = new sXY_int();
                sXY_int GateFinish = new sXY_int();
                clsGateway Gateway = default(clsGateway);
                foreach ( clsGateway tempLoopVar_Gateway in MapToInsert.Gateways )
                {
                    Gateway = tempLoopVar_Gateway;
                    GateStart.X = Offset.X + Gateway.PosA.X;
                    GateStart.Y = Offset.Y + Gateway.PosA.Y;
                    GateFinish.X = Offset.X + Gateway.PosB.X;
                    GateFinish.Y = Offset.Y + Gateway.PosB.Y;
                    if ( GateStart.IsInRange(Offset, LastTile) || GateFinish.IsInRange(Offset, LastTile) )
                    {
                        GatewayCreateStoreChange(GateStart, GateFinish);
                    }
                }
            }

            if ( DeleteUnits )
            {
                SimpleList<clsUnit> UnitsToDelete = new SimpleList<clsUnit>();
                int UnitToDeleteCount = 0;
                clsUnit Unit = default(clsUnit);
                for ( Y = SectorStart.Y; Y <= SectorFinish.Y; Y++ )
                {
                    for ( X = SectorStart.X; X <= SectorFinish.X; X++ )
                    {
                        clsUnitSectorConnection Connection = default(clsUnitSectorConnection);
                        foreach ( clsUnitSectorConnection tempLoopVar_Connection in Sectors[X, Y].Units )
                        {
                            Connection = tempLoopVar_Connection;
                            Unit = Connection.Unit;
                            if ( App.PosIsWithinTileArea(Unit.Pos.Horizontal, Offset, Finish) )
                            {
                                UnitsToDelete.Add(Unit);
                            }
                        }
                    }
                }
                foreach ( clsUnit tempLoopVar_Unit in UnitsToDelete )
                {
                    Unit = tempLoopVar_Unit;
                    if ( Unit.MapLink.IsConnected ) //units may be in the list multiple times and already be deleted
                    {
                        UnitRemoveStoreChange(Unit.MapLink.ArrayPosition);
                    }
                }
            }
            if ( InsertUnits )
            {
                sXY_int PosDif = new sXY_int();
                clsUnit NewUnit = default(clsUnit);
                clsUnit Unit = default(clsUnit);
                sXY_int ZeroPos = new sXY_int(0, 0);
                clsUnitAdd UnitAdd = new clsUnitAdd();

                UnitAdd.Map = this;
                UnitAdd.StoreChange = true;

                PosDif.X = Offset.X * App.TerrainGridSpacing;
                PosDif.Y = Offset.Y * App.TerrainGridSpacing;
                foreach ( clsUnit tempLoopVar_Unit in MapToInsert.Units )
                {
                    Unit = tempLoopVar_Unit;
                    if ( App.PosIsWithinTileArea(Unit.Pos.Horizontal, ZeroPos, AreaAdjusted) )
                    {
                        NewUnit = new clsUnit(Unit, this);
                        NewUnit.Pos.Horizontal.X += PosDif.X;
                        NewUnit.Pos.Horizontal.Y += PosDif.Y;
                        UnitAdd.NewUnit = NewUnit;
                        UnitAdd.Label = Unit.Label;
                        UnitAdd.Perform();
                    }
                }
            }

            SectorsUpdateGraphics();
            SectorsUpdateUnitHeights();
            MinimapMakeLater();
        }
Пример #28
0
        public sXY_int GetPosSectorNum(sXY_int Horizontal)
        {
            sXY_int Result = new sXY_int();

            Result = GetTileSectorNum(GetPosTileNum(Horizontal));

            return Result;
        }
Пример #29
0
        private void SelectUnits(sXY_int VertexA, sXY_int VertexB)
        {
            clsMap Map = MainMap;
            clsViewInfo.clsMouseOver.clsOverTerrain MouseOverTerrain = Map.ViewInfo.GetMouseOverTerrain();
            sXY_int SectorNum = new sXY_int();
            clsMap.clsUnit Unit = default(clsMap.clsUnit);
            sXY_int SectorStart = new sXY_int();
            sXY_int SectorFinish = new sXY_int();
            sXY_int StartPos = new sXY_int();
            sXY_int FinishPos = new sXY_int();
            sXY_int StartVertex = new sXY_int();
            sXY_int FinishVertex = new sXY_int();

            if ( Math.Abs(VertexA.X - VertexB.X) <= 1 &&
                 Math.Abs(VertexA.Y - VertexB.Y) <= 1 &&
                 MouseOverTerrain != null )
            {
                if ( MouseOverTerrain.Units.Count > 0 )
                {
                    if ( MouseOverTerrain.Units.Count == 1 )
                    {
                        Unit = MouseOverTerrain.Units[0];
                        if ( Unit.MapSelectedUnitLink.IsConnected )
                        {
                            Unit.MapDeselect();
                        }
                        else
                        {
                            Unit.MapSelect();
                        }
                    }
                    else
                    {
                        ListSelectBegin(false);
                    }
                }
            }
            else
            {
                MathUtil.ReorderXY(VertexA, VertexB, StartVertex, FinishVertex);
                StartPos.X = StartVertex.X * App.TerrainGridSpacing;
                StartPos.Y = StartVertex.Y * App.TerrainGridSpacing;
                FinishPos.X = FinishVertex.X * App.TerrainGridSpacing;
                FinishPos.Y = FinishVertex.Y * App.TerrainGridSpacing;
                SectorStart.X = Math.Min(Conversion.Int(StartVertex.X / Constants.SectorTileSize), Map.SectorCount.X - 1);
                SectorStart.Y = Math.Min((int)(Conversion.Int(StartVertex.Y / Constants.SectorTileSize)), Map.SectorCount.Y - 1);
                SectorFinish.X = Math.Min(Conversion.Int(FinishVertex.X / Constants.SectorTileSize), Map.SectorCount.X - 1);
                SectorFinish.Y = Math.Min(Conversion.Int(FinishVertex.Y / Constants.SectorTileSize), Map.SectorCount.Y - 1);
                for ( SectorNum.Y = SectorStart.Y; SectorNum.Y <= SectorFinish.Y; SectorNum.Y++ )
                {
                    for ( SectorNum.X = SectorStart.X; SectorNum.X <= SectorFinish.X; SectorNum.X++ )
                    {
                        clsMap.clsUnitSectorConnection Connection = default(clsMap.clsUnitSectorConnection);
                        foreach ( clsMap.clsUnitSectorConnection tempLoopVar_Connection in Map.Sectors[SectorNum.X, SectorNum.Y].Units )
                        {
                            Connection = tempLoopVar_Connection;
                            Unit = Connection.Unit;
                            if ( Unit.Pos.Horizontal.X >= StartPos.X & Unit.Pos.Horizontal.Y >= StartPos.Y &
                                 Unit.Pos.Horizontal.X <= FinishPos.X & Unit.Pos.Horizontal.Y <= FinishPos.Y )
                            {
                                if ( !Unit.MapSelectedUnitLink.IsConnected )
                                {
                                    Unit.MapSelect();
                                }
                            }
                        }
                    }
                }
            }
            Program.frmMainInstance.SelectedObject_Changed();
            DrawViewLater();
        }
Пример #30
0
        public sXY_int GetPosTileNum(sXY_int Horizontal)
        {
            sXY_int Result = new sXY_int();

            Result.X = (int)(Conversion.Int(Horizontal.X / App.TerrainGridSpacing));
            Result.Y = Conversion.Int(Horizontal.Y / App.TerrainGridSpacing);

            return Result;
        }