コード例 #1
0
ファイル: World.cs プロジェクト: Bycob/world
        public World(WorldDef worldDef)
        {
            string jsonStr = WorldSerialization.ToJson(worldDef);

            _handle = createWorldFromJson(jsonStr);
        }
コード例 #2
0
ファイル: LevelSelect.cs プロジェクト: etlearn/DoNotShake
    public void GoToLevelSelection(WorldDef worldDef)
    {
        ClearGrid(worldGrid);
        ClearGrid(levelGrid);
        loadedLevelGroups = new List<LevelGroupDef>();

        levelSelectPanel.enabled = true;
        worldSelectPanel.enabled = false;

        worldSelectPanel.gameObject.SetActiveRecursively(false);
        levelSelectPanel.gameObject.SetActiveRecursively(true);

        focusedLevelGroupIndex = 0;
        //focusedWorldIndex = 0;

        levelGrid.cellWidth = worldButtonSeparation;

        for (int i = 0; i < worldDef.levelGroups.Count; i++) {
            LevelGroupDef lg = (LevelGroupDef)Instantiate(worldDef.levelGroups[i]);
            lg.transform.parent = levelGrid.transform;
            lg.transform.localScale = Vector3.one;
            lg.levelSelect = this;
            loadedLevelGroups.Add(lg);

            lg.grids = new UIGrid[4];

            for (int j = 0; j < lg.grids.Length; j++) {
                lg.grids[j] = new GameObject("Grid").AddComponent<UIGrid>();
                lg.grids[j].cellWidth = 100.0f;
                lg.grids[j].transform.parent = lg.transform;
                lg.grids[j].transform.localPosition = new Vector3(-(100.0f*4.0f)/2.0f,((100.0f*4.0f)/2.0f)-j*100.0f,0);
                lg.grids[j].transform.localPosition += new Vector3(100.0f*0.5f,-100.0f*0.5f,0);
                lg.grids[j].transform.localScale = Vector3.one;
            }

            for (int j = 0; j < lg.levels.Count; j++) {
                int gridIndex = j/4;
                //Debug.Log(j+" "+gridIndex);
                LevelDef ld = (LevelDef)Instantiate(lg.levels[j]);
                ld.transform.parent = lg.grids[gridIndex].transform;
                ld.transform.localScale = Vector3.one;
                ld.levelSelect = this;
            }
            for (int j = 0; j < lg.grids.Length; j++) {
                lg.grids[j].Reposition();
            }
        }

        levelGrid.Reposition();
        isWorldSelect = false;
    }
コード例 #3
0
 public WorldDefEffectHandler(string objName, List <Effect> effects, WorldDef host)
     : base(objName, effects, host)
 {
 }
コード例 #4
0
        private void InitWorld(bool vulkan = false)
        {
            var worldDef = new WorldDef();

            worldDef.ground.terrainRes = resolution;
            // TODO check what value should have this parameter
            worldDef.ground.textureRes            = 3;
            worldDef.ground.minAltitude           = minAltitude;
            worldDef.ground.maxAltitude           = maxAltitude;
            worldDef.ground.tileSystem.maxLod     = 0;
            worldDef.ground.tileSystem.baseSize.x = tileWidth;
            worldDef.ground.tileSystem.baseSize.y = tileWidth;

            var perlin = new PerlinTerrainGeneratorDef();

            perlin.perlinInfo.octaves     = perlin.maxOctaves = octavesCount;
            perlin.perlinInfo.frequency   = frequency;
            perlin.perlinInfo.persistence = persistence;
            worldDef.ground.workers_list.Add(perlin);

            if (useBiomes)
            {
                var customMap = new CustomWorldRMModifierDef();
                customMap.biomeDensity    = biomeDensity;
                customMap.limitBrightness = limitBrightness;
                worldDef.ground.workers_list.Add(customMap);
            }

            var texturer = new MultilayerGroundTextureDef();

            texturer.distribResolution = distributionResolution;
            foreach (Layer layer in layers)
            {
                texturer.layers.Add(layer.distribParams);
            }

            if (vulkan)
            {
                var texProvider = new VkwGroundTextureGeneratorDef();
                texturer.texProvider = texProvider;

                foreach (Layer layer in layers)
                {
                    // I've got this bug: https://issuetracker.unity3d.com/issues/vulkan-amd-editor-crashes-with-vk-icdnegotiateloadericdinterfaceversion-when-changing-api-to-vulkan
                    // only when I add the second texture
                    // on draw(6) (multiple draw calls?)
                    texProvider.layers.Add(layer.shader);
                }
            }
            else
            {
                var texProvider = new GroundTextureGeneratorDef();
                texturer.texProvider = texProvider;

                foreach (Layer layer in layers)
                {
                    Color4dDef color = new Color4dDef
                    {
                        r = layer.color.r,
                        g = layer.color.g,
                        b = layer.color.b,
                        a = layer.color.a,
                    };
                    texProvider.colors.Add(color);
                }
            }

            worldDef.ground.workers_list.Add(texturer);

            _world = new World(worldDef);
            _world.SetCacheLocation(_cacheLocation);
        }
コード例 #5
0
 public WorldDefEffectHandler(List <Effect> effects, WorldDef host)
     : this("WorldEffectHandler (default)", effects, host)
 {
 }