public virtual void SetItem(Item_TYPE _type) { dropItemob = Instantiate(LoadDataManager.instance.itemPrefabDic[_type.ToString()]); dropItemob.transform.localPosition = Vector2.zero; dropItemob.transform.SetParent(this.transform.parent); dropItemob.gameObject.SetActive(false); }
/// <summary> /// NOTE : 아이템 PREFAB 생성 /// </summary> /// <param name="room"></param> private void DrawItem(DungeonRoom room) { room.SetPrefabInfoList(room.itemInfoList); foreach (SpawnItemInfo iteminfo in room.itemInfoList) { ItemSc tmpitem = Instantiate(loadData.itemPrefabDic[iteminfo.iType.ToString()], iteminfo.startpos, Quaternion.identity, room.roomModel.transform); iteminfo.itemModel = tmpitem; } }
public SpawnItemInfo(Item_TYPE _itype, Vector2 _startpos) { iType = _itype; startpos = _startpos; itemModel = null; }
/// <summary> /// NOTE : Tileinfo를 통하여 Draw /// </summary> /// <param name="_rooms"></param> public GameObject DrawTilemap(DungeonRoom room, bool ingame) { //Tilemap 생성 및 초기화 var tmpob = new GameObject("Room" + room.roomNumberOfList, typeof(Tilemap), typeof(CompositeCollider2D)); tmpob.AddComponent <TilemapCollider2D>().usedByComposite = true; tmpob.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Static; tmpob.AddComponent <TilemapRenderer>().sortingLayerName = "Ground"; tmpob.tag = "Ground"; tmpob.layer = 8; Tilemap tmptilemap = tmpob.GetComponent <Tilemap>(); //내부 생성 for (int x = 0; x < room.roomRect.xMax; x++) { for (int y = 0; y < room.roomRect.yMax; y++) { if (room.roomTileArray[x, y] != null) { TileInfo tmpdata = room.roomTileArray[x, y]; switch (tmpdata.tileType) { case TileType.Terrain: tmptilemap.SetTile(new Vector3Int(x, y, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile); break; case TileType.Structure: StructureObject tmpen = Instantiate(loadData.structurePrefabDic[tmpdata.tileName], new Vector3(x + 0.5f, y + 0.5f, 0), Quaternion.identity, tmptilemap.transform); tmpen.ownRoom = room; if (tmpdata.tileName == STRUCTURE_TYPE.Entrance.ToString()) { tmpen.transform.localPosition += new Vector3(0, 0.5f, 0); //Maptool에서 사용할경우 대비 if (room.entranceInfoList.Count == 0) { room.entranceInfoList.Add(new EntranceConnectRoom(null, tmpen.GetComponent <EntranceSc>())); } if (room.roomClearType == Room_ClearType.Boss) { tmpen.sR.sprite = loadData.tileDataArray[room.roomSpriteType].entranceSprite[0]; } tmpen.sR.sprite = loadData.tileDataArray[room.roomSpriteType].entranceSprite[0]; tmpen.sR.sortingLayerName = "Entrance"; tmpen.GetComponent <EntranceSc>().spriteArray[0] = loadData.tileDataArray[room.roomSpriteType].entranceSprite[0]; tmpen.GetComponent <EntranceSc>().spriteArray[1] = loadData.tileDataArray[room.roomSpriteType].entranceSprite[1]; tmpen.transform.SetParent(tmpob.transform); //이미 출입문이 생성되어있는방 예외 처리 foreach (EntranceConnectRoom nroom in room.entranceInfoList) { if (nroom.entrance == null) { tmpen.GetComponent <EntranceSc>().ownRoom = room; nroom.entrance = tmpen.GetComponent <EntranceSc>(); break; } } } else if (tmpdata.tileName == STRUCTURE_TYPE.Box.ToString()) { room.boxInfoList.Add(new SpawnBoxInfo(tmpdata.tileNamesType.ToString(), tmpen)); } else if (tmpdata.tileName == STRUCTURE_TYPE.Switch.ToString()) { room.switchInfoList.Add(new SpawnSwitchInfo(tmpdata.tileNamesType, tmpen)); } break; case TileType.Monster: Monster tmpmonster = Instantiate(loadData.monsterPrefabDic[room.roomTileArray[x, y].tileName], new Vector3Int(x, y, 0), loadData.monsterPrefabDic[room.roomTileArray[x, y].tileName].transform.rotation, tmptilemap.transform); tmpmonster.ownRoom = room; room.monsterInfoList.Add(new SpawnMonsterInfo(tmpmonster.mType, new Vector2(x, y), tmpmonster)); break; case TileType.Item: ItemSc tmpitem = Instantiate(loadData.itemPrefabDic[room.roomTileArray[x, y].tileName], new Vector3Int(x, y, 0), Quaternion.identity, tmptilemap.transform); break; case TileType.Boss: BossMonsterController tmpboss = Instantiate(loadData.bossPrefabDic[room.roomTileArray[x, y].tileName], new Vector3Int(x, y, 0), loadData.bossPrefabDic[room.roomTileArray[x, y].tileName].transform.rotation, tmptilemap.transform); tmpboss.ownRoom = room; room.bossInfoList.Add(new SpawnBossInfo(tmpboss.bType, new Vector2(x, y), tmpboss)); break; default: Debug.Log(room.roomTileArray[x, y].tileType.ToString()); break; } } } } //인게임일 경우에만 생성 (맵툴의 경우에는 배경을 남겨두므로 제외) if (ingame) { //Edge생성 for (int i = 0; i < room.roomRect.xMax; i++) { tmptilemap.SetTile(new Vector3Int(i, -1, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile); tmptilemap.SetTile(new Vector3Int(i, -2, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile); tmptilemap.SetTile(new Vector3Int(i, (int)room.roomRect.yMax, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile); tmptilemap.SetTile(new Vector3Int(i, (int)room.roomRect.yMax + 1, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile); } //left, right for (int j = -2; j < room.roomRect.yMax + 2; j++) { tmptilemap.SetTile(new Vector3Int(-1, j, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile); tmptilemap.SetTile(new Vector3Int(-2, j, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile); tmptilemap.SetTile(new Vector3Int((int)room.roomRect.xMax, j, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile); tmptilemap.SetTile(new Vector3Int((int)room.roomRect.xMax + 1, j, 0), loadData.tileDataArray[room.roomSpriteType].terrainRuleTile); } //배경 생성 GameObject tmpParent = new GameObject("BackGroundParent"); int count = 0; foreach (var tmptile in loadData.tileDataArray[room.roomSpriteType].backGroundTile) { GameObject backgroundob = new GameObject("BackGround", typeof(SpriteRenderer)); backgroundob.transform.localPosition = Vector3.zero; backgroundob.transform.localRotation = Quaternion.identity; backgroundob.GetComponent <SpriteRenderer>().sortingLayerName = "BackGround"; backgroundob.GetComponent <SpriteRenderer>().drawMode = SpriteDrawMode.Sliced; backgroundob.GetComponent <SpriteRenderer>().sprite = tmptile.sprite; backgroundob.GetComponent <SpriteRenderer>().size = room.roomRect.size; backgroundob.GetComponent <SpriteRenderer>().sortingOrder = count; count++; backgroundob.transform.SetParent(tmpParent.transform); } tmpParent.transform.SetParent(tmpob.transform); } room.roomModel = tmpob; tmpob.SetActive(false); return(tmpob); }
protected override void Awake() { base.Awake(); item = Instantiate(LoadDataManager.instance.itemPrefabDic[Item_TYPE.BigCatnip.ToString()], new Vector3(transform.position.x, transform.position.y + 2f, 0), Quaternion.identity); item.gameObject.SetActive(false); }