Ejemplo n.º 1
0
        public static void CreateGeneratorTilesets()
        {
            Generator_TilesetArizona = new clsGeneratorTileset();
            Generator_TilesetArizona.Tileset = App.Tileset_Arizona;
            Generator_TilesetUrban = new clsGeneratorTileset();
            Generator_TilesetUrban.Tileset = App.Tileset_Urban;
            Generator_TilesetRockies = new clsGeneratorTileset();
            Generator_TilesetRockies.Tileset = App.Tileset_Rockies;

            UnitTypeBaseOilResource = GetUnitTypeFromCode("OilResource");
            UnitTypeBaseCommandCentre = GetUnitTypeFromCode("A0CommandCentre");
            UnitTypeBaseTruck = GetUnitTypeFromCode("ConstructionDroid");
            UnitTypeBaseFactory = GetUnitTypeFromCode("A0LightFactory");
            UnitTypeBaseFactoryModule = GetUnitTypeFromCode("A0FacMod1");
            UnitTypeBaseCyborgFactory = GetUnitTypeFromCode("A0CyborgFactory");
            UnitTypeBaseResearchFacility = GetUnitTypeFromCode("A0ResearchFacility");
            UnitTypeBaseResearchModule = GetUnitTypeFromCode("A0ResearchModule1");
            UnitTypeBasePowerGenerator = GetUnitTypeFromCode("A0PowerGenerator");
            UnitTypeBasePowerModule = GetUnitTypeFromCode("A0PowMod1");
            UnitTypeBaseDerrick = GetUnitTypeFromCode("A0ResourceExtractor");
            UnitTypeBaseBoulder1 = GetUnitTypeFromCode("Boulder1");
            UnitTypeBaseBoulder2 = GetUnitTypeFromCode("Boulder2");
            UnitTypeBaseBoulder3 = GetUnitTypeFromCode("Boulder3");
            UnitTypeBaseRuin1 = GetUnitTypeFromCode("Ruin1");
            UnitTypeBaseRuin3 = GetUnitTypeFromCode("Ruin3");
            UnitTypeBaseRuin4 = GetUnitTypeFromCode("Ruin4");
            UnitTypeBaseRuin5 = GetUnitTypeFromCode("Ruin5");
            UnitTypeBase5Trees = GetUnitTypeFromCode("Tree1");
            UnitTypeBase4Trees = GetUnitTypeFromCode("Tree2");
            UnitTypeBase1Tree = GetUnitTypeFromCode("Tree3");
            UnitTypeBase5TreesSnowy = GetUnitTypeFromCode("TreeSnow1");
            UnitTypeBase4TreesSnowy = GetUnitTypeFromCode("TreeSnow2");
            UnitTypeBase1TreeSnowy = GetUnitTypeFromCode("TreeSnow3");
            UnitTypeBaseHighrise1 = GetUnitTypeFromCode("building1");
            UnitTypeBaseHighrise2 = GetUnitTypeFromCode("building2");
            UnitTypeBaseHighrise3 = GetUnitTypeFromCode("building3");
            UnitTypeBaseHalfHighrise = GetUnitTypeFromCode("building11");
            UnitTypeBaseHighriseStump1 = GetUnitTypeFromCode("building7");
            UnitTypeBaseHighriseStump2 = GetUnitTypeFromCode("building8");
            UnitTypeBaseBuildingStump = GetUnitTypeFromCode("WreckedBuilding9");
            UnitTypeBaseSmallBuilding1 = GetUnitTypeFromCode("building10");
            UnitTypeBaseSmallBuilding2 = GetUnitTypeFromCode("building12");
            UnitTypeBaseSmallBuilding3 = GetUnitTypeFromCode("WreckedBuilding17");
            UnitTypeBaseLogCabin1 = GetUnitTypeFromCode("LogCabin1");
            UnitTypeBaseLogCabin2 = GetUnitTypeFromCode("LogCabin2");
            UnitTypeBaseLogCabin3 = GetUnitTypeFromCode("LogCabin3");
            UnitTypeBaseLogCabin4 = GetUnitTypeFromCode("LogCabin4");
            UnitTypeBaseLogCabin5 = GetUnitTypeFromCode("LogCabin5");
            UnitTypeBaseCrane = GetUnitTypeFromCode("Crane");
            UnitTypeBaseOilDrum = GetUnitTypeFromCode("OilDrum");

            Generator_TilesetArizona.ScatteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseBoulder1, 1));
            Generator_TilesetArizona.ScatteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseBoulder2, 1));
            Generator_TilesetArizona.ScatteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseBoulder3, 1));

            Generator_TilesetArizona.ClusteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseRuin1, 1));
            Generator_TilesetArizona.ClusteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseRuin3, 1));
            Generator_TilesetArizona.ClusteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseRuin4, 1));
            Generator_TilesetArizona.ClusteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseRuin5, 1));

            Generator_TilesetUrban.ScatteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseHighrise1, 3));
            Generator_TilesetUrban.ScatteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseHighrise2, 3));
            Generator_TilesetUrban.ScatteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseHighrise3, 3));
            Generator_TilesetUrban.ScatteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseHalfHighrise, 1));
            Generator_TilesetUrban.ScatteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseSmallBuilding1, 3));
            Generator_TilesetUrban.ScatteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseSmallBuilding2, 3));
            Generator_TilesetUrban.ScatteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseSmallBuilding3, 3));
            Generator_TilesetUrban.ScatteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseHighriseStump1, 1));
            Generator_TilesetUrban.ScatteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseHighriseStump2, 1));
            Generator_TilesetUrban.ScatteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseBuildingStump, 1));
            Generator_TilesetUrban.ScatteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseCrane, 2));

            Generator_TilesetRockies.ScatteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBase5Trees, 1));
            Generator_TilesetRockies.ScatteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBase4Trees, 1));
            Generator_TilesetRockies.ScatteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBase1Tree, 2));
            //Tileset_Rockies.ScatteredUnit_Add(New clsWZTileset.sUnitChance(UnitType_5TreesSnowy, 1))
            //Tileset_Rockies.ScatteredUnit_Add(New clsWZTileset.sUnitChance(UnitType_4TreesSnowy, 1))
            //Tileset_Rockies.ScatteredUnit_Add(New clsWZTileset.sUnitChance(UnitType_1TreeSnowy, 2))

            Generator_TilesetRockies.ClusteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseLogCabin1, 3));
            Generator_TilesetRockies.ClusteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseLogCabin2, 1));
            Generator_TilesetRockies.ClusteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseLogCabin3, 1));
            Generator_TilesetRockies.ClusteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseLogCabin4, 1));
            Generator_TilesetRockies.ClusteredUnit_Add(new clsGeneratorTileset.sUnitChance(UnitTypeBaseLogCabin5, 3));

            var Num = 0;

            //terrain arizona

            TerrainStyle_Arizona.LayerCount = 5;

            Num = 0;

            Array.Resize(ref TerrainStyle_Arizona.Layers, Num + 1);

            TerrainStyle_Arizona.Layers[Num] = new sGenerateMasterTerrainArgs.clsLayer();
            TerrainStyle_Arizona.Layers[Num].TileNum = 48; //red
            TerrainStyle_Arizona.Layers[Num].TerrainmapDensity = 1.0F;
            TerrainStyle_Arizona.Layers[Num].TerrainmapScale = 0.0F;
            TerrainStyle_Arizona.Layers[Num].HeightMax = 256.0F;
            TerrainStyle_Arizona.Layers[Num].AvoidLayers = new bool[TerrainStyle_Arizona.LayerCount];
            TerrainStyle_Arizona.Layers[Num].WithinLayer = -1;

            Num++;
            Array.Resize(ref TerrainStyle_Arizona.Layers, Num + 1);

            TerrainStyle_Arizona.Layers[Num] = new sGenerateMasterTerrainArgs.clsLayer();
            TerrainStyle_Arizona.Layers[Num].TileNum = 11; //yellow
            TerrainStyle_Arizona.Layers[Num].TerrainmapDensity = 0.5F;
            TerrainStyle_Arizona.Layers[Num].TerrainmapScale = 2.0F;
            TerrainStyle_Arizona.Layers[Num].HeightMax = 256.0F;
            TerrainStyle_Arizona.Layers[Num].AvoidLayers = new bool[TerrainStyle_Arizona.LayerCount];
            TerrainStyle_Arizona.Layers[Num].WithinLayer = -1;

            Num++;
            Array.Resize(ref TerrainStyle_Arizona.Layers, Num + 1);

            TerrainStyle_Arizona.Layers[Num] = new sGenerateMasterTerrainArgs.clsLayer();
            TerrainStyle_Arizona.Layers[Num].TileNum = 5; //brown
            TerrainStyle_Arizona.Layers[Num].TerrainmapDensity = 0.4F;
            TerrainStyle_Arizona.Layers[Num].TerrainmapScale = 1.5F;
            TerrainStyle_Arizona.Layers[Num].HeightMax = 256.0F;
            TerrainStyle_Arizona.Layers[Num].AvoidLayers = new bool[TerrainStyle_Arizona.LayerCount];
            TerrainStyle_Arizona.Layers[Num].WithinLayer = -1;

            Num++;
            Array.Resize(ref TerrainStyle_Arizona.Layers, Num + 1);

            TerrainStyle_Arizona.Layers[Num] = new sGenerateMasterTerrainArgs.clsLayer();
            TerrainStyle_Arizona.Layers[Num].TileNum = 23; //green
            TerrainStyle_Arizona.Layers[Num].TerrainmapDensity = 0.75F;
            TerrainStyle_Arizona.Layers[Num].TerrainmapScale = 1.5F;
            TerrainStyle_Arizona.Layers[Num].HeightMax = 256.0F;
            TerrainStyle_Arizona.Layers[Num].AvoidLayers = new bool[TerrainStyle_Arizona.LayerCount];
            TerrainStyle_Arizona.Layers[Num].WithinLayer = Num - 1;

            Num++;
            Array.Resize(ref TerrainStyle_Arizona.Layers, Num + 1);

            TerrainStyle_Arizona.Layers[Num] = new sGenerateMasterTerrainArgs.clsLayer();
            TerrainStyle_Arizona.Layers[Num].TileNum = 18; //cliff
            TerrainStyle_Arizona.Layers[Num].TerrainmapDensity = 1.0F;
            TerrainStyle_Arizona.Layers[Num].TerrainmapScale = 0.0F;
            TerrainStyle_Arizona.Layers[Num].HeightMax = 256.0F;
            TerrainStyle_Arizona.Layers[Num].IsCliff = true;
            TerrainStyle_Arizona.Layers[Num].AvoidLayers = new bool[TerrainStyle_Arizona.LayerCount];
            TerrainStyle_Arizona.Layers[Num].WithinLayer = -1;

            TerrainStyle_Arizona.Tileset = Generator_TilesetArizona;

            Generator_TilesetArizona.BorderTextureNum = 18;

            //terrain urban

            TerrainStyle_Urban.LayerCount = 6;

            Num = 0;

            Array.Resize(ref TerrainStyle_Urban.Layers, Num + 1);

            TerrainStyle_Urban.Layers[Num] = new sGenerateMasterTerrainArgs.clsLayer();
            TerrainStyle_Urban.Layers[Num].TileNum = 7;
            TerrainStyle_Urban.Layers[Num].TerrainmapDensity = 1.0F;
            TerrainStyle_Urban.Layers[Num].HeightMax = 256.0F;
            TerrainStyle_Urban.Layers[Num].AvoidLayers = new bool[TerrainStyle_Urban.LayerCount];
            TerrainStyle_Urban.Layers[Num].WithinLayer = -1;

            Num++;
            Array.Resize(ref TerrainStyle_Urban.Layers, Num + 1);

            TerrainStyle_Urban.Layers[Num] = new sGenerateMasterTerrainArgs.clsLayer();
            TerrainStyle_Urban.Layers[Num].TileNum = 0;
            TerrainStyle_Urban.Layers[Num].TerrainmapDensity = 0.5F;
            TerrainStyle_Urban.Layers[Num].TerrainmapScale = 1.5F;
            TerrainStyle_Urban.Layers[Num].HeightMax = 256.0F;
            TerrainStyle_Urban.Layers[Num].AvoidLayers = new bool[TerrainStyle_Urban.LayerCount];
            TerrainStyle_Urban.Layers[Num].WithinLayer = -1;

            Num++;
            Array.Resize(ref TerrainStyle_Urban.Layers, Num + 1);

            TerrainStyle_Urban.Layers[Num] = new sGenerateMasterTerrainArgs.clsLayer();
            TerrainStyle_Urban.Layers[Num].TileNum = 22;
            TerrainStyle_Urban.Layers[Num].TerrainmapDensity = 0.333F;
            TerrainStyle_Urban.Layers[Num].TerrainmapScale = 1.5F;
            TerrainStyle_Urban.Layers[Num].HeightMax = 256.0F;
            TerrainStyle_Urban.Layers[Num].AvoidLayers = new bool[TerrainStyle_Urban.LayerCount];
            TerrainStyle_Urban.Layers[Num].WithinLayer = -1;

            Num++;
            Array.Resize(ref TerrainStyle_Urban.Layers, Num + 1);

            TerrainStyle_Urban.Layers[Num] = new sGenerateMasterTerrainArgs.clsLayer();
            TerrainStyle_Urban.Layers[Num].TileNum = 50;
            TerrainStyle_Urban.Layers[Num].TerrainmapDensity = 0.333F;
            TerrainStyle_Urban.Layers[Num].TerrainmapScale = 1.5F;
            TerrainStyle_Urban.Layers[Num].HeightMax = 256.0F;
            TerrainStyle_Urban.Layers[Num].AvoidLayers = new bool[TerrainStyle_Urban.LayerCount];
            TerrainStyle_Urban.Layers[Num].WithinLayer = -1;

            //Num += 1
            //ReDim Preserve TerrainStyle_Urban.Layers(Num)

            //TerrainStyle_Urban.Layers(Num) = New clsMap.sGenerateMasterTerrainArgs.clsLayer
            //TerrainStyle_Urban.Layers(Num).TileNum = 19
            //TerrainStyle_Urban.Layers(Num).TerrainmapDensity = 0.25F
            //TerrainStyle_Urban.Layers(Num).TerrainmapScale = 1.5F
            //TerrainStyle_Urban.Layers(Num).HeightMax = 256.0F
            //ReDim TerrainStyle_Urban.Layers(Num).AvoidLayers(TerrainStyle_Urban.LayerCount - 1)
            //TerrainStyle_Urban.Layers(Num).WithinLayer = -1

            Num++;
            Array.Resize(ref TerrainStyle_Urban.Layers, Num + 1);

            TerrainStyle_Urban.Layers[Num] = new sGenerateMasterTerrainArgs.clsLayer();
            TerrainStyle_Urban.Layers[Num].TileNum = 51;
            TerrainStyle_Urban.Layers[Num].TerrainmapDensity = 0.4F;
            TerrainStyle_Urban.Layers[Num].TerrainmapScale = 1.5F;
            TerrainStyle_Urban.Layers[Num].HeightMax = 256.0F;
            TerrainStyle_Urban.Layers[Num].AvoidLayers = new bool[TerrainStyle_Urban.LayerCount];
            TerrainStyle_Urban.Layers[Num].WithinLayer = -1;

            Num++;
            Array.Resize(ref TerrainStyle_Urban.Layers, Num + 1);

            TerrainStyle_Urban.Layers[Num] = new sGenerateMasterTerrainArgs.clsLayer();
            TerrainStyle_Urban.Layers[Num].TileNum = 70;
            TerrainStyle_Urban.Layers[Num].TerrainmapDensity = 1.0F;
            TerrainStyle_Urban.Layers[Num].TerrainmapScale = 0.0F;
            TerrainStyle_Urban.Layers[Num].HeightMax = 256.0F;
            TerrainStyle_Urban.Layers[Num].IsCliff = true;
            TerrainStyle_Urban.Layers[Num].AvoidLayers = new bool[TerrainStyle_Urban.LayerCount];
            TerrainStyle_Urban.Layers[Num].WithinLayer = -1;

            TerrainStyle_Urban.Tileset = Generator_TilesetUrban;

            Generator_TilesetUrban.BorderTextureNum = 70;

            //terrain rockies

            TerrainStyle_Rockies.LayerCount = 7;

            Num = 0;

            Array.Resize(ref TerrainStyle_Rockies.Layers, Num + 1);

            TerrainStyle_Rockies.Layers[Num] = new sGenerateMasterTerrainArgs.clsLayer();
            TerrainStyle_Rockies.Layers[Num].TileNum = 0; //green
            TerrainStyle_Rockies.Layers[Num].TerrainmapDensity = 1.0F;
            TerrainStyle_Rockies.Layers[Num].TerrainmapScale = 0.0F;
            TerrainStyle_Rockies.Layers[Num].HeightMax = 256.0F;
            TerrainStyle_Rockies.Layers[Num].AvoidLayers = new bool[TerrainStyle_Rockies.LayerCount];
            TerrainStyle_Rockies.Layers[Num].WithinLayer = -1;

            Num++;
            Array.Resize(ref TerrainStyle_Rockies.Layers, Num + 1);

            TerrainStyle_Rockies.Layers[Num] = new sGenerateMasterTerrainArgs.clsLayer();
            TerrainStyle_Rockies.Layers[Num].TileNum = 53; //brown
            TerrainStyle_Rockies.Layers[Num].TerrainmapDensity = 0.4F;
            TerrainStyle_Rockies.Layers[Num].TerrainmapScale = 1.5F;
            TerrainStyle_Rockies.Layers[Num].HeightMax = 256.0F;
            TerrainStyle_Rockies.Layers[Num].AvoidLayers = new bool[TerrainStyle_Rockies.LayerCount];
            TerrainStyle_Rockies.Layers[Num].WithinLayer = -1;

            Num++;
            Array.Resize(ref TerrainStyle_Rockies.Layers, Num + 1);

            TerrainStyle_Rockies.Layers[Num] = new sGenerateMasterTerrainArgs.clsLayer();
            TerrainStyle_Rockies.Layers[Num].TileNum = 23; //green & snow
            TerrainStyle_Rockies.Layers[Num].TerrainmapDensity = 0.333F;
            TerrainStyle_Rockies.Layers[Num].TerrainmapScale = 1.5F;
            TerrainStyle_Rockies.Layers[Num].HeightMin = 85.0F;
            TerrainStyle_Rockies.Layers[Num].HeightMax = 256.0F;
            TerrainStyle_Rockies.Layers[Num].AvoidLayers = new bool[TerrainStyle_Rockies.LayerCount];
            TerrainStyle_Rockies.Layers[Num].WithinLayer = -1;

            Num++;
            Array.Resize(ref TerrainStyle_Rockies.Layers, Num + 1);

            TerrainStyle_Rockies.Layers[Num] = new sGenerateMasterTerrainArgs.clsLayer();
            TerrainStyle_Rockies.Layers[Num].TileNum = 64; //snow
            TerrainStyle_Rockies.Layers[Num].TerrainmapDensity = 0.5F;
            TerrainStyle_Rockies.Layers[Num].TerrainmapScale = 1.0F;
            TerrainStyle_Rockies.Layers[Num].HeightMin = 85.0F;
            TerrainStyle_Rockies.Layers[Num].HeightMax = 256.0F;
            TerrainStyle_Rockies.Layers[Num].AvoidLayers = new bool[TerrainStyle_Rockies.LayerCount];
            TerrainStyle_Rockies.Layers[Num].WithinLayer = Num - 1;

            Num++;
            Array.Resize(ref TerrainStyle_Rockies.Layers, Num + 1);

            TerrainStyle_Rockies.Layers[Num] = new sGenerateMasterTerrainArgs.clsLayer();
            TerrainStyle_Rockies.Layers[Num].TileNum = 41; //brown & snow
            TerrainStyle_Rockies.Layers[Num].TerrainmapDensity = 1.0F;
            TerrainStyle_Rockies.Layers[Num].TerrainmapScale = 0.0F;
            TerrainStyle_Rockies.Layers[Num].HeightMin = 170.0F;
            TerrainStyle_Rockies.Layers[Num].HeightMax = 256.0F;
            TerrainStyle_Rockies.Layers[Num].AvoidLayers = new bool[TerrainStyle_Rockies.LayerCount];
            TerrainStyle_Rockies.Layers[Num].WithinLayer = -1;

            Num++;
            Array.Resize(ref TerrainStyle_Rockies.Layers, Num + 1);

            TerrainStyle_Rockies.Layers[Num] = new sGenerateMasterTerrainArgs.clsLayer();
            TerrainStyle_Rockies.Layers[Num].TileNum = 64; //snow
            TerrainStyle_Rockies.Layers[Num].TerrainmapDensity = 0.875F;
            TerrainStyle_Rockies.Layers[Num].TerrainmapScale = 1.0F;
            TerrainStyle_Rockies.Layers[Num].HeightMin = 170.0F;
            TerrainStyle_Rockies.Layers[Num].HeightMax = 256.0F;
            TerrainStyle_Rockies.Layers[Num].AvoidLayers = new bool[TerrainStyle_Rockies.LayerCount];
            TerrainStyle_Rockies.Layers[Num].WithinLayer = Num - 1;

            Num++;
            Array.Resize(ref TerrainStyle_Rockies.Layers, Num + 1);

            TerrainStyle_Rockies.Layers[Num] = new sGenerateMasterTerrainArgs.clsLayer();
            TerrainStyle_Rockies.Layers[Num].TileNum = 30; //cliff
            TerrainStyle_Rockies.Layers[Num].TerrainmapDensity = 1.0F;
            TerrainStyle_Rockies.Layers[Num].TerrainmapScale = 0.0F;
            TerrainStyle_Rockies.Layers[Num].HeightMax = 256.0F;
            TerrainStyle_Rockies.Layers[Num].IsCliff = true;
            TerrainStyle_Rockies.Layers[Num].AvoidLayers = new bool[TerrainStyle_Rockies.LayerCount];
            TerrainStyle_Rockies.Layers[Num].WithinLayer = -1;

            TerrainStyle_Rockies.Tileset = Generator_TilesetRockies;

            Generator_TilesetRockies.BorderTextureNum = 30;
        }
