コード例 #1
0
            void Awake()
            {
                Debug.Log("MenuTriggers.Awake", "Nyan.nyan = " + Nyan.nyan);
                Debug.Log("MenuTriggers.Awake", "MunSceneInfo.DataBase.Count = " + MunSceneInfo.DataBase?.Count);
                Debug.Log("MenuTriggers.Awake", "OrbitSceneInfo.DataBase.Count = " + OrbitSceneInfo.DataBase?.Count);
                if (!Nyan.nyan && !(MunSceneInfo.DataBase?.Count > 0) && !(OrbitSceneInfo.DataBase?.Count > 0))
                {
                    return;
                }

                GameObject[] scenes = FindObjectOfType <MainMenu>()?.envLogic?.areas;

                Debug.Log("MenuTriggers.Awake", "scenes = " + scenes?.Length);
                if (scenes == null)
                {
                    return;
                }

                int    i    = 1;
                string hash = DateTime.Now.ToLongTimeString();

                hash = Math.Abs(hash.GetHashCode()).ToString();

                i = PseudoRandom.Scene(Math.Abs(hash.GetHashCode()));
                Debug.Log("MenuTriggers.Awake", "random scene = " + i);

                // Choose Scene
                scenes[i].SetActive(true);
                scenes[(i + 1) % 2].SetActive(false);

                if (Nyan.nyan)
                {
                    Debug.Log("MenuTriggers.Awake", "Loading nyan scene");

                    Renderer mun = scenes[1].GetChild("Mun").GetComponent <Renderer>();
                    mun.material.SetTexture(Nyan.nyanGround);

                    Terrain        terrain = scenes[0].GetChild("Terrain").GetComponent <Terrain>();
                    TerrainLayer[] layers  = terrain.terrainData.terrainLayers;
                    layers[0].diffuseTexture          = layers[1].diffuseTexture = (Texture2D)Nyan.nyanGround;
                    layers[0].normalMapTexture        = layers[1].normalMapTexture = null;
                    terrain.terrainData.terrainLayers = layers;
                    return;
                }

                Debug.Log("MenuTriggers.Awake", "chosen scene = " + i);
                if (i == 0)
                {
                    Debug.Log("MenuTriggers.Awake", "Loading mun scene");

                    int            index = MunSceneInfo.DataBase.Choose(Math.Abs(hash.GetHashCode()));
                    CustomMunScene scene = new CustomMunScene((MunSceneInfo)MunSceneInfo.DataBase[index]);
                    scene.ApplyTo(scenes[0]);
                }
                else if (OrbitSceneInfo.DataBase?.Count > 0)
                {
                    Debug.Log("MenuTriggers.Awake", "Loading orbit scene");

                    int index = OrbitSceneInfo.DataBase.Choose(Math.Abs(hash.GetHashCode()));
                    CustomOrbitScene scene = new CustomOrbitScene((OrbitSceneInfo)OrbitSceneInfo.DataBase[index]);
                    scene.ApplyTo(scenes);
                }

                if (KopernicusFixer.detect)
                {
                    Debug.Log("MenuTriggers.Awake", "Kopernicus has been detected");

                    gameObject.AddOrGetComponent <KopernicusFixer>();
                }
            }