예제 #1
0
 public static clsResultProblemGoto<clsResultItemPosGoto> CreateResultProblemGotoForObject(clsMap.clsUnit unit)
 {
     clsResultItemPosGoto goto2 = new clsResultItemPosGoto {
         View = unit.MapLink.Source.ViewInfo,
         Horizontal = unit.Pos.Horizontal
     };
     return new clsResultProblemGoto<clsResultItemPosGoto> { MapGoto = goto2 };
 }
예제 #2
0
 public clsViewInfo(clsMap Map, ctrlMapView MapView)
 {
     this.Map = Map;
     this.MapView = MapView;
     this.ViewPos = new modMath.sXYZ_int(0, 0xc00, 0);
     this.FOV_Multiplier_Set(modSettings.Settings.FOVDefault);
     this.ViewAngleSetToDefault();
     modMath.sXY_int horizontal = new modMath.sXY_int((int) Math.Round((double) (((double) (Map.Terrain.TileSize.X * 0x80)) / 2.0)), (int) Math.Round((double) (((double) (Map.Terrain.TileSize.Y * 0x80)) / 2.0)));
     this.LookAtPos(horizontal);
 }
예제 #3
0
 private frmCompile(clsMap Map)
 {
     base.FormClosed += new FormClosedEventHandler(this.frmCompile_FormClosed);
     base.FormClosing += new FormClosingEventHandler(this.frmCompile_FormClosing);
     this.InitializeComponent();
     this.Icon = modProgram.ProgramIcon;
     this.Map = Map;
     Map.CompileScreen = this;
     this.UpdateControls();
 }
예제 #4
0
        private frmCompile(clsMap Map)
        {
            InitializeComponent();

            Icon = App.ProgramIcon;

            this.Map = Map;
            Map.CompileScreen = this;

            UpdateControls();
        }
예제 #5
0
        public clsViewInfo(clsMap map, MapViewControl mapViewControl)
        {
            Map = map;
            MapViewControl = mapViewControl;

            ViewPos = new XYZInt(0, 3072, 0);
            FOV_Multiplier_Set(SettingsManager.Settings.FOVDefault);
            ViewAngleSetToDefault();
            LookAtPos(new XYInt((int)(map.Terrain.TileSize.X * Constants.TerrainGridSpacing / 2.0D),
                (int)(map.Terrain.TileSize.Y * Constants.TerrainGridSpacing / 2.0D)));
        }
예제 #6
0
        public static frmCompile Create(clsMap Map)
        {
            if ( Map == null )
            {
                Debugger.Break();
                return null;
            }

            if ( Map.CompileScreen != null )
            {
                Debugger.Break();
                return null;
            }

            return new frmCompile(Map);
        }
예제 #7
0
 public Minimap(clsMap newMap)
 {
     map = newMap;
 }
예제 #8
0
 public clsAutoTextureChanges(clsMap Map)
     : base(Map, Map.Terrain.TileSize)
 {
 }
예제 #9
0
        public clsMap.clsUnit PlaceUnitNear(clsUnitType Type, sXY_int Pos, clsMap.clsUnitGroup UnitGroup, int Clearance, int Rotation, int MaxDistFromPos)
        {
            PathfinderNode PosNode = default(PathfinderNode);
            clsNodeTag NodeTag = default(clsNodeTag);
            sXY_int FinalTilePos = new sXY_int();
            sXY_int TilePosA = new sXY_int();
            sXY_int TilePosB = new sXY_int();
            int X2 = 0;
            int Y2 = 0;
            int Remainder = 0;
            sXY_int Footprint = new sXY_int();

            PosNode = GetNearestNodeConnection(TilePathMap, Pos, Clearance, MaxDistFromPos);
            if ( PosNode != null )
            {
                NodeTag = (clsNodeTag)PosNode.Tag;
                if ( (Pos - NodeTag.Pos).ToDoubles().GetMagnitude() <= MaxDistFromPos )
                {
                    clsMap.clsUnitAdd NewUnitAdd = new clsMap.clsUnitAdd();
                    NewUnitAdd.Map = Map;
                    NewUnitAdd.StoreChange = true;
                    clsMap.clsUnit NewUnit = new clsMap.clsUnit();
                    NewUnitAdd.NewUnit = NewUnit;
                    NewUnit.Type = Type;
                    NewUnit.UnitGroup = UnitGroup;

                    FinalTilePos.X = (int)(Conversion.Int(NodeTag.Pos.X / App.TerrainGridSpacing));
                    FinalTilePos.Y = Conversion.Int(NodeTag.Pos.Y / App.TerrainGridSpacing);
                    Footprint = Type.get_GetFootprintSelected(Rotation);
                    Remainder = Footprint.X % 2;
                    if ( Remainder > 0 )
                    {
                        NewUnit.Pos.Horizontal.X = NodeTag.Pos.X;
                    }
                    else
                    {
                        if ( VBMath.Rnd() >= 0.5F )
                        {
                            NewUnit.Pos.Horizontal.X = (int)(NodeTag.Pos.X - App.TerrainGridSpacing / 2.0D);
                        }
                        else
                        {
                            NewUnit.Pos.Horizontal.X = (int)(NodeTag.Pos.X + App.TerrainGridSpacing / 2.0D);
                        }
                    }
                    Remainder = Footprint.Y % 2;
                    if ( Remainder > 0 )
                    {
                        NewUnit.Pos.Horizontal.Y = NodeTag.Pos.Y;
                    }
                    else
                    {
                        if ( VBMath.Rnd() >= 0.5F )
                        {
                            NewUnit.Pos.Horizontal.Y = (int)(NodeTag.Pos.Y - App.TerrainGridSpacing / 2.0D);
                        }
                        else
                        {
                            NewUnit.Pos.Horizontal.Y = (int)(NodeTag.Pos.Y + App.TerrainGridSpacing / 2.0D);
                        }
                    }
                    TilePosA.X = (int)Conversion.Int(NewUnit.Pos.Horizontal.X / App.TerrainGridSpacing - Footprint.X / 2.0D + 0.5D);
                    TilePosA.Y = (int)Conversion.Int(NewUnit.Pos.Horizontal.Y / App.TerrainGridSpacing - Footprint.Y / 2.0D + 0.5D);
                    TilePosB.X = (int)(Conversion.Int(NewUnit.Pos.Horizontal.X / App.TerrainGridSpacing + Footprint.X / 2.0D - 0.5D));
                    TilePosB.Y = (int)(Conversion.Int(NewUnit.Pos.Horizontal.Y / App.TerrainGridSpacing + Footprint.Y / 2.0D - 0.5D));
                    NewUnit.Rotation = Rotation;

                    NewUnitAdd.Perform();

                    for ( Y2 = Math.Max(TilePosA.Y, 0); Y2 <= Math.Min(TilePosB.Y, Map.Terrain.TileSize.Y - 1); Y2++ )
                    {
                        for ( X2 = Math.Max(TilePosA.X, 0); X2 <= Math.Min(TilePosB.X, Map.Terrain.TileSize.X - 1); X2++ )
                        {
                            TileNodeBlock(X2, Y2);
                        }
                    }

                    TilePathMap.FindCalc();

                    return NewUnit;
                }
                else
                {
                    return null;
                }
            }
            else
            {
                return null;
            }
        }
