void SpawnPotions() { Item items = new Item(); items._potionsList = new List<ItemEffect>(); items.GetPotionsAndRandomizeEffects();//hae potion prefabit ja randomoi niiden vaikutukset Manager Script = (Manager) (GameObject.Find("GaneManager").GetComponent(typeof(Manager))); Script.setPotionList(items); //foreach huoneet ja sinne item per huone testi int _potionCount = Random.Range(1, 4); for (int i = 0; i < _potionCount; i++) { int roomIndex = Random.Range(0, this._Rooms.Count - 1); Room room = Room.rooms[roomIndex]; int index = Random.Range(0, 4); float _potionPositionX = Random.Range(room.worldPosition.x + 1, room.worldPosition.x + room.size.x - 1); float _potionPositionY = Random.Range(room.worldPosition.y + 1, room.worldPosition.y + room.size.y - 1); Vector3 spawnPoint = new Vector3(_potionPositionX, _potionPositionY); MonoBehaviour.Instantiate(items._potionsList[index].Item, spawnPoint, Quaternion.identity); } }