//加入房间的prefab public void initMapScenes(mapinfo mapInfo) { foreach (roominfo roomInfo in mapInfo.mRoomInfos) { SceneTemplate template = getSceneTemplate(roomInfo.mSceneIndex); if (roomInfo.mRoomType == constant.RoomType.Item) { int itemNum = 1; List <Vector3> poss = new List <Vector3>(); foreach (Vector3 v in template.BaseItemPos) { poss.Add(v); } for (int i = 0; i < itemNum; ++i) { itemtemplate item = constant.getItemFactory().getRandomTemplate(roomInfo, mapInfo); int index = Random.Range(0, poss.Count - 1); Vector3 v = poss[index]; poss.RemoveAt(index); roomInfo.addItemPrefabs(item, v); } } else if (roomInfo.mRoomType == constant.RoomType.Monster) { int monsterNum = 1; List <Vector3> poss = new List <Vector3>(); foreach (Vector3 v in template.BaseMonsterPos) { poss.Add(v); } //Debug.Log("count:" + poss.Count); for (int i = 0; i < monsterNum; ++i) { monstertemplate monster = constant.getMonsterFactory().getRandomTemplate(roomInfo, mapInfo); int index = Random.Range(0, poss.Count - 1); Vector3 v = poss[index]; poss.RemoveAt(index); roomInfo.addMonsterPrefabs(monster, v); } } } }
public void addMonsterPrefabs(monstertemplate template, Vector3 v) { mMonsterPrefabs.Add(new KeyValuePair <monstertemplate, Vector3>(template, v)); }