예제 #10
0
 public void SetMap(clsMap NewMap)
 {
     int num;
     if (NewMap == null)
     {
         num = 0;
         do
         {
             this.tsbNumber[num].Tag = null;
             num++;
         }
         while (num <= 9);
         this.tsbNumber[10].Tag = null;
     }
     else
     {
         num = 0;
         do
         {
             this.tsbNumber[num].Tag = NewMap.UnitGroups[num];
             num++;
         }
         while (num <= 9);
         this.tsbNumber[10].Tag = NewMap.ScavengerUnitGroup;
     }
     this.SelectedChanged();
 }
예제 #11
0
파일: LND.cs 프로젝트: pcdummy/SharpFlame
 public LND(clsMap newMap)
 {
     map = newMap;
 }
예제 #12
0
 public clsMap.clsUnit PlaceUnit(clsUnitType Type, modProgram.sWorldPos Pos, clsMap.clsUnitGroup UnitGroup, int Rotation)
 {
     modMath.sXY_int _int;
     modMath.sXY_int _int3;
     modMath.sXY_int _int4;
     clsMap.clsUnitAdd add = new clsMap.clsUnitAdd {
         Map = this.Map,
         StoreChange = true
     };
     clsMap.clsUnit unit = new clsMap.clsUnit();
     add.NewUnit = unit;
     unit.Type = Type;
     unit.UnitGroup = UnitGroup;
     _int.X = (int) Math.Round(((double) (((double) Pos.Horizontal.X) / 128.0)));
     _int.Y = (int) Math.Round(((double) (((double) Pos.Horizontal.Y) / 128.0)));
     modMath.sXY_int _int2 = Type.get_GetFootprintSelected(Rotation);
     unit.Pos = Pos;
     _int3.X = (int) Math.Round(((double) (((((double) unit.Pos.Horizontal.X) / 128.0) - (((double) _int2.X) / 2.0)) + 0.5)));
     _int3.Y = (int) Math.Round(((double) (((((double) unit.Pos.Horizontal.Y) / 128.0) - (((double) _int2.Y) / 2.0)) + 0.5)));
     _int4.X = (int) Math.Round(((double) (((((double) unit.Pos.Horizontal.X) / 128.0) + (((double) _int2.X) / 2.0)) - 0.5)));
     _int4.Y = (int) Math.Round(((double) (((((double) unit.Pos.Horizontal.Y) / 128.0) + (((double) _int2.Y) / 2.0)) - 0.5)));
     unit.Rotation = Rotation;
     add.Perform();
     int num3 = Math.Min(_int4.Y, this.Map.Terrain.TileSize.Y - 1);
     for (int i = Math.Max(_int3.Y, 0); i <= num3; i++)
     {
         int num4 = Math.Min(_int4.X, this.Map.Terrain.TileSize.X - 1);
         for (int j = Math.Max(_int3.X, 0); j <= num4; j++)
         {
             this.TileNodeBlock(j, i);
         }
     }
     this.TilePathMap.FindCalc();
     return unit;
 }
예제 #13
0
 public void Deallocate()
 {
     Map = null;
 }
예제 #14
0
 private void PerformAction(clsMap.clsAction Action, sPosNum PosNum, modMath.sXY_int LastValidNum)
 {
     if (Action.Map == null)
     {
         Debugger.Break();
     }
     else
     {
         modMath.sXY_int posNum = this.GetPosNum(PosNum);
         Action.Effect = 1.0;
         int introduced11 = modMath.Clamp_int(this.Tiles.YMin + posNum.Y, 0, LastValidNum.Y);
         int introduced12 = modMath.Clamp_int(this.Tiles.YMax + posNum.Y, 0, LastValidNum.Y);
         int num4 = introduced12 - posNum.Y;
         for (int i = introduced11 - posNum.Y; i <= num4; i++)
         {
             Action.PosNum.Y = posNum.Y + i;
             int index = i - this.Tiles.YMin;
             int introduced13 = modMath.Clamp_int(this.Tiles.XMin[index] + posNum.X, 0, LastValidNum.X);
             int introduced14 = modMath.Clamp_int(this.Tiles.XMax[index] + posNum.X, 0, LastValidNum.X);
             int num5 = introduced14 - posNum.X;
             for (int j = introduced13 - posNum.X; j <= num5; j++)
             {
                 modMath.sXY_int _int2;
                 Action.PosNum.X = posNum.X + j;
                 if (Action.UseEffect && (this.Tiles.ResultRadius > 0.0))
                 {
                     switch (this._Shape)
                     {
                         case enumShape.Circle:
                         {
                             if (!this._Alignment)
                             {
                                 goto Label_01DD;
                             }
                             Position.XY_dbl _dbl = new Position.XY_dbl((double) Action.PosNum.X, (double) Action.PosNum.Y);
                             Position.XY_dbl _dbl2 = new Position.XY_dbl(posNum.X - 0.5, posNum.Y - 0.5);
                             Position.XY_dbl _dbl3 = _dbl - _dbl2;
                             Action.Effect = 1.0 - (_dbl3.GetMagnitude() / (this.Tiles.ResultRadius + 0.5));
                             break;
                         }
                         case enumShape.Square:
                         {
                             if (!this._Alignment)
                             {
                                 goto Label_02A3;
                             }
                             double introduced15 = Math.Abs((double) (Action.PosNum.X - (posNum.X - 0.5)));
                             Action.Effect = 1.0 - (Math.Max(introduced15, Math.Abs((double) (Action.PosNum.Y - (posNum.Y - 0.5)))) / (this.Tiles.ResultRadius + 0.5));
                             break;
                         }
                     }
                 }
                 goto Label_02FF;
             Label_01DD:
                 _int2 = posNum - Action.PosNum;
                 Action.Effect = 1.0 - (_int2.ToDoubles().GetMagnitude() / (this.Tiles.ResultRadius + 0.5));
                 goto Label_02FF;
             Label_02A3:
                 int introduced16 = Math.Abs((int) (Action.PosNum.X - posNum.X));
                 Action.Effect = 1.0 - (((double) Math.Max(introduced16, Math.Abs((int) (Action.PosNum.Y - posNum.Y)))) / (this.Tiles.ResultRadius + 0.5));
             Label_02FF:
                 Action.ActionPerform();
             }
         }
     }
 }
예제 #15
0
 public void PerformActionMapVertices(clsMap.clsAction Tool, sPosNum Centre)
 {
     this.PerformAction(Tool, Centre, Tool.Map.Terrain.TileSize);
 }
예제 #16
0
 public void PerformActionMapTiles(clsMap.clsAction Tool, sPosNum Centre)
 {
     modMath.sXY_int lastValidNum = new modMath.sXY_int(Tool.Map.Terrain.TileSize.X - 1, Tool.Map.Terrain.TileSize.Y - 1);
     this.PerformAction(Tool, Centre, lastValidNum);
 }
