Example #1
0
    void loadCellData(string s)
    {
        if (string.IsNullOrEmpty(s))
        {
            return;
        }

        string[] data = s.Split('$');
        if (data.Length < 2)
        {
            return;
        }

        CellData cell = GetCellById(int.Parse(data[0]));

        int heightDataCount = (data.Length - 1) / 2;

        for (int i = 0; i < heightDataCount; i++)
        {
            float h  = float.Parse(data[i * 2 + 1]);
            float sz = float.Parse(data[i * 2 + 2]);
            cell.AddHeight(h, sz);
        }

        if (((data.Length - 1) % 2) == 1)
        {
            bool canMove = true;
            if (bool.TryParse(data[data.Length - 1], out canMove))
            {
                if (canMove)
                {
                    cell.AddUnit(UnitType.OBJECTS);
                }
                else
                {
                    cell.AddUnit(UnitType.OBSTACLE);
                }
            }
            else
            {
                cell.Unit = (UnitType)System.Enum.Parse(typeof(UnitType), data[data.Length - 1]);
            }
        }
        else
        {
            cell.AddUnit(UnitType.OBJECTS);
        }
    }
Example #2
0
 public CellData this[int x, int z]
 {
     get
     {
         return(GetCell(x, z));
     }
     set
     {
         WriteCellData(x, z, new Vector3(1, 0, 1), value.Unit);
         int      len = value.Height.Count;
         CellData cur = GetCell(x, z);
         cur.RemoveAllHeight();
         for (int i = 0; i < len; i++)
         {
             cur.AddHeight(value.Height[i].Height, value.Height[i].Size);
         }
     }
 }