Ejemplo n.º 2
0
        public clsUnit PlaceUnit(UnitTypeBase TypeBase, WorldPos Pos, clsUnitGroup UnitGroup, int Rotation)
        {
            var TilePosA = new XYInt();
            var TilePosB = new XYInt();
            var X2 = 0;
            var Y2 = 0;
            var FinalTilePos = new XYInt();
            var Footprint = new XYInt();

            var NewUnitAdd = new clsUnitAdd();
            NewUnitAdd.Map = Map;
            NewUnitAdd.StoreChange = true;
            var NewUnit = new clsUnit();
            NewUnitAdd.NewUnit = NewUnit;
            NewUnit.TypeBase = TypeBase;
            NewUnit.UnitGroup = UnitGroup;

            FinalTilePos.X = Pos.Horizontal.X / Constants.TerrainGridSpacing;
            FinalTilePos.Y = Pos.Horizontal.Y / Constants.TerrainGridSpacing;

            Footprint = TypeBase.get_GetFootprintSelected(Rotation);

            NewUnit.Pos = Pos;
            TilePosA.X = (int)(((double)NewUnit.Pos.Horizontal.X / Constants.TerrainGridSpacing - Footprint.X / 2.0D + 0.5D));
            TilePosA.Y = (int)(((double)NewUnit.Pos.Horizontal.Y / Constants.TerrainGridSpacing - Footprint.Y / 2.0D + 0.5D));
            TilePosB.X = (int)((double)NewUnit.Pos.Horizontal.X / Constants.TerrainGridSpacing + Footprint.X / 2.0D - 0.5D);
            TilePosB.Y = (int)((double)NewUnit.Pos.Horizontal.Y / Constants.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;
        }
Ejemplo n.º 3
0
        public clsUnit PlaceUnitNear(UnitTypeBase TypeBase, XYInt Pos, clsUnitGroup UnitGroup, int Clearance, int Rotation, int MaxDistFromPos)
        {
            var PosNode = default(PathfinderNode);
            var NodeTag = default(clsNodeTag);
            var FinalTilePos = new XYInt();
            var TilePosA = new XYInt();
            var TilePosB = new XYInt();
            var X2 = 0;
            var Y2 = 0;
            var Remainder = 0;
            var Footprint = new XYInt();

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

                    FinalTilePos.X = NodeTag.Pos.X / Constants.TerrainGridSpacing;
                    FinalTilePos.Y = (NodeTag.Pos.Y / Constants.TerrainGridSpacing);
                    Footprint = TypeBase.get_GetFootprintSelected(Rotation);
                    Remainder = Footprint.X % 2;
                    if ( Remainder > 0 )
                    {
                        NewUnit.Pos.Horizontal.X = NodeTag.Pos.X;
                    }
                    else
                    {
                        if ( App.Random.Next() >= 0.5F )
                        {
                            NewUnit.Pos.Horizontal.X = (int)(NodeTag.Pos.X - Constants.TerrainGridSpacing / 2.0D);
                        }
                        else
                        {
                            NewUnit.Pos.Horizontal.X = (int)(NodeTag.Pos.X + Constants.TerrainGridSpacing / 2.0D);
                        }
                    }
                    Remainder = Footprint.Y % 2;
                    if ( Remainder > 0 )
                    {
                        NewUnit.Pos.Horizontal.Y = NodeTag.Pos.Y;
                    }
                    else
                    {
                        if ( App.Random.Next() >= 0.5F )
                        {
                            NewUnit.Pos.Horizontal.Y = (int)(NodeTag.Pos.Y - Constants.TerrainGridSpacing / 2.0D);
                        }
                        else
                        {
                            NewUnit.Pos.Horizontal.Y = (int)(NodeTag.Pos.Y + Constants.TerrainGridSpacing / 2.0D);
                        }
                    }
                    TilePosA.X = (int)((double)NewUnit.Pos.Horizontal.X / Constants.TerrainGridSpacing - Footprint.X / 2.0D + 0.5D);
                    TilePosA.Y = (int)((double)NewUnit.Pos.Horizontal.Y / Constants.TerrainGridSpacing - Footprint.Y / 2.0D + 0.5D);
                    TilePosB.X = (int)(((double)NewUnit.Pos.Horizontal.X / Constants.TerrainGridSpacing + Footprint.X / 2.0D - 0.5D));
                    TilePosB.Y = (int)(((double)NewUnit.Pos.Horizontal.Y / Constants.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;
                }
                return null;
            }
            return null;
        }
Ejemplo n.º 4
0
 public sUnitChance(UnitTypeBase TypeBase, UInt32 Chance)
 {
     this.TypeBase = TypeBase;
     this.Chance = Chance;
 }