示例#1
0
        /// <summary>
        /// Create the terrain defined by these settings - and apply the resources to it
        /// </summary>
        public void CreateTerrain(GaiaResource resources)
        {
            Terrain[,] world;

            //Update the resouces ny associating them with their assets
            resources.AssociateAssets();

            //Update the session
            GaiaSessionManager sessionMgr = GaiaSessionManager.GetSessionManager();

            if (sessionMgr != null && sessionMgr.IsLocked() != true)
            {
                //Update terrain settings in session
                sessionMgr.m_session.m_terrainWidth  = m_tilesX * m_terrainSize;
                sessionMgr.m_session.m_terrainDepth  = m_tilesZ * m_terrainSize;
                sessionMgr.m_session.m_terrainHeight = m_terrainHeight;

                //Add the defaults
                sessionMgr.AddDefaults(this);

                //Set the sea level - but only if it is zero - if not zero then its been deliberately set
                if (Gaia.GaiaUtils.Math_ApproximatelyEqual(sessionMgr.m_session.m_seaLevel, 0f))
                {
                    sessionMgr.SetSeaLevel(m_seaLevel);
                }

                //Grab the resources scriptable object
                sessionMgr.AddResource(resources);

                //Adjust them if they are different to the defaults
                resources.ChangeSeaLevel(sessionMgr.m_session.m_seaLevel);

                //Then add the operation
                sessionMgr.AddOperation(GetTerrainCreationOperation(resources));
            }

            //Create the terrains array
            world = new Terrain[m_tilesX, m_tilesZ];

            //And iterate through and create each terrain
            for (int x = 0; x < m_tilesX; x++)
            {
                for (int z = 0; z < m_tilesZ; z++)
                {
                    CreateTile(x, z, ref world, resources);
                }
            }

            //Now join them together and remove their seams
            RemoveWorldSeams(ref world);
        }
示例#2
0
        /// <summary>
        /// Create the terrain defined by these settings
        /// </summary>
        public void CreateTerrain()
        {
            Terrain[,] world;

            //Update the session
            GaiaSessionManager sessionMgr = GaiaSessionManager.GetSessionManager();

            if (sessionMgr != null && sessionMgr.IsLocked() != true)
            {
                //Update terrain settings in session
                sessionMgr.m_session.m_terrainWidth  = m_tilesX * m_terrainSize;
                sessionMgr.m_session.m_terrainDepth  = m_tilesZ * m_terrainSize;
                sessionMgr.m_session.m_terrainHeight = m_terrainHeight;
                sessionMgr.AddDefaults(this);

                sessionMgr.SetSeaLevel(m_seaLevel);

                //Then add the operation
                GaiaOperation op = new GaiaOperation();
                op.m_description       = "Creating terrain";
                op.m_generatedByID     = m_defaultsID;
                op.m_generatedByName   = this.name;
                op.m_generatedByType   = this.GetType().ToString();
                op.m_isActive          = true;
                op.m_operationDateTime = DateTime.Now.ToString();
                op.m_operationType     = GaiaOperation.OperationType.CreateTerrain;
                sessionMgr.AddOperation(op);
            }

            //Create the terrains array
            world = new Terrain[m_tilesX, m_tilesZ];

            //And iterate through and create each terrain
            for (int x = 0; x < m_tilesX; x++)
            {
                for (int z = 0; z < m_tilesZ; z++)
                {
                    CreateTile(x, z, ref world, null);
                }
            }

            //Now join them together and remove their seams
            RemoveWorldSeams(ref world);
        }