예제 #17
0
 public void frmCompile_FormClosed(object sender, FormClosedEventArgs e)
 {
     Map.CompileScreen = null;
     Map = null;
 }
예제 #18
0
            public IniStructures(int NewStructureCount, clsMap NewParentMap)
            {
                int A = 0;

                ParentMap = NewParentMap;

                StructureCount = NewStructureCount;
                Structures = new sStructure[StructureCount];
                for ( A = 0; A <= StructureCount - 1; A++ )
                {
                    Structures[A].HealthPercent = -1;
                    Structures[A].WallType = -1;
                }
            }
예제 #19
0
 public void PerformActionMapSectors(clsMap.clsAction Tool, sPosNum Centre)
 {
     modMath.sXY_int lastValidNum = new modMath.sXY_int(Tool.Map.SectorCount.X - 1, Tool.Map.SectorCount.Y - 1);
     this.PerformAction(Tool, Centre, lastValidNum);
 }
예제 #20
0
 public clsMapTileChanges(clsMap Map, XYInt PointSize)
     : base(PointSize)
 {
     this.Map = Map;
     Terrain = Map.Terrain;
 }
예제 #21
0
 private void frmCompile_FormClosed(object sender, FormClosedEventArgs e)
 {
     this.Map.CompileScreen = null;
     this.Map = null;
 }
예제 #22
0
 public clsResult GenerateLayoutTerrain()
 {
     int num2;
     int num4;
     double magnitude;
     clsNodeTag tag;
     PathfinderNode node2;
     int num8;
     int num9;
     modMath.sXY_int _int3;
     clsResult result2 = new clsResult("Terrain heights");
     this.Map = new clsMap(this.TileSize);
     this.GenerateTerrainTiles = new GenerateTerrainTile[(this.Map.Terrain.TileSize.X - 1) + 1, (this.Map.Terrain.TileSize.Y - 1) + 1];
     this.GenerateTerrainVertices = new GenerateTerrainVertex[this.Map.Terrain.TileSize.X + 1, this.Map.Terrain.TileSize.Y + 1];
     this.VertexPathMap = new PathfinderNetwork();
     int y = this.Map.Terrain.TileSize.Y;
     for (num9 = 0; num9 <= y; num9++)
     {
         int x = this.Map.Terrain.TileSize.X;
         num8 = 0;
         while (num8 <= x)
         {
             this.GenerateTerrainVertices[num8, num9] = new GenerateTerrainVertex();
             this.GenerateTerrainVertices[num8, num9].Node = new PathfinderNode(this.VertexPathMap);
             tag = new clsNodeTag {
                 Pos = new modMath.sXY_int(num8 * 0x80, num9 * 0x80)
             };
             this.GenerateTerrainVertices[num8, num9].Node.Tag = tag;
             num8++;
         }
     }
     int num12 = this.Map.Terrain.TileSize.Y;
     for (num9 = 0; num9 <= num12; num9++)
     {
         int num13 = this.Map.Terrain.TileSize.X;
         for (num8 = 0; num8 <= num13; num8++)
         {
             PathfinderNode node3;
             node2 = this.GenerateTerrainVertices[num8, num9].Node;
             if (num8 > 0)
             {
                 node3 = this.GenerateTerrainVertices[num8 - 1, num9].Node;
                 this.GenerateTerrainVertices[num8, num9].LeftLink = node2.GetOrCreateConnection(node3, this.GetNodePosDist(node2, node3));
             }
             if (num9 > 0)
             {
                 if (num8 > 0)
                 {
                     node3 = this.GenerateTerrainVertices[num8 - 1, num9 - 1].Node;
                     this.GenerateTerrainVertices[num8, num9].TopLeftLink = node2.GetOrCreateConnection(node3, this.GetNodePosDist(node2, node3));
                 }
                 node3 = this.GenerateTerrainVertices[num8, num9 - 1].Node;
                 this.GenerateTerrainVertices[num8, num9].TopLink = node2.GetOrCreateConnection(node3, this.GetNodePosDist(node2, node3));
                 if (num8 < this.Map.Terrain.TileSize.X)
                 {
                     node3 = this.GenerateTerrainVertices[num8 + 1, num9 - 1].Node;
                     this.GenerateTerrainVertices[num8, num9].TopRightLink = node2.GetOrCreateConnection(node3, this.GetNodePosDist(node2, node3));
                 }
             }
             if (num8 < this.Map.Terrain.TileSize.X)
             {
                 node3 = this.GenerateTerrainVertices[num8 + 1, num9].Node;
                 this.GenerateTerrainVertices[num8, num9].RightLink = node2.GetOrCreateConnection(node3, this.GetNodePosDist(node2, node3));
             }
             if (num9 < this.Map.Terrain.TileSize.Y)
             {
                 if (num8 > 0)
                 {
                     node3 = this.GenerateTerrainVertices[num8 - 1, num9 + 1].Node;
                     this.GenerateTerrainVertices[num8, num9].BottomLeftLink = node2.GetOrCreateConnection(node3, this.GetNodePosDist(node2, node3));
                 }
                 node3 = this.GenerateTerrainVertices[num8, num9 + 1].Node;
                 this.GenerateTerrainVertices[num8, num9].BottomLink = node2.GetOrCreateConnection(node3, this.GetNodePosDist(node2, node3));
                 if (num8 < this.Map.Terrain.TileSize.X)
                 {
                     node3 = this.GenerateTerrainVertices[num8 + 1, num9 + 1].Node;
                     this.GenerateTerrainVertices[num8, num9].BottomRightLink = node2.GetOrCreateConnection(node3, this.GetNodePosDist(node2, node3));
                 }
             }
         }
     }
     this.VertexPathMap.LargeArraysResize();
     this.VertexPathMap.FindCalc();
     PathfinderLayer layer = this.VertexPathMap.get_GetNodeLayer(0);
     PathfinderLayer layer2 = this.VertexPathMap.get_GetNodeLayer(this.JitterScale);
     int num = layer2.GetNodeCount - 1;
     int[] numArray = new int[num + 1];
     clsBaseNodeLevels baseLevel = new clsBaseNodeLevels {
         NodeLevels = new float[(layer.GetNodeCount - 1) + 1]
     };
     if (num > 0)
     {
         int num14 = num;
         num2 = 0;
         while (num2 <= num14)
         {
             Position.XY_dbl _dbl;
             node2 = layer2.get_GetNode(num2);
             num4 = 0;
             _dbl.X = 0.0;
             _dbl.Y = 0.0;
             this.CalcNodePos(node2, ref _dbl, ref num4);
             tag = new clsNodeTag();
             tag.Pos.X = (int) Math.Round((double) (_dbl.X / ((double) num4)));
             tag.Pos.Y = (int) Math.Round((double) (_dbl.Y / ((double) num4)));
             node2.Tag = tag;
             num2++;
         }
     }
     int num15 = layer2.GetNodeCount - 1;
     for (num = 0; num <= num15; num++)
     {
         bool flag;
         tag = (clsNodeTag) layer2.get_GetNode(num).Tag;
         numArray[num] = -1;
         double num3 = 3.4028234663852886E+38;
         clsConnection connection = null;
         clsPassageNode passageNodeA = null;
         int num16 = this.ConnectionCount - 1;
         num2 = 0;
         while (num2 <= num16)
         {
             if (this.Connections[num2].PassageNodeA.Level == this.Connections[num2].PassageNodeB.Level)
             {
                 modMath.sXY_int _int2 = modMath.PointGetClosestPosOnLine(this.Connections[num2].PassageNodeA.Pos, this.Connections[num2].PassageNodeB.Pos, tag.Pos) - tag.Pos;
                 magnitude = (float) _int2.ToDoubles().GetMagnitude();
                 if (magnitude < num3)
                 {
                     num3 = magnitude;
                     _int2 = tag.Pos - this.Connections[num2].PassageNodeA.Pos;
                     _int3 = tag.Pos - this.Connections[num2].PassageNodeB.Pos;
                     if (_int2.ToDoubles().GetMagnitude() <= _int3.ToDoubles().GetMagnitude())
                     {
                         passageNodeA = this.Connections[num2].PassageNodeA;
                     }
                     else
                     {
                         passageNodeA = this.Connections[num2].PassageNodeB;
                     }
                     flag = true;
                 }
             }
             num2++;
         }
         int num17 = this.PassageNodeCount - 1;
         for (num4 = 0; num4 <= num17; num4++)
         {
             int num18 = this.SymmetryBlockCount - 1;
             for (int i = 0; i <= num18; i++)
             {
                 _int3 = tag.Pos - this.PassageNodes[i, num4].Pos;
                 magnitude = (float) _int3.ToDoubles().GetMagnitude();
                 if (magnitude < num3)
                 {
                     num3 = magnitude;
                     passageNodeA = this.PassageNodes[i, num4];
                     flag = true;
                 }
             }
         }
         if (flag)
         {
             numArray[num] = passageNodeA.Level;
         }
         else
         {
             numArray[num] = connection.PassageNodeA.Level;
         }
         if (numArray[num] < 0)
         {
             result2.ProblemAdd("Error: Node height is not set.");
             return result2;
         }
     }
     int num19 = this.LevelCount - 1;
     num = 0;
     while (num <= num19)
     {
         int num20 = layer2.GetNodeCount - 1;
         num2 = 0;
         while (num2 <= num20)
         {
             if (numArray[num2] >= num)
             {
                 this.SetBaseLevel(layer2.get_GetNode(num2), num, baseLevel);
             }
             num2++;
         }
         num++;
     }
     int num7 = ((int) Math.Round((double) ((this.LevelHeight * this.Map.HeightMultiplier) * 2.0))) + 0x80;
     clsSetBaseLevelRampArgs args = new clsSetBaseLevelRampArgs {
         BaseLevel = baseLevel,
         RampRadius = 320f
     };
     int num21 = this.ConnectionCount - 1;
     for (num2 = 0; num2 <= num21; num2++)
     {
         args.Connection = this.Connections[num2];
         _int3 = this.Connections[num2].PassageNodeA.Pos - this.Connections[num2].PassageNodeB.Pos;
         args.RampLength = Math.Max((int) Math.Round((double) (_int3.ToDoubles().GetMagnitude() * 0.75)), num7 * Math.Abs((int) (this.Connections[num2].PassageNodeA.Level - this.Connections[num2].PassageNodeB.Level)));
         int num22 = layer2.GetNodeCount - 1;
         num = 0;
         while (num <= num22)
         {
             if (this.Connections[num2].IsRamp)
             {
                 tag = (clsNodeTag) layer2.get_GetNode(num).Tag;
                 _int3 = modMath.PointGetClosestPosOnLine(this.Connections[num2].PassageNodeA.Pos, this.Connections[num2].PassageNodeB.Pos, tag.Pos) - tag.Pos;
                 magnitude = (float) _int3.ToDoubles().GetMagnitude();
                 if (magnitude < (args.RampLength * 2f))
                 {
                     this.SetBaseLevelRamp(args, layer2.get_GetNode(num));
                 }
             }
             num++;
         }
     }
     int num23 = layer.GetNodeCount - 1;
     for (num = 0; num <= num23; num++)
     {
         tag = (clsNodeTag) layer.get_GetNode(num).Tag;
         this.Map.Terrain.Vertices[(int) Math.Round((double) (((float) tag.Pos.X) / 128f)), (int) Math.Round((double) (((float) tag.Pos.Y) / 128f))].Height = (byte) Math.Round((double) (baseLevel.NodeLevels[num] * this.LevelHeight));
     }
     return result2;
 }
