コード例 #1
0
ファイル: HexGrid.cs プロジェクト: etihw-mxlin/WYMiniGame
    public void SaveFile()
    {
        HexCellMsgArray tempCell = CreateCellMsg();
        string          jsonStr  = JsonUtility.ToJson(tempCell);
        StreamWriter    sw       = new StreamWriter(Application.dataPath + "/" + ScenesName + ".txt");

        sw.Write(jsonStr);
        sw.Close();
    }
コード例 #2
0
ファイル: HexGrid.cs プロジェクト: etihw-mxlin/WYMiniGame
    HexCellMsgArray CreateCellMsg()
    {
        HexCellMsgArray tempCell = new HexCellMsgArray()
        {
            cellArray = new List <HexCellMsg>()
        };

        for (int i = 0; i < cellCountX * cellCountZ; i++)
        {
            HexCellMsg temp = new HexCellMsg();
            temp.x         = cells[i].x;
            temp.y         = cells[i].z;
            temp.color     = cells[i].Color;
            temp.Elevation = cells[i].Elevation;
            tempCell.cellArray.Add(temp);
        }
        return(tempCell);
    }
コード例 #3
0
ファイル: HexGrid.cs プロジェクト: etihw-mxlin/WYMiniGame
 void LoadFile()
 {
     if (File.Exists(Application.dataPath + "/" + ScenesName + ".txt"))
     {
         StreamReader    sr      = new StreamReader(Application.dataPath + "/" + ScenesName + ".txt");
         string          temp    = sr.ReadToEnd();
         HexCellMsgArray tempMeg = JsonUtility.FromJson <HexCellMsgArray>(temp);
         cells = new HexCell[cellCountX * cellCountZ];
         for (int i = 0; i < cellCountX * cellCountZ; i++)
         {
             CreateCell(tempMeg.cellArray[i].x, tempMeg.cellArray[i].y, i, tempMeg.cellArray[i].color, tempMeg.cellArray[i].Elevation);
         }
     }
     else
     {
         CreateCells();
     }
 }