Esempio n. 1
0
        void Start()
        {
            if (player == null)
            {
                throw new MissingComponentException("Missing Player component");
            }
            if (blockParticle == null)
            {
                throw new MissingComponentException("Missing Block Particle component");
            }
            if (chunkMeshPrefab == null)
            {
                throw new MissingComponentException("Missing Chunk Mesh component");
            }
            if (solidBlockMaterial == null)
            {
                throw new MissingComponentException("Missing Solid Block Material component");
            }
            if (transparentBlockMaterial == null)
            {
                throw new MissingComponentException("Missing Transparent Block Material component");
            }
            if (waterBlockMaterial == null)
            {
                throw new MissingComponentException("Missing Water Block Material component");
            }

            Vector3 playerStartPosition;

            playerStartPosition.x = 64.5f;
            playerStartPosition.y = 148;
            playerStartPosition.z = 64.5f;
            Instantiate(player, playerStartPosition, Quaternion.identity);

            instance = this;
            BlockDefinition.InitializeAllTypes();
            AsyncService.Initialize();
            ChunkRepository.Initialize();
            CollisionService.Initialize();
            GeneratorService.Initialize();
            RenderService.Initialize();

            SetSeed(UnityEngine.Random.Range(Int32.MinValue + 1, Int32.MaxValue - 1));

            fogDistance = 0.0f;

            AsyncService.Load();

            // Remove the next line if you want your game to stop processing when it loses focus
            Application.runInBackground = true;
        }