예제 #23
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();
                }
            }
        }
예제 #24
0
 public clsMap.clsUnit PlaceUnitNear(clsUnitType Type, modMath.sXY_int Pos, clsMap.clsUnitGroup UnitGroup, int Clearance, int Rotation, int MaxDistFromPos)
 {
     modMath.sXY_int _int;
     modMath.sXY_int _int3;
     modMath.sXY_int _int4;
     PathfinderNode node = this.GetNearestNodeConnection(this.TilePathMap, Pos, Clearance, (float) MaxDistFromPos);
     if (node == null)
     {
         return null;
     }
     clsNodeTag tag = (clsNodeTag) node.Tag;
     modMath.sXY_int _int5 = Pos - tag.Pos;
     if (_int5.ToDoubles().GetMagnitude() > MaxDistFromPos)
     {
         return null;
     }
     clsMap.clsUnitAdd add = new clsMap.clsUnitAdd {
         Map = this.Map,
         StoreChange = true
     };
     clsMap.clsUnit unit2 = new clsMap.clsUnit();
     add.NewUnit = unit2;
     unit2.Type = Type;
     unit2.UnitGroup = UnitGroup;
     _int.X = (int) Math.Round(((double) (((double) tag.Pos.X) / 128.0)));
     _int.Y = (int) Math.Round(((double) (((double) tag.Pos.Y) / 128.0)));
     modMath.sXY_int _int2 = Type.get_GetFootprintSelected(Rotation);
     int num = _int2.X % 2;
     if (num > 0)
     {
         unit2.Pos.Horizontal.X = tag.Pos.X;
     }
     else if (App.Random.Next() >= 0.5f)
     {
         unit2.Pos.Horizontal.X = tag.Pos.X - 0x40;
     }
     else
     {
         unit2.Pos.Horizontal.X = tag.Pos.X + 0x40;
     }
     num = _int2.Y % 2;
     if (num > 0)
     {
         unit2.Pos.Horizontal.Y = tag.Pos.Y;
     }
     else if (App.Random.Next() >= 0.5f)
     {
         unit2.Pos.Horizontal.Y = tag.Pos.Y - 0x40;
     }
     else
     {
         unit2.Pos.Horizontal.Y = tag.Pos.Y + 0x40;
     }
     _int3.X = (int) Math.Round(((double) (((((double) unit2.Pos.Horizontal.X) / 128.0) - (((double) _int2.X) / 2.0)) + 0.5)));
     _int3.Y = (int) Math.Round(((double) (((((double) unit2.Pos.Horizontal.Y) / 128.0) - (((double) _int2.Y) / 2.0)) + 0.5)));
     _int4.X = (int) Math.Round(((double) (((((double) unit2.Pos.Horizontal.X) / 128.0) + (((double) _int2.X) / 2.0)) - 0.5)));
     _int4.Y = (int) Math.Round(((double) (((((double) unit2.Pos.Horizontal.Y) / 128.0) + (((double) _int2.Y) / 2.0)) - 0.5)));
     unit2.Rotation = Rotation;
     add.Perform();
     int num4 = Math.Min(_int4.Y, this.Map.Terrain.TileSize.Y - 1);
     for (int i = Math.Max(_int3.Y, 0); i <= num4; i++)
     {
         int num5 = Math.Min(_int4.X, this.Map.Terrain.TileSize.X - 1);
         for (int j = Math.Max(_int3.X, 0); j <= num5; j++)
         {
             this.TileNodeBlock(j, i);
         }
     }
     this.TilePathMap.FindCalc();
     return unit2;
 }
