Unity3d 戰略遊戲-地圖1-地圖初始化

public void BuildMap()
{
   m_map = new MapData(MapSizeX, MapSizeZ);
   
   for(int i=0; i<MapSizeZ; k++) {
     m_map[i, k] = new MapData();
  }
}

GameObject[] nodes = (GameObject[])GameObject.FindGameObjectsWithTag()("gridnode");

foreach(GameObject nodeobj in nodes)
{
   GridNode node = nodeobj.GetComponent<GridNode>();
   
   Vector3 pos = nodeobj.transform.position;
   
   if((int)pos.x >= MapSizeX || (int)pos.z >= MapSizeZ) {
      continue;
   }
   
   m_map[(int)pos.x, (int)pos.z].fieldtype = node._mapData.fieldtype;
}
相關文章
相關標籤/搜索