public void LoadGarbageTile(GarbageTile.SaveData[] datas) { if (datas == null) { return; } foreach (var item in datas) { if (objectTileDic.ContainsKey(item.point)) { continue; } GameObject obj = Instantiate(prefGarbageTile, objectTileGroup.transform); GarbageTile script = obj.GetComponent <GarbageTile>(); script.SetSaveData(item); objectTileDic.Add(item.point, script); } }
public void CreateGarbageTile() { while (true) { Point point; point.X = Random.Range(0, MapData.MapWidth); point.Y = Random.Range(0, MapData.MapHeight); if (!objectTileDic.ContainsKey(point)) { int typeLength = MapData.Instance.GarbageDataDic.Count; int randomType = Random.Range(0, typeLength); GameObject obj = Instantiate(prefGarbageTile, objectTileGroup.transform); GarbageTile script = obj.GetComponent <GarbageTile>(); script.DeployTile(point, randomType); objectTileDic.Add(point, script); break; } } }