예제 #25
0
            public IniDroids(int NewDroidCount, clsMap NewParentMap)
            {
                int A = 0;

                ParentMap = NewParentMap;

                DroidCount = NewDroidCount;
                Droids = new sDroid[DroidCount];
                for ( A = 0; A <= DroidCount - 1; A++ )
                {
                    Droids[A].HealthPercent = -1;
                    Droids[A].DroidType = -1;
                    Droids[A].Weapons = new string[3];
                }
            }
예제 #26
0
파일: Wz.cs 프로젝트: pcdummy/SharpFlame
 public Wz(clsMap newMap)
 {
     map = newMap;
 }
예제 #27
0
        public void SetMap(clsMap NewMap)
        {
            int A = 0;

            if ( NewMap == null )
            {
                for ( A = 0; A <= Constants.PlayerCountMax - 1; A++ )
                {
                    tsbNumber[A].Tag = null;
                }
                tsbNumber[ScavButtonNum].Tag = null;
            }
            else
            {
                for ( A = 0; A <= Constants.PlayerCountMax - 1; A++ )
                {
                    tsbNumber[A].Tag = NewMap.UnitGroups[A];
                }
                tsbNumber[ScavButtonNum].Tag = NewMap.ScavengerUnitGroup;
            }
            SelectedChanged();
        }
