Ejemplo n.º 1
0
        public bool GetMapPreview(string Mapname, out Texture2D preview)
        {
            preview = new Texture2D(1, 1);
            if (!isReady || Mapname == "")
            {
                return(false);
            }

            var mapPreviewPath = Path.Combine(MapFitPath, Mapname + ".tga").ToUpper();
            var fileData       = MechCommanderUnity.Instance.FileManager.File(mapPreviewPath);

            if (fileData != null)
            {
                MechCommanderUnity.LogMessage("TGA file " + mapPreviewPath);
                preview = TGALoader.LoadTGA(new MemoryStream(fileData));
                return(true);
            }
            else
            {
                var missionFile = new FITFile(MechCommanderUnity.Instance.FileManager.File(MCGExtensions.PathCombine(new string[] { "missions", Mapname + ".fit" })));
                missionFile.SeekSection("TerrainSystem");
                missionFile.GetString("TerrainFileName", out string terrainFileName);
                mapPreviewPath = Path.Combine(MapFitPath, terrainFileName + ".tga").ToUpper();
                fileData       = MechCommanderUnity.Instance.FileManager.File(mapPreviewPath);
                if (fileData != null)
                {
                    MechCommanderUnity.LogMessage("TGA file DIFFERENT NAME " + mapPreviewPath);
                    preview = TGALoader.LoadTGA(new MemoryStream(fileData));
                    return(true);
                }
            }

            MechCommanderUnity.LogMessage("Can´t Find TGA file " + mapPreviewPath);
            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Read file.
        /// </summary>
        /// <returns>True if succeeded, otherwise false.</returns>
        private bool Read()
        {
            try
            {
                // Step through file
                BinaryReader Reader = managedFile.GetReader();

                height = Reader.ReadInt32();
                width  = Reader.ReadInt32();


                planet = Reader.ReadInt32();

                auxlst = new List <byte[]>();

                for (int i = 0; i < width; i++)
                {
                    for (int z = 0; z < height; z++)
                    {
                        //var id1 = Reader.ReadInt32();
                        //var id2 = Reader.ReadInt32();

                        //Objs.Add(new MCDatObj(id1, id2));

                        auxlst.Add(Reader.ReadBytes(8));
                    }
                }
            } catch (Exception e)
            {
                MechCommanderUnity.LogMessage(e.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Read file.
        /// </summary>
        /// <returns>True if succeeded, otherwise false.</returns>
        private bool Read()
        {
            try
            {
                for (int i = 0; i < elvPakFile.PakInnerFileCount; i++)
                {
                    var elvdata = elvPakFile.GetFileInner(i);

                    for (int x = 0; x < (VerticesBlockSide * VerticesBlockSide); x++)
                    {
                        //  var tile = elvdata.Read<MCTile>();
                        var tile = new MCTile();
                        tile.Elevation   = elvdata[(x * 8) + 0];
                        tile.Mask        = elvdata[(x * 8) + 1];
                        tile.Byte2       = elvdata[(x * 8) + 2];
                        tile.Byte3       = elvdata[(x * 8) + 3];
                        tile.Terrain     = BitConverter.ToUInt16(elvdata, (x * 8) + 4);
                        tile.OverlayTile = BitConverter.ToInt16(elvdata, (x * 8) + 6);


                        Vertice[(i * VerticesBlockSide * VerticesBlockSide) + x] = tile;
                    }

                    //if (!ReadMapBlock(elvdata))
                    //    return false;
                }
            }
            catch (Exception e)
            {
                MechCommanderUnity.LogMessage(e.Message + " " + e.InnerException);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Read file.
        /// </summary>
        /// <returns>True if succeeded, otherwise false.</returns>
        private bool Read()
        {
            try
            {
                for (int i = 0; i < objPakFile.PakInnerFileCount; i++)
                {
                    var objdata = objPakFile.GetFileInner(i);

                    if (objdata == null || objdata.Length == 0)
                    {
                        continue;
                    }

                    for (int x = 0; x < (objdata.Length / 11); x++)
                    {
                        var obj = objdata.Skip((x * 11)).ToArray().Read <MCObj>();

                        Objs.Add(obj);
                    }
                }
            }
            catch (Exception e)
            {
                MechCommanderUnity.LogMessage(e.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 5
0
 public int GetFirstValidIndex()
 {
     for (int i = 0; i < SkipFlags.Count(); i++)
     {
         if (SkipFlags[i] == 0)
         {
             return(i);
         }
     }
     MechCommanderUnity.LogMessage("no Valid First Index");
     return(-1);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Read file.
        /// </summary>
        /// <returns>True if succeeded, otherwise false.</returns>
        private bool Read()
        {
            try
            {
                // Step through file
                BinaryReader Reader = managedFile.GetReader();

                while (Reader.BaseStream.Position != Reader.BaseStream.Length)
                {
                    LstTileIndex.Add(Reader.ReadInt32());
                }
            }
            catch (Exception e)
            {
                MechCommanderUnity.LogMessage(e.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 7
0
        public bool GetFitSprite(int ObjIndex, out FITFile fitFile)
        {
            fitFile = new FITFile();

            if (!isReady)
            {
                return(false);
            }

            // Get block data

            var data = spritesPakFile.GetFileInner(ObjIndex);


            if (data == null)
            {
                MechCommanderUnity.LogMessage(string.Format("Unknown FITFILE SPRITE.PAK '{0}'.", ObjIndex), true);
                return(false);
            }

            fitFile = new FITFile(data);

            return(true);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Read file.
        /// </summary>
        /// <returns>True if succeeded, otherwise false.</returns>
        private bool Read()
        {
            try
            {
                BinaryReader Reader = managedFile.GetReader();

                int Firma = Reader.ReadInt32();

                if (Firma != 140649)
                {
                    return(false);
                }
                Reader.ReadInt32(); //vacio1
                Reader.ReadInt32(); //vacio2

                int width  = Reader.ReadInt32();
                int heigth = Reader.ReadInt32();

                int sectorDim    = Reader.ReadInt32();
                int sectorHeight = Reader.ReadInt32();
                int sectorWidth  = Reader.ReadInt32();

                int numAreas     = Reader.ReadInt32();
                int numDoors     = Reader.ReadInt32();
                int numDoorInfos = Reader.ReadInt32();
                int numDoorLinks = Reader.ReadInt32();

                int LargeArea = numAreas > 256 ? 2 : 1;

                var AreaMap = new sbyte[LargeArea * width * heigth]; //Reader.ReadBytes(LargeArea * width * heigth);

                for (int i = 0; i < (LargeArea * width * heigth) / 4; i++)
                {
                    AreaMap[i] = Reader.ReadSByte();
                    // var id1 = Reader.ReadInt16();
                    // var id2 = Reader.ReadInt32();

                    // Objs.Add(new MCAreaObj(id1));
                }

                for (int i = 0; i < numDoorInfos; i++)
                {
                    var DoorIndex = Reader.ReadInt16();
                    var DoorSide  = Reader.ReadByte();


                    ObjsDoorInfo.Add(new MCDoorInfoObj(DoorIndex, DoorSide));
                }

                for (int i = 0; i < numAreas; i++)
                {
                }


                var st = 2;
            } catch (Exception e)
            {
                MechCommanderUnity.LogMessage(e.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 9
0
        public void AddObject(int objTypeNum)
        {
            if (PalTexture == null)
            {
                PalTexture = MechCommanderUnity.Instance.ContentReader.ShapesPakFile.Palette.ExportPaletteTexture();
            }

            MapObjFile.MCObj objData = new MapObjFile.MCObj()
            {
                Block        = 0,
                damage       = 0,
                ObjId        = (short)objTypeNum,
                pixelOffsetX = 0,
                pixelOffsetY = 0,
                Vertex       = 0
            };


            var objtype = objTypeManager.Get(objData.ObjId);

            var realDmg = objData.damage & 0x0f;

            MCGameObject obj;

            switch (objtype.objectClass)
            {
            case ObjectClass.TERRAINOBJECT:
            case ObjectClass.TREE:
                var terrainGo = new GameObject();
                obj = terrainGo.AddComponent <TerrainObject>();
                ((TerrainObject)obj).Init(objtype, appearanceTypeManager);

                //obj = new TerrainObject(objtype, appearanceTypeManager);

                obj.block        = objData.Block;
                obj.vertex       = objData.Vertex;
                obj.OffsetPixelX = objData.pixelOffsetX;
                obj.OffsetPixelY = objData.pixelOffsetY;
                obj.position     = terrain.MapPositionToWorldCoords(obj.block, obj.vertex, obj.OffsetPixelX, obj.OffsetPixelY);

                //if (realDmg>0)
                //((TerrainObjectPtr)obj)->setDamage(((TerrainObjectTypePtr)objType)->getDamageLevel());

                //objList[curCollidableHandle] = obj;
                //obj->setHandle(curCollidableHandle++);

                //obj->setExists(true);
                //appearanceTypeManager.GetAppearanceType(objtype.Appearance);

                terrainObjects.Add(terrainGo);
                break;

            case ObjectClass.TURRET:
                MechCommanderUnity.LogMessage("Creating Turret!!");
                var turretGo = new GameObject();
                obj = turretGo.AddComponent <TurretObject>();
                ((TurretObject)obj).Init(objtype, appearanceTypeManager);
                // obj = new TurretObject(objtype, appearanceTypeManager);
                obj.block        = objData.Block;
                obj.vertex       = objData.Vertex;
                obj.OffsetPixelX = objData.pixelOffsetX;
                obj.OffsetPixelY = objData.pixelOffsetY;
                obj.position     = terrain.MapPositionToWorldCoords(obj.block, obj.vertex, obj.OffsetPixelX, obj.OffsetPixelY);

                //obj = getTurret(curTurretIndex++);
                //if (obj)
                //{
                //    ((TurretPtr)obj)->init(true, objType);
                //    if (realDmg)
                //        obj->setDamage(((TurretTypePtr)objType)->getDamageLevel());

                //    objList[curCollidableHandle] = obj;
                //    obj->setHandle(curCollidableHandle++);
                //    obj->setExists(true);
                //    obj->setParentId(objData->parentId);
                //    obj->setTeamId(objData->teamId, true);
                //}

                turrets.Add(turretGo);

                break;

            case ObjectClass.BUILDING:
            case ObjectClass.TREEBUILDING:
                var buildGo = new GameObject();
                obj = buildGo.AddComponent <BuildingObject>();
                ((BuildingObject)obj).Init(objtype, appearanceTypeManager);
                //obj = new BuildingObject(objtype, appearanceTypeManager);
                obj.block        = objData.Block;
                obj.vertex       = objData.Vertex;
                obj.OffsetPixelX = objData.pixelOffsetX;
                obj.OffsetPixelY = objData.pixelOffsetY;
                obj.position     = terrain.MapPositionToWorldCoords(obj.block, obj.vertex, obj.OffsetPixelX, obj.OffsetPixelY);

                //appearanceTypeManager.GetAppearanceType(objtype.Appearance);

                //if (realDmg>0)
                //    obj->setDamage(((BuildingTypePtr)objType)->getDamageLevel());
                //((BuildingPtr)obj)->baseTileId = (objData->damage >> 4);
                //if (obj->isSpecialBuilding())
                //{
                //    objList[curCollidableHandle] = obj;
                //    obj->setHandle(curCollidableHandle++);
                //} else
                //{
                //    objList[curNonCollidableHandle] = obj;
                //    obj->setHandle(curNonCollidableHandle++);
                //}

                //obj->setExists(true);
                //obj->setParentId(objData->parentId);
                //obj->setTeamId(objData->teamId, true);

                buildings.Add(buildGo);

                break;

            default:
                Debug.Log("Loading Unknow TypeOBj: " + objtype.objectClass);
                break;
            }
        }
Ejemplo n.º 10
0
        public IEnumerator Init(Func <IEnumerator> OnFinish)
        {
            if (this.IsCached())
            {
                yield return(OnFinish());
            }
            else
            {
                PakFile pak;

                if (TerrainTileFile.ToUpper() == "Tiles".ToUpper())
                {
                    pak = new PakFile(Path.Combine(MechCommanderUnity.Instance.MCGPath, "TILES/TILES90.PAK"),
                                      MechCommanderUnity.Instance.FileManager.File(palettePath));
                }
                else if (TerrainTileFile.ToUpper() == "GTiles".ToUpper())
                {
                    pak = new PakFile(Path.Combine(MechCommanderUnity.Instance.MCGPath, "TILES/GTILES90.PAK"),
                                      MechCommanderUnity.Instance.FileManager.File(GpalettePath));
                }
                else
                {
                    throw (new Exception());
                }

                this.LstTiles   = new Dictionary <int, MCBitmap>();
                this.LstTilesOV = new Dictionary <int, MCBitmap>();

                for (int i = 0; i < LstTileIndexes.Count; i++)
                {
                    var tiledata = pak.GetFileInner(LstTileIndexes[i]);

                    if (tiledata == null)
                    {
                        continue;
                    }

                    MCBitmap bitmap;
                    if (tiledata[0] != 68 && tiledata[1] != 78)
                    {
                        var tile = new MCTileFile(tiledata);
                        bitmap = tile.GetBitMap();
                        if (bitmap == null)
                        {
                            continue;
                        }
                        bitmap.Name = LstTileIndexes[i].ToString();//this.TerrainTileFile.ToUpper() + "-" +

                        LstTiles.Add(LstTileIndexes[i], bitmap);
                    }
                    else
                    {
                        var tile = new MCTileFileOverlay(tiledata);
                        bitmap = tile.GetBitMap();
                        if (bitmap == null)
                        {
                            continue;
                        }

                        bitmap.Name = LstTileIndexes[i].ToString();//this.TerrainTileFile.ToUpper() + "-" +

                        LstTilesOV.Add(LstTileIndexes[i], bitmap);
                    }
                    // lstText.Add(ImageProcessing.MakeTexture2D(ref bitmap, pak.Palette));
                }

                yield return(null);

                MCBitmap atlas;
                MCBitmap atlasOV;

                Dictionary <string, Rect> DictRects;
                Dictionary <string, Rect> DictRectsOV;

                MechCommanderUnity.LogMessage("Starting Terrain Atlas Generation after Tiles");
                //            try
                //            {
                var result = ImageProcessing.CreateAtlas(LstTiles.Values.ToArray(), out atlas, out DictRects);

                yield return(null);

                this.CacheMap(atlas);

                DictTileInfo = new Dictionary <string, TileInfo>();
                foreach (var rect in DictRects)
                {
                    var bitmap = LstTiles[int.Parse(rect.Key)];
                    DictTileInfo.Add(rect.Key, new TileInfo()
                    {
                        rect  = rect.Value,
                        pivot = bitmap.Pivot     //new Vector2((float)((double)bitmap.PivotX / bitmap.Width), 1f - (float)((double)bitmap.PivotY / bitmap.Height))
                    });
                }

                this.CacheTileInfo(DictTileInfo);

                if (result)
                {
                    MainText = ImageProcessing.MakeIndexedTexture2D(atlas);
                    PalText  = pak.Palette.ExportPaletteTexture();

                    atlas.Dispose();
                }
                else
                {
                    MechCommanderUnity.LogMessage("Error Packing file " + result);
                }

                var resultOv = ImageProcessing.CreateAtlas(LstTilesOV.Values.ToArray(), out atlasOV, out DictRectsOV);

                yield return(null);

                this.CacheMap(atlasOV, "OV");

                DictTileOVInfo = new Dictionary <string, TileInfo>();
                foreach (var rect in DictRectsOV)
                {
                    var bitmap = LstTilesOV[int.Parse(rect.Key)];
                    DictTileOVInfo.Add(rect.Key, new TileInfo()
                    {
                        rect  = rect.Value,
                        pivot = bitmap.Pivot
                    });
                }

                this.CacheTileInfo(DictTileOVInfo, "OV");

                if (resultOv)
                {
                    MainOVText = ImageProcessing.MakeIndexedTexture2D(atlasOV);
                    atlasOV.Dispose();
                }
                else
                {
                    MechCommanderUnity.LogMessage("Error Packing file " + resultOv);
                }
                //            } catch (Exception e)
                //            {
                //                MechCommanderUnity.LogMessage("Error Packing file " + e.Message);
                //                // throw;
                //            }


                foreach (var tile in LstTiles)
                {
                    tile.Value.Dispose();
                }

                foreach (var tile in LstTilesOV)
                {
                    tile.Value.Dispose();
                }


                MechCommanderUnity.LogMessage("Finish Init Terrain");

                yield return(OnFinish());
            }
        }
Ejemplo n.º 11
0
        public bool GetShapes(int ObjIndex, out List <MCBitmap> lstImgs, List <int> shpIds)
        {
            lstImgs = new List <MCBitmap>();

            if (!isReady)
            {
                return(false);
            }

            // Get block data

            var maxShp = shapesPakFile.PakInnerFileCount;

            bool result = false;

            PakFile pak = null;

            try
            {
                if (!shapePakFiles.ContainsKey(ObjIndex))
                {
                    var pakData = shapesPakFile.GetFileInner(ObjIndex);

                    if (pakData == null)
                    {
                        pakData = shapes90PakFile.GetFileInner(ObjIndex);
                    }
                    if (pakData != null)
                    {
                        pak = new PakFile(pakData);
                        shapePakFiles.Add(ObjIndex, pak);
                    }
                }
                else
                {
                    pak = shapePakFiles[ObjIndex];
                }


                if (pak != null)
                {
                    foreach (var innerShp in shpIds)
                    {
                        var shpdata = pak.GetFileInner(innerShp);

                        if (shpdata != null)
                        {
                            result = true;
                            var shp = new ShpFile(shpdata);

                            var lstBmps = shp.GetBitMaps();
                            for (int i = 0; i < lstBmps.Length; i++)
                            {
                                if (lstBmps[i] == null)
                                {
                                    continue;
                                    Debug.Log("BMP Vacio exportando: " + ObjIndex + " - " + innerShp + " : " + i);
                                    lstBmps[i] = new MCBitmap(1, 1);
                                }
                                lstBmps[i].Name = innerShp + "-" + i;
                            }
                            lstImgs.AddRange(lstBmps.Where(x => x != null).ToArray());
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }

            if (!result)
            {
                MechCommanderUnity.LogMessage(string.Format("Unknown Shape '{0}' '{1}' t:{2}.", ObjIndex, string.Join(",", shpIds.Select(x => x.ToString()).ToArray()), pak.PakInnerFileCount), true);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 12
0
        public bool GetShape(int ObjIndex, out List <MCBitmap> lstImgs, int innerShp = -1, int indexImg = -1)
        {
            lstImgs = new List <MCBitmap>();

            if (!isReady)
            {
                return(false);
            }

            // Get block data

            var maxShp = shapesPakFile.PakInnerFileCount;

            bool result = false;

            PakFile pak = null;

            if (!shapePakFiles.ContainsKey(ObjIndex))
            {
                var pakData = shapesPakFile.GetFileInner(ObjIndex);

                if (pakData == null)
                {
                    pakData = shapes90PakFile.GetFileInner(ObjIndex);
                }
                if (pakData != null)
                {
                    pak = new PakFile(pakData);
                    shapePakFiles.Add(ObjIndex, pak);
                }
            }
            else
            {
                pak = shapePakFiles[ObjIndex];
            }


            if (pak != null)
            {
                var shpdata = pak.GetFileInner(innerShp);

                Debug.Log("SHP: " + ObjIndex + " - " + innerShp);

                if (shpdata != null)
                {
                    result = true;

                    var shp = new ShpFile(shpdata);

                    if (indexImg > -1)
                    {
                        lstImgs.Add(shp.GetBitMap(indexImg));
                    }
                    else
                    {
                        lstImgs.AddRange(shp.GetBitMaps());
                    }
                }
            }

            if (!result)
            {
                MechCommanderUnity.LogMessage(string.Format("Unknown Shape '{0}' '{1}' '{2}'.", ObjIndex, innerShp, indexImg), true);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 13
0
        public void Init(string missionName, MissionLoadType loadType)
        //public Mission(string missionName, MissionLoadType loadType)
        {
            this.Init();
            float loadProgress = 0f;

            MechCommanderUnity.LogMessage("Loading Mission: " + missionName);

            var auxStr = "";


            //LoadType mission SP (quick or logistic) and MP
            //define team relations

            loadProgress = 4.0f;

            //--------------------------
            // Load Game System stuff...
            //Define General Game Settings

            var generalFitFile = new FITFile(MechCommanderUnity.Instance.FileManager.File(MCGExtensions.PathCombine(new string[] { "missions", "gamesys.fit" })));

            if (generalFitFile.SectionNumber == 0)
            {
                MechCommanderUnity.LogMessage("Error Loading General FitFile :" + MCGExtensions.PathCombine(new string[] { MechCommanderUnity.Instance.MCGPath, "missions", "gamesys.fit" }));
                return;
            }

            //----------------------------------------------------------------------
            // Now that we have some base values, load the master component table...



            //---------------------------------------
            // Read in difficulty here if it exits.
            //InitDifficultySettings(gameSystemFile);


            //---------------------------------------
            // Read Mission File
            missionFileName = Path.ChangeExtension(missionName, "fit");

            //Read Mission Fit File
            missionFile = new FITFile(MechCommanderUnity.Instance.FileManager.File(MCGExtensions.PathCombine(new string[] { "missions", missionFileName })));
            if (missionFile.SectionNumber == 0)
            {
                MechCommanderUnity.LogMessage("Error Loading Mission FitFile :" + MCGExtensions.PathCombine(new string[] { MechCommanderUnity.Instance.MCGPath, "missions", missionFileName }));
            }
            //-----------------------------------------
            // Begin Setting up Teams and Commanders...
            loadProgress = 10.0f;

            //NULL ANY TEAMS & COMMANDERS

            //------------------------------------------------------------
            // First, let's see how many teams and commanders there are...
            long maxTeamID      = -1;
            long maxCommanderID = -1;

            if (loadType == MissionLoadType.MISSION_LOAD_MP_LOGISTICS)
            {
                //MP TEAMS & COMMANDERS
            }
            else
            {
                missionFile.SeekSection("Parts");
                int numParts;

                missionFile.GetInt("NumParts", out numParts);

                if (numParts > 0)
                {
                    for (int i = 1; i < (long)numParts + 1; i++)
                    {
                        //SP TEAMS & COMMANDERS



                        //------------------------------------------------------------------
                        // Find the object to load
                        missionFile.SeekSection("Part" + i);

                        int teamID = -1;
                        missionFile.GetInt("TeamId", out teamID);

                        int commanderID = -1;

                        if (missionFile.GetInt("CommanderId", out commanderID))
                        {
                            int cID;
                            missionFile.GetInt("CommanderId", out cID);
                            commanderID = (sbyte)cID;
                        }

                        //if (MPlayer && dropZoneList)
                        //{
                        //    //-------------------------------------------------------------
                        //    // Since dropZoneList is not NULL, we know this was not started
                        //    // from the command-line...
                        //    long origCommanderID = commanderID;
                        //    commanderID = commandersToLoad[origCommanderID][0];
                        //    teamID = commandersToLoad[origCommanderID][1];
                        //}

                        if (commanderID > maxCommanderID)
                        {
                            maxCommanderID = commanderID;
                        }
                        if (teamID > maxTeamID)
                        {
                            maxTeamID = teamID;
                        }
                    }
                }
            }

            missionFile.SeekSection("PaletteSystem");
            missionFile.GetString("PaletteSystem", out string paletteName);

            ContentReader.PaletteXpansion = paletteName == "palettex";

            //----------------------------------------------
            // Now, init the teams and commanders we need...

            //INIT TEAMS & COMMANDERS

            //-----------------------------
            // Init Trigger Area Manager...

            //-----------------------------------
            // Setup the Sensor System Manager...

            //INIT SENSOR MANAGER

            //INITIAL DROPZONE FROM missionFIle

            missionFile.SeekSection("DropZone0");
            missionFile.GetFloat("PositionX", out dropZone.x);
            missionFile.GetFloat("PositionY", out dropZone.y);

            //-----------------------------------------------------------------
            // Load the names of the scenario tunes.
            missionFile.SeekSection("Music");
            missionFile.GetInt("scenarioTuneNum", out missionTuneNum);
            //auxStr = "";
            //missionFile.getKeyValueBySection("Music", "scenarioTuneNum", out auxStr);
            //missionTuneNum=int.Parse(auxStr);

            //INIT CRATER MANAGER!!?¿?
            //result = craterManager->init(1000,20479,"feet");

//            MechCommanderUnity.LogMessage("Starting ObjectManager");
            //-----------------------------------------------------------------
            // Start the object system next.
            ObjectManager = GameObjectManager.Instance;
//            MechCommanderUnity.LogMessage("Finished ObjectManager");


            //-----------------------------------------------------------------
            // Start the collision detection system. -- Doesn't need objects?

            //------------------------------------------------------------
            // Start the Terrain System

            missionFile.SeekSection("TerrainSystem");
            string terrainFileName;

            missionFile.GetString("TerrainFileName", out terrainFileName);//System.IO.Path.ChangeExtension(missionName, "fit");
            //Read Terrain Fit File
            //INIT TERRAIN FILE
//            MechCommanderUnity.LogMessage("Starting Terrain");
            Terrain = new Terrain(terrainFileName);
            var Map = new GameObject();

            this.MapGO = Map;
//            MechCommanderUnity.LogMessage("Finished Terrain");

            loadProgress = 15.0f;

            //INIT TERRAIN GENERATION
//            MechCommanderUnity.LogMessage("Starting TerrainTiles");
            StartCoroutine(Terrain.InitTerrainTiles(GenerateMapIsoMeshes));
//            MechCommanderUnity.LogMessage("Finished TerrainTiles");
            //long terrainInitResult = land->init(&pakFile, 0, GameVisibleVertices, loadProgress, 20.0 );


            loadProgress = 35.0f;


            // land->load(missionFile);

            loadProgress = 36.0f;


            //----------------------------------------------------
            // Start GameMap for Movement System


            // PathManager = new MovePathManager;

            loadProgress = 40.0f;


            //----------------------
            // Load ABL Libraries...


            //---------------------------
            // Load the mission script...
            //-----------------------------------------------------------------
            // We now read in the mission Script File Name


            loadProgress = 41.0f;

            //-------------------------------------------
            // Load all MechWarriors for this mission...

            //Get Num Warrior from missionFile
            //foreach warrior
            //-------------------------
            // Find the warrior to load
            //--------------------------------------
            // Load the mechwarrior into the mech...
            //----------------------------
            // Read in the Brain module...
            //------------------------------------------------------------
            // For now, all mplayer brains are pbrain. Need to change when
            // we allow ai brains in mplayer...

            //---------------------------------------------------------------
            // Load the brain parameter file and load 'em for each warrior...


            loadProgress = 43.0f;

            //-----------------------------------------------------------------
            // All systems are GO if we reach this point.  Now we need to
            // parse the scenario file for the Objects we need for this scenario
            // We then create each object and place it in the world at the
            // position we read in with the frame we read in.



            //--------------------------------------------------------------------------------
            // IMPORTANT NOTE: mission parts should always start with Part 1.
            // Part 0 is reserved as a "NULL" id for routines that reference the mission
            // parts. AI routines, Brain keywords, etc. use PART ID 0 as an "object not found"
            // error code. DO NOT USE PART 0!!!!!!! Start with Part 1...


            loadProgress = 43.5f;

            //READ SPECIAL PARTS & LOAD THEM

            loadProgress = 48.5f;
            //--------------------------------------------------------------------------
            // Now that the parts data has been loaded, let's prep the ObjectManager for
            // the real things. First, count the number of objects we need...
            long numMechs    = 0;
            long numVehicles = 0;

            //foreach part load in Objectmanager calculate total nummechs & vehicles

            loadProgress = 55.0f;

            //pakFile.seekPacket(1);
            //ObjectManager->countTerrainObjects(&pakFile, (numMechs + MAX_TEAMS * MAX_REINFORCEMENTS_PER_TEAM) + (numVehicles + MAX_TEAMS * MAX_REINFORCEMENTS_PER_TEAM)/* + ObjectManager->maxElementals*/ + 1);
            loadProgress = 58.0f;
            //ObjectManager->setNumObjects(numMechs, numVehicles, 0, -1, -1, -1, 100, 50, 0, 130, -1);

            //-------------------------
            // Load the mech objects...


            loadProgress = 68.0f;

            //  ObjectManager->loadTerrainObjects(&pakFile, loadProgress, 30);
            ObjectManager.terrain = Terrain;
            StartCoroutine(ObjectManager.LoadTerrainObjects(Terrain.ObjBlock.objDataBlock, GenerateMapObj));
            //Terrain.InitTerrainObjects();

            loadProgress = 98.0f;

            //----------------------------------------------
            // Read in the Mission Time Limit.


            //----------------------------------------------
            // Read in the Objectives.  Safe to have none.

            //----------------------------
            // Read in Commander Groups...

            //-----------------------------------------------------------------------
            // Now that the parts are loaded, let's build the roster for each team...

            //---------------------------------------------------------------------------------
            // If we're not playing multiplayer, make sure all home commander movers have their
            // localMoverId set to 0, so the iface can at least check if a mover is player
            // controlled...

            //-----------------------------------------------------
            // This tracks time since scenario started in seconds.

            //----------------------------
            // Create and load the Weather

            //---------------------------------------------------------------
            // Start the Camera and Lists


            //----------------------------------------------------------------------------
            // Start the Mission GUI


            //--------------------------------------------------
            // Close all walls and open gates and landbridges...

//            MechCommanderUnity.LogMessage(loadProgress.ToString());
        }