Write() public method

向配置文件中写入一条记录.
public Write ( string key, object values, string description = "" ) : void
key string
values object
description string 注释.
return void
Esempio n. 1
0
    public void SaveStageData(int levelNum)              //保存关卡数据到一个文件
    {
        _config = new ConfigOperator("Level" + levelNum);
        _config.Write("Target", (int)Target);
        _config.Write("StepLimit", StepLimit);
        _config.Write("TimeLimit", TimeLimit);
        _config.Write("ColorCount", ColorCount);
        _config.Write("Nut1Count", Nut1Count);
        _config.Write("Nut2Count", Nut2Count);
		_config.Write("NutInitCount", NutInitCount);
        _config.Write("NutMaxCount", NutMaxCount);
        _config.Write("NutMinCount", NutMinCount);
		_config.Write("NutStep", NutStep);

        _config.Write("PlusInitCount", PlusInitCount);
        _config.Write("PlusMaxCount", PlusMaxCount);
        _config.Write("PlusStartTime", PlusStartTime);
        _config.Write("PlusStepMin", PlusStepMin);
        _config.Write("PlusStepMax", PlusStepMax);

        _config.Write("Seed", Seed);
        _config.Write("NewFormat", 1);                  //新格式标记
        string temp = string.Empty;
        for (int i = 0; i < 3; ++i )
        {
            temp = temp + StarScore[i] + ",";
        }

        _config.Write("StarScore", temp);

        temp = string.Empty;
        for (int i = 0; i < 3; ++i)
        {
            temp = temp + (int)CollectColors[i] + ",";
        }

        _config.Write("CollectColors", temp);

        temp = string.Empty;
        for (int i = 0; i < 3; ++i)
        {
            temp = temp + (int)CollectSpecial[i] + ",";
        }

        _config.Write("CollectSpecial", temp);

        temp = string.Empty;
        for (int i = 0; i < 3; ++i)
        {
            temp = temp + CollectCount[i] + ",";
        }

        _config.Write("CollectCount", temp);

        temp = string.Empty;
        for (int j = 0; j < GameLogic.BlockCountY; ++j)
        {
            for (int i = 0; i < GameLogic.BlockCountX; ++i)
            {
                temp = temp + GridData[i, j] + ",";
            }
        }

        _config.Write("GridDataArray", temp);

        temp = string.Empty;

        foreach(KeyValuePair<int, Portal> pair in PortalToMap)
        {
            temp = temp + pair.Value.from.x + ",";
            temp = temp + pair.Value.from.y + ",";
            temp = temp + pair.Value.to.x + ",";
            temp = temp + pair.Value.to.y + ",";
            temp = temp + pair.Value.flag + ",";
        }

        _config.Write("PortalArray", temp);

        //保存画面上的特殊块
        temp = string.Empty;
        for (int j = 0; j < GameLogic.BlockCountY; ++j)
        {
            for (int i = 0; i < GameLogic.BlockCountX; ++i)
            {
                CapBlock block = GameLogic.Singleton.GetBlock(new Position(i, j));
                if (block != null && block.special != TSpecialBlock.ESpecial_Normal)
                {
                    temp = temp + i + ",";
                    temp = temp + j + ",";
                    temp = temp + (int)block.special+ ",";
                }
            }
        }
        _config.Write("SpecialArray", temp);

        _config.Save();
        Debug.Log("Level " + levelNum + " Saved");
    }
Esempio n. 2
0
    public void SaveStageData(int levelNum)              //保存关卡数据到一个文件
    {
        _config = new ConfigOperator("Level" + levelNum);
        _config.Write("Target", (int)Target);
        _config.Write("StepLimit", StepLimit);
        _config.Write("TimeLimit", TimeLimit);
        _config.Write("ColorCount", ColorCount);
        _config.Write("Nut1Count", Nut1Count);
        _config.Write("Nut2Count", Nut2Count);
		_config.Write("NutInitCount", NutInitCount);
        _config.Write("NutMaxCount", NutMaxCount);
		_config.Write("NutStep", NutStep);

        _config.Write("PlusInitCount", PlusInitCount);
        _config.Write("PlusMaxCount", PlusMaxCount);
        _config.Write("PlusStartTime", PlusStartTime);
        _config.Write("PlusStep", PlusStep);

        _config.Write("Seed", Seed);
        _config.Write("NewFormat", 1);                  //新格式标记
        string temp = string.Empty;
        for (int i = 0; i < 3; ++i )
        {
            temp = temp + StarScore[i] + ",";
        }

        _config.Write("StarScore", temp);

        temp = string.Empty;
        for (int j = 0; j < GameLogic.BlockCountY; ++j)
        {
            for (int i = 0; i < GameLogic.BlockCountX; ++i)
            {
                temp = temp + GridData[i, j] + ",";
            }
        }

        _config.Write("GridDataArray", temp);

        temp = string.Empty;

        foreach(KeyValuePair<int, Portal> pair in PortalToMap)
        {
            temp = temp + pair.Value.from.x + ",";
            temp = temp + pair.Value.from.y + ",";
            temp = temp + pair.Value.to.x + ",";
            temp = temp + pair.Value.to.y + ",";
            temp = temp + pair.Value.flag + ",";
        }

        _config.Write("PortalArray", temp);

        _config.Save();
        Debug.Log("Level " + levelNum + " Saved");
    }