예제 #28
0
        public clsResult GenerateLayoutTerrain()
        {
            clsResult ReturnResult = new clsResult("Terrain heights");

            clsNodeTag NodeTag = default(clsNodeTag);
            PathfinderNode tmpNodeA = default(PathfinderNode);
            PathfinderNode tmpNodeB = default(PathfinderNode);
            int A = 0;
            int B = 0;
            int C = 0;
            int D = 0;
            int X = 0;
            int Y = 0;
            sXY_int XY_int = new sXY_int();
            double Dist = 0;
            double BestDist = 0;
            bool Flag = default(bool);

            Map = new clsMap(TileSize);
            GenerateTerrainTiles = new GenerateTerrainTile[Map.Terrain.TileSize.X, Map.Terrain.TileSize.Y];
            GenerateTerrainVertices = new GenerateTerrainVertex[Map.Terrain.TileSize.X + 1, Map.Terrain.TileSize.Y + 1];

            //set terrain heights

            VertexPathMap = new PathfinderNetwork();

            for ( Y = 0; Y <= Map.Terrain.TileSize.Y; Y++ )
            {
                for ( X = 0; X <= Map.Terrain.TileSize.X; X++ )
                {
                    GenerateTerrainVertices[X, Y] = new GenerateTerrainVertex();
                    GenerateTerrainVertices[X, Y].Node = new PathfinderNode(VertexPathMap);
                    NodeTag = new clsNodeTag();
                    NodeTag.Pos = new sXY_int(X * 128, Y * 128);
                    GenerateTerrainVertices[X, Y].Node.Tag = NodeTag;
                }
            }
            for ( Y = 0; Y <= Map.Terrain.TileSize.Y; Y++ )
            {
                for ( X = 0; X <= Map.Terrain.TileSize.X; X++ )
                {
                    tmpNodeA = GenerateTerrainVertices[X, Y].Node;
                    if ( X > 0 )
                    {
                        tmpNodeB = GenerateTerrainVertices[X - 1, Y].Node;
                        GenerateTerrainVertices[X, Y].LeftLink = tmpNodeA.GetOrCreateConnection(tmpNodeB, GetNodePosDist(tmpNodeA, tmpNodeB));
                    }
                    if ( Y > 0 )
                    {
                        if ( X > 0 )
                        {
                            tmpNodeB = GenerateTerrainVertices[X - 1, Y - 1].Node;
                            GenerateTerrainVertices[X, Y].TopLeftLink = tmpNodeA.GetOrCreateConnection(tmpNodeB, GetNodePosDist(tmpNodeA, tmpNodeB));
                        }
                        tmpNodeB = GenerateTerrainVertices[X, Y - 1].Node;
                        GenerateTerrainVertices[X, Y].TopLink = tmpNodeA.GetOrCreateConnection(tmpNodeB, GetNodePosDist(tmpNodeA, tmpNodeB));
                        if ( X < Map.Terrain.TileSize.X )
                        {
                            tmpNodeB = GenerateTerrainVertices[X + 1, Y - 1].Node;
                            GenerateTerrainVertices[X, Y].TopRightLink = tmpNodeA.GetOrCreateConnection(tmpNodeB, GetNodePosDist(tmpNodeA, tmpNodeB));
                        }
                    }
                    if ( X < Map.Terrain.TileSize.X )
                    {
                        tmpNodeB = GenerateTerrainVertices[X + 1, Y].Node;
                        GenerateTerrainVertices[X, Y].RightLink = tmpNodeA.GetOrCreateConnection(tmpNodeB, GetNodePosDist(tmpNodeA, tmpNodeB));
                    }
                    if ( Y < Map.Terrain.TileSize.Y )
                    {
                        if ( X > 0 )
                        {
                            tmpNodeB = GenerateTerrainVertices[X - 1, Y + 1].Node;
                            GenerateTerrainVertices[X, Y].BottomLeftLink = tmpNodeA.GetOrCreateConnection(tmpNodeB, GetNodePosDist(tmpNodeA, tmpNodeB));
                        }
                        tmpNodeB = GenerateTerrainVertices[X, Y + 1].Node;
                        GenerateTerrainVertices[X, Y].BottomLink = tmpNodeA.GetOrCreateConnection(tmpNodeB, GetNodePosDist(tmpNodeA, tmpNodeB));
                        if ( X < Map.Terrain.TileSize.X )
                        {
                            tmpNodeB = GenerateTerrainVertices[X + 1, Y + 1].Node;
                            GenerateTerrainVertices[X, Y].BottomRightLink = tmpNodeA.GetOrCreateConnection(tmpNodeB, GetNodePosDist(tmpNodeA, tmpNodeB));
                        }
                    }
                }
            }

            VertexPathMap.LargeArraysResize();
            VertexPathMap.FindCalc();

            PathfinderLayer BaseLayer = VertexPathMap.get_GetNodeLayer(0);
            PathfinderLayer JitterLayer = VertexPathMap.get_GetNodeLayer(JitterScale);
            A = JitterLayer.GetNodeCount - 1;
            int[] NodeLevel = new int[A + 1];
            clsBaseNodeLevels BaseNodeLevel = new clsBaseNodeLevels();
            BaseNodeLevel.NodeLevels = new float[BaseLayer.GetNodeCount];

            //set position of jitter layer nodes

            Position.XY_dbl XY_dbl = default(Position.XY_dbl);

            if ( A > 0 )
            {
                for ( B = 0; B <= A; B++ )
                {
                    tmpNodeA = JitterLayer.get_GetNode(B);
                    C = 0;
                    XY_dbl.X = 0.0D;
                    XY_dbl.Y = 0.0D;
                    CalcNodePos(tmpNodeA, ref XY_dbl, ref C);
                    NodeTag = new clsNodeTag();
                    NodeTag.Pos.X = (int)(XY_dbl.X / C);
                    NodeTag.Pos.Y = (int)(XY_dbl.Y / C);
                    tmpNodeA.Tag = NodeTag;
                }
            }

            //set node heights

            clsConnection BestConnection = default(clsConnection);
            clsPassageNode BestNode = default(clsPassageNode);

            for ( A = 0; A <= JitterLayer.GetNodeCount - 1; A++ )
            {
                NodeTag = (clsNodeTag)(JitterLayer.get_GetNode(A).Tag);
                NodeLevel[A] = -1;
                BestDist = float.MaxValue;
                BestConnection = null;
                BestNode = null;
                for ( B = 0; B <= ConnectionCount - 1; B++ )
                {
                    //If Not (Connections(B).PassageNodeA.IsOnBorder Or Connections(B).PassageNodeB.IsOnBorder) Then
                    if ( Connections[B].PassageNodeA.Level == Connections[B].PassageNodeB.Level )
                    {
                        //only do this if the levels are the same
                        //this is to make sure nodes that are connected are actually connected on the terrain
                        XY_int = MathUtil.PointGetClosestPosOnLine(Connections[B].PassageNodeA.Pos, Connections[B].PassageNodeB.Pos, NodeTag.Pos);
                        Dist = Convert.ToSingle((XY_int - NodeTag.Pos).ToDoubles().GetMagnitude());
                        if ( Dist < BestDist )
                        {
                            BestDist = Dist;
                            if ( (NodeTag.Pos - Connections[B].PassageNodeA.Pos).ToDoubles().GetMagnitude() <=
                                 (NodeTag.Pos - Connections[B].PassageNodeB.Pos).ToDoubles().GetMagnitude() )
                            {
                                BestNode = Connections[B].PassageNodeA;
                            }
                            else
                            {
                                BestNode = Connections[B].PassageNodeB;
                            }
                            Flag = true;
                        }
                    }
                }
                for ( C = 0; C <= PassageNodeCount - 1; C++ )
                {
                    //If Not PassageNodesA(C).IsOnBorder Then
                    for ( D = 0; D <= SymmetryBlockCount - 1; D++ )
                    {
                        Dist = Convert.ToSingle((NodeTag.Pos - PassageNodes[D, C].Pos).ToDoubles().GetMagnitude());
                        if ( Dist < BestDist )
                        {
                            BestDist = Dist;
                            BestNode = PassageNodes[D, C];
                            Flag = true;
                        }
                    }
                    //End If
                }
                if ( Flag )
                {
                    NodeLevel[A] = BestNode.Level;
                }
                else
                {
                    NodeLevel[A] = BestConnection.PassageNodeA.Level;
                }
                if ( NodeLevel[A] < 0 )
                {
                    ReturnResult.ProblemAdd("Error: Node height is not set.");
                    return ReturnResult;
                }
            }

            for ( A = 0; A <= LevelCount - 1; A++ )
            {
                for ( B = 0; B <= JitterLayer.GetNodeCount - 1; B++ )
                {
                    if ( NodeLevel[B] >= A )
                    {
                        SetBaseLevel(JitterLayer.get_GetNode(B), A, BaseNodeLevel);
                    }
                }
            }

            //make ramp slopes

            int MinRampLength = ((int)(LevelHeight * Map.HeightMultiplier * 2.0D)) + 128;
            clsSetBaseLevelRampArgs RampArgs = new clsSetBaseLevelRampArgs();
            RampArgs.BaseLevel = BaseNodeLevel;
            RampArgs.RampRadius = 320.0F;
            for ( B = 0; B <= ConnectionCount - 1; B++ )
            {
                RampArgs.Connection = Connections[B];
                RampArgs.RampLength =
                    Math.Max(Convert.ToInt32((Connections[B].PassageNodeA.Pos - Connections[B].PassageNodeB.Pos).ToDoubles().GetMagnitude() * 0.75D),
                        MinRampLength * Math.Abs(Connections[B].PassageNodeA.Level - Connections[B].PassageNodeB.Level));
                for ( A = 0; A <= JitterLayer.GetNodeCount - 1; A++ )
                {
                    if ( Connections[B].IsRamp )
                    {
                        NodeTag = (clsNodeTag)(JitterLayer.get_GetNode(A).Tag);
                        XY_int = MathUtil.PointGetClosestPosOnLine(Connections[B].PassageNodeA.Pos, Connections[B].PassageNodeB.Pos, NodeTag.Pos);
                        Dist = Convert.ToSingle((XY_int - NodeTag.Pos).ToDoubles().GetMagnitude());
                        if ( Dist < RampArgs.RampLength * 2.0F )
                        {
                            SetBaseLevelRamp(RampArgs, JitterLayer.get_GetNode(A));
                        }
                    }
                }
            }

            for ( A = 0; A <= BaseLayer.GetNodeCount - 1; A++ )
            {
                NodeTag = (clsNodeTag)(BaseLayer.get_GetNode(A).Tag);
                Map.Terrain.Vertices[(int)(NodeTag.Pos.X / 128.0F), (int)(NodeTag.Pos.Y / 128.0F)].Height = (byte)(BaseNodeLevel.NodeLevels[A] * LevelHeight);
            }

            return ReturnResult;
        }
