Example #1
0
 //Clean up eventTable every time a new level loads.
 public void SceneLoaded(int unused)
 {
     GameObjectManager.Cleanup();
 }
Example #2
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());
        }