コード例 #1
0
ファイル: Level.cs プロジェクト: ShadowVision/FOX
    public void init(Data_Level options)
    {
        //build sun
        GameObject go = new GameObject ("Sun");
        sun = go.AddComponent<Light> ();
        sun.type = LightType.Directional;
        sun.transform.position = new Vector3 (0, 10, 0);
        setSun (options.sunColor, options.sunBrightness, options.sunDirection);

        //build grid
        tiles = new Dictionary<TilePosition, GameTile> ();
        tileHolder = new GameObject ("TileHolder");
        tileHolder.transform.parent = transform;
        foreach(Data_GameTile tileOptions in options.tiles){
            addTile(tileTemplate, tileOptions);
        }
    }
コード例 #2
0
ファイル: LevelBuilder.cs プロジェクト: ShadowVision/FOX
    public void loadLevel()
    {
        Data_Level options = new Data_Level ();
        options.sunColor = new Color (1, 1, 1);
        options.sunBrightness = 1f;
        options.sunDirection = new Vector3 (45, 45, 0);

        JSONNode levelJson = io.loadData (projectName, levelName);

        List<Data_GameTile> tileOptions = new List<Data_GameTile> ();

        foreach (JSONNode node in levelJson["level"]["tiles"].AsArray) {
            Data_GameTile to = new Data_GameTile ();
            to.loadData(node);
            tileOptions.Add(to);
        }

        options.tiles = tileOptions;
        level.init (options);
    }
コード例 #3
0
ファイル: LevelBuilder.cs プロジェクト: ShadowVision/FOX
    private void loadDefaultLevel()
    {
        Data_Level options = new Data_Level ();
        options.sunColor = new Color (0, 1, 1);
        options.sunBrightness = 1f;
        options.sunDirection = new Vector3 (45, 45, 0);

        List<Data_GameTile> tileOptions = new List<Data_GameTile> ();
        for(int x=0; x<defaultMapSize; x++){
            for(int y=0; y<defaultMapHeight; y++){
                for(int z=0; z<defaultMapSize; z++){
                    Data_GameTile to = new Data_GameTile ();
                    to.position = new TilePosition (x, y, z);
                    to.loadData(to.saveData());
                    tileOptions.Add(to);
                }
            }
        }
        options.tiles = tileOptions;
        level.init (options);
    }
コード例 #4
0
ファイル: LevelBuilder.cs プロジェクト: ShadowVision/FOX
    private void loadRandomLevel()
    {
        Data_Level options = new Data_Level ();
        options.sunColor = new Color (Random.Range(0f,1f),Random.Range(0f,1f),Random.Range(0f,1f));
        options.sunBrightness = Random.Range(.2f,2f);
        options.sunDirection = new Vector3 (Random.Range(0,180), Random.Range(0,180), 0);

        List<Data_GameTile> tileOptions = new List<Data_GameTile> ();
        for(int x=0; x<defaultMapSize; x++){
            int height = Random.Range(1,6);
            for(int y=0; y<height; y++){
                for(int z=0; z<defaultMapSize; z++){
                    Data_GameTile to = new Data_GameTile ();
                    to.position = new TilePosition (x, y, z);
                    to.loadData(to.saveData());
                    tileOptions.Add(to);
                }
            }
        }
        options.tiles = tileOptions;
        level.init (options);
    }