public void LoadContent(World world, Vector2 size, Vector2 position, ContentManager Content, CollectibleItemType type) { //Initialisation du body body = BodyFactory.CreateRectangle(world, size.X, size.Y, 1f); body.BodyType = BodyType.Static; body.IsSensor = true; body.Position = position; bodyPosition = position; body.FixtureList[0].UserData = (int)(500+id); //Initialisation de l'image Vector2 imagePosition = new Vector2(ConvertUnits.ToDisplayUnits(position.X), ConvertUnits.ToDisplayUnits(position.Y)); image = new Image(); string texturePath = ""; if (type == CollectibleItemType.HEALTH) { texturePath = "Graphics/Collectible/plume"; } else { texturePath = "Graphics/TileMap/torchStone"; } image.LoadContent(Content, texturePath, Color.White, imagePosition); image.ScaleToMeters(size); this.type = type; }
public AbstractAbility GetRandomAbility(CollectibleItemType type, CollectibleItemPower power) { //if (AllAbilities.Count > 0) //{ // return AllAbilities[Random.Range(0, AllAbilities.Count)]; //} //else //{ // return new EmptyAbility(); //} var abilities = AllAbilities.FindAll(ability => ability.ItemPower == power && ability.ItemType == type); if (abilities.Count > 0) { var index = Random.Range(0, abilities.Count); return(abilities[index]); } else { return(null); } }