예제 #29
0
        public clsMap.clsUnit PlaceUnit(clsUnitType Type, App.sWorldPos Pos, clsMap.clsUnitGroup UnitGroup, int Rotation)
        {
            sXY_int TilePosA = new sXY_int();
            sXY_int TilePosB = new sXY_int();
            int X2 = 0;
            int Y2 = 0;
            sXY_int FinalTilePos = new sXY_int();
            sXY_int Footprint = new sXY_int();

            clsMap.clsUnitAdd NewUnitAdd = new clsMap.clsUnitAdd();
            NewUnitAdd.Map = Map;
            NewUnitAdd.StoreChange = true;
            clsMap.clsUnit NewUnit = new clsMap.clsUnit();
            NewUnitAdd.NewUnit = NewUnit;
            NewUnit.Type = Type;
            NewUnit.UnitGroup = UnitGroup;

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

            Footprint = Type.get_GetFootprintSelected(Rotation);

            NewUnit.Pos = Pos;
            TilePosA.X = (int)(Conversion.Int(NewUnit.Pos.Horizontal.X / App.TerrainGridSpacing - Footprint.X / 2.0D + 0.5D));
            TilePosA.Y = (int)(Conversion.Int(NewUnit.Pos.Horizontal.Y / App.TerrainGridSpacing - Footprint.Y / 2.0D + 0.5D));
            TilePosB.X = (int)Conversion.Int(NewUnit.Pos.Horizontal.X / App.TerrainGridSpacing + Footprint.X / 2.0D - 0.5D);
            TilePosB.Y = (int)Conversion.Int(NewUnit.Pos.Horizontal.Y / App.TerrainGridSpacing + Footprint.Y / 2.0D - 0.5D);
            NewUnit.Rotation = Rotation;

            NewUnitAdd.Perform();

            for ( Y2 = Math.Max(TilePosA.Y, 0); Y2 <= Math.Min(TilePosB.Y, Map.Terrain.TileSize.Y - 1); Y2++ )
            {
                for ( X2 = Math.Max(TilePosA.X, 0); X2 <= Math.Min(TilePosB.X, Map.Terrain.TileSize.X - 1); X2++ )
                {
                    TileNodeBlock(X2, Y2);
                }
            }

            TilePathMap.FindCalc();

            return NewUnit;
        }
예제 #30
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();
        }
