private void PlaceAbility() { if (_level == 1 || _level % 3 == 0) { try { var ability = AbilityGenerator.CreateAbility(); int roomIndex = Game.Random.Next(0, _map.Rooms.Count - 1); Point location = _map.GetRandomLocationInRoom(_map.Rooms[roomIndex]); _map.AddTreasure(location.X, location.Y, ability); } catch (InvalidOperationException) { } } }
private void PlaceAbility() { if (_level == 1 || _level % 3 == 0) { Ability ability; try { ability = AbilityGenerator.CreateAbility(); } catch (InvalidOperationException) { return; } int roomIndex = Game.Random.Next(0, _map.Rooms.Count - 1); Point location = _map.GetRandomLocationInRoom(_map.Rooms[roomIndex]); ability.go = GameObject.Instantiate <GameObject>(Game.Items[ability.Name], new Vector2(location.X, location.Y), Quaternion.identity); ability.go.transform.SetParent(Game.itemsHolder); ability.go.GetComponent <Renderer>().enabled = false; Game.ItemsTiles[location.X, location.Y] = ability; _map.AddTreasure(location.X, location.Y, ability); } }