예제 #31
0
        internal void ShowList()
        {
            if (Type == eList.Msgs)
            {
                txtList.Lines = Msgs;
                return;
            }

            string[]      lines = null;
            clsFileStream fs    = null;

            if (P.F.FSTrackMap != null)
            {
                fs = P.F.FSTrackMap;
            }
            else if (P.F.FileStreamConv != null)
            {
                fs = P.F.FileStreamConv;
            }

            //* get first selected track, or null
            if (Type == eList.Strm)
            {
                clsTrks.T trk = null;
                clsFileStream.clsEvStrm[] strm = P.F.FSTrackMap.Strm;
                if (strm == null)
                {
                    return;
                }
                clsTrks.Array <bool> trkselect = P.F.frmTrackMap?.GetSelectedTrks();
                if (trkselect != null)
                {
                    foreach (clsTrks.T t in trkselect.Next)
                    {
                        if (trkselect[t])
                        {
                            trk = t;
                            break;
                        }
                    }
                }
                Text  = "Show Strm for ";
                Text += (trk == null) ? "all tracks" : "track " + trk.ToString();

                //* display headings
                List <string> list = new List <string>(110);
                string        fmt  = "{0,6} {1,3} {2,6} {3,6} {4}";
                list.Add((string.Format(fmt, "Seq", "Trk", "Ticks", "DITime", "Data")));

                //* show data from CurrentBBT
                int strmpos = clsFileStream.clsPlay.Find(P.F.FSTrackMap, strm, P.F.CurrentBBT.Ticks);
                int cnt     = 0;
                for (int i = strmpos; i < strm.Length; i++)
                {
                    clsFileStream.clsEvStrm s = strm[i];
                    if (trk != null && s.Trk != null && trk != s.Trk)
                    {
                        continue;
                    }
                    string t = (s.Trk == null) ? "*" : s.Trk.ToString();
                    list.Add(String.Format(fmt, i, t, s.Ticks, s.QTime, s.ToString()));
                    if (++cnt > 100)
                    {
                        break;
                    }
                }
                lines = list.ToArray();
            }
            else if (Type == eList.Attributes)
            {
                if (P.F.MTime == null)
                {
                    return;
                }
                Text = "Show Project and System Attributes";
                List <string> lineslist = new List <string>();
                //lineslist.Add("Version = " + P.Version);
                lineslist.Add("64-bit Operating System = " + Environment.Is64BitOperatingSystem);
                lineslist.Add("64-bit Process = " + Environment.Is64BitProcess);
                lineslist.Add("Debug Mode = " + Debugger.IsAttached);
                //#if APPDATAPATH
                //  lineslist.Add("AppDataPath = true");
                //#else
                //  lineslist.Add("AppDataPath = false");
                //#endif
        #if ADVANCED
                lineslist.Add("Advanced = true");
        #else
                lineslist.Add("Advanced = false");
        #endif
                lineslist.Add("TicksPerQuarterNote = " + P.F.MTime.TicksPerQNote);
                lineslist.Add("TicksPerQI = " + P.F.TicksPerQI);
                lineslist.Add("QIPerNote = " + P.F.QIPerNote);
                if (P.F.FSTrackMap?.Text00.Count > 0)
                {
                    lineslist.Add("");
                    lineslist.Add("Initial text events on MidiFile conductor track");
                    lineslist.Add("-----------------------------------------------");
                    foreach (string text in P.F.FSTrackMap?.Text00)
                    {
                        lineslist.Add(text);
                    }
                }
                lines = lineslist.ToArray();
            }
            else if (Type == eList.TSigs)
            {
                if (P.F.MTime?.TSigs == null)
                {
                    return;
                }
                Text = "Show Time Signatures";
                string fmt = "{0,3} {1,2}/{2,-2}";
                //* bar nn / dd
                lines = new string[P.F.MTime.TSigs.Length + 2];
                //lines[0] = "Source: Midi";
                lines[0] = string.Format(fmt, "Bar", "NN", "DD");
                for (int i = 0; i < P.F.MTime.TSigs.Length; i++)
                {
                    clsMTime.clsTSigBB tsig = P.F.MTime.TSigs[i];
                    lines[i + 1] = String.Format(fmt, tsig.Bar + 1, tsig.NN, tsig.DD);
                }
            }
            else if (Type == eList.Keys)
            {
                clsKeysTicks keys = P.F.Keys;
                if (keys == null)
                {
                    return;
                }
                Text = "Show Keys";
                string fmt = "{0,3} {1,4} {2,5} {3,-5}";
                //* bar beat pitch scale
                lines    = new string[keys.Keys.Count + 1];
                lines[0] = string.Format(fmt, "Bar", "Beat", "Pitch", "Scale");
                for (int i = 0; i < keys.Keys.Count; i++)
                {
                    clsKeyTicks key = keys.Keys[i];
                    lines[i + 1] = String.Format(fmt, key.BBT.Bar + 1, key.BBT.BeatsRemBar + 1, key.KeyNoteStr_ToSharpFlat, key.Scale);
                }
            }
            else if (Type == eList.Tempos)
            {
                if (fs == null || fs.TempoMap == null)
                {
                    return;
                }
                Text = "Show Tempos";
                string fmt = "{0,3} {1,4} {2,5} {3,9} {4,10}";
                //* bar beat tempo
                lines    = new string[Math.Max(2, fs.TempoMap.Count + 1)];
                lines[0] = string.Format(fmt, "Bar", "Beat", "Tempo", "MidiTempo", "MSecsPerQI");
                int miditempo, bpm, msecsperqi;
                if (fs.TempoMap.Count == 0)
                {
                    //miditempo = fs.TempoMap[0];  //default
                    miditempo  = fs.TempoMap.GetFirstValue(); //default
                    msecsperqi = (P.F.TicksPerQI * miditempo) / (P.F.MTime.TicksPerQNote * 1000);
                    //msecsperpi = (P.F.TicksPerPI * miditempo) / (P.F.MTime.TicksPerQNote * 1000);
                    int dd = P.F.MTime.GetTSig(0).DD;
                    bpm       = clsAudioSync.DivRound(dd * 60000000, 4 * miditempo);
                    lines[1]  = String.Format(fmt, 1, 1, bpm, miditempo, msecsperqi);
                    lines[1] += " (default)";
                }
                else
                {
                    //for (int i = 0; i < fs.TempoMap.Count; i++) {
                    //  int ticks = fs.TempoMap.KeyByIndex(i);
                    //  miditempo = fs.TempoMap.ValByIndex(i);
                    int linenum = 1;
                    foreach (KeyValuePair <int, int> pair in fs.TempoMap)
                    {
                        int ticks = pair.Key;
                        miditempo = pair.Value;
                        clsMTime.clsBBT bbt = new clsMTime.clsBBT(ticks);
                        msecsperqi = (P.F.TicksPerQI * miditempo) / (P.F.MTime.TicksPerQNote * 1000);
                        int dd = P.F.MTime.GetTSig(ticks).DD;
                        bpm = clsAudioSync.DivRound(dd * 60000000, 4 * miditempo);
                        //lines[i + 1] = String.Format(fmt, bbt.Bar + 1, bbt.BeatsRemBar + 1, bpm, miditempo, msecsperdi);
                        lines[linenum++] = String.Format(fmt, bbt.Bar + 1, bbt.BeatsRemBar + 1, bpm, miditempo, msecsperqi);
                    }
                }
            }
            else if (Type == eList.CtlrTots)
            {
                if (fs == null || fs.MidiCtlrs == null)
                {
                    return;                              //or P.F.MultiMap or P.F.MultiPlay???
                }
                Text = "Show Controller Totals";
                string fmt = "{0,4} {1,4} {2,4} {3,6} {4}";
                //string fmt = "{0,4} {1,4} {2,4} {3,4} {4,6} {5}";
                //* trk port chan ctlr total description
                List <string> l = new List <string>();
                l.Add(string.Format(fmt, " Trk", "Chan", "Ctlr", "Total", "Description"));
                for (int ctlr = 0; ctlr < fs.MidiCtlrs.DataLast.GetLength(0); ctlr++)
                {
                    for (int pc = 0; pc < 16; pc++)
                    {
                        if (fs.MidiCtlrs.DataLast[ctlr, pc] == null)
                        {
                            continue;
                        }
                        int    tot  = fs.MidiCtlrs.DataLast[ctlr, pc].Count;
                        string trk  = "*";
                        string desc = "???";
                        if (ctlr == clsMidiCtlrs.PatchCtlrNum)
                        {
                            desc = "Patch";
                        }
                        else
                        {
                            desc = MidiCtlrList.Desc[ctlr];
                        }
                        l.Add(String.Format(fmt, trk, (pc + 1), ctlr, tot, desc));
                    }
                }
                lines = l.ToArray();
            }
            else if (Type == eList.CtlrDetails)
            {
                if (fs == null || fs.MidiCtlrs == null)
                {
                    return;                              //or P.F.MultiMap or P.F.MultiPlay???
                }
                Text = "Show Controller Details";
                string fmt = "{0,4} {1,4} {2,4} {3,6} {4,9} {5,4} {6}";
                //string fmt = "{0,4} {1,4} {2,4} {3,4} {4,6} {5,9} {6,4} {7}";
                //* trk port chan ctlr ticks value description
                List <string> l = new List <string>();
                l.Add(string.Format(fmt, " Trk", "Chan", "Ctlr", "Ticks", "BBT", " Val", "Description"));
                for (int pc = 0; pc < 16; pc++)
                {
                    string trk = "*";
                    for (int ctlr = 0; ctlr < fs.MidiCtlrs.DataLast.GetLength(0); ctlr++)
                    {
                        string desc = "???";
                        //clsMidiCtlrs.clsMap<int> map = fs.MidiCtlrs.DataLast[ctlr, pc];
                        clsMap <int> map = fs.MidiCtlrs.DataLast[ctlr, pc];
                        if (map == null)
                        {
                            continue;
                        }
                        foreach (KeyValuePair <int, int> pair in map)
                        {
                            int             ticks = pair.Key;
                            clsMTime.clsBBT bbt   = new clsMTime.clsBBT(ticks);
                            int             val   = pair.Value;
                            if (ctlr == clsMidiCtlrs.PatchCtlrNum)
                            {
                                desc = "Patch: " + GeneralMidiList.Desc[val];
                            }
                            else
                            {
                                desc = MidiCtlrList.Desc[ctlr];
                            }
                            l.Add(String.Format(fmt, trk, (pc + 1), ctlr, ticks, bbt.ToString(), val, desc));
                        }
                    }
                }
                lines = l.ToArray();
            }
            else if (Type == eList.Debug)
            {
                Text = "Show Debug Info";
                List <string> l = new List <string>();
                l.Add("Current Ticks = " + P.F.CurrentBBT.Ticks);
                if (P.F != null)
                {
                    if (P.F.MTime != null)
                    {
                        l.Add("P.F.MTime.TicksPerQNote = " + P.F.MTime.TicksPerQNote);
                    }
                    l.Add("P.F.TicksPerDI = " + P.F.TicksPerQI);
                    //l.Add("P.F.TicksPerPI = " + P.F.TicksPerPI);
                    l.Add("P.F.MaxTicks = " + P.F.MaxBBT.Ticks);
                    l.Add("P.F.MaxDITime = " + P.F.MaxBBT.QI);
                    //l.Add("P.F.MaxPITime = " + P.F.MaxPITime);
                }
                lines = l.ToArray();
            }
            else if (Type == eList.ChordList) //standard chords
            {
                Text = "Show Chords";
                string fmt = "{0,-8} {1,-8} {2,-8} {3,-4} {4,-24}";
                lines    = new string[ChordAnalysis.USToTemplate.Values.Count + 1];
                lines[0] = string.Format(fmt, "Name", "Name", "Name", "Rank", "Notes");
                for (int i = 0; i < ChordAnalysis.FileSeqToTemplate.Values.Count; i++)
                {
                    ChordAnalysis.clsTemplate t = ChordAnalysis.FileSeqToTemplate.Values[i];
                    string notes = ""; //root note
                    for (int j = 0; j < 12; j++)
                    {
                        if (t.PC[j])
                        {
                            notes += NoteName.ToSharpFlat(NoteName.GetNoteName(0, 0, j)) + ' ';
                        }
                    }
                    List <string> names = ChordAnalysis.GetSynonyms(t);
                    string        name0 = names[0];
                    string        name1 = (names.Count > 1) ? names[1] : "";
                    string        name2 = (names.Count > 2) ? names[2] : "";
                    lines[i + 1] = String.Format(fmt, name0, name1, name2, t.Rank, notes);
                }
            }
            else
            {
                LogicError.Throw(eLogicError.X048);
                lines = new string[] { "Invalid Show Type" };
            }
            txtList.Lines = lines;
            txtList.Select(0, 0);
        } //method