added sound effects

This commit is contained in:
Ellpeck 2020-06-22 14:13:59 +02:00
parent aa6a75a14b
commit 28be9644cc
10 changed files with 98 additions and 35 deletions

View file

@ -13,6 +13,67 @@
#---------------------------------- Content ---------------------------------# #---------------------------------- Content ---------------------------------#
#begin Fonts/Regular.spritefont
/importer:FontDescriptionImporter
/processor:FontDescriptionProcessor
/processorParam:PremultiplyAlpha=True
/processorParam:TextureFormat=Compressed
/build:Fonts/Regular.spritefont
#begin Localization/Localization.de.json
/copy:Localization/Localization.de.json
#begin Localization/Localization.json
/copy:Localization/Localization.json
#begin Localization/News.de.json
/copy:Localization/News.de.json
#begin Localization/News.json
/copy:Localization/News.json
#begin Sounds/Click.wav
/importer:WavImporter
/processor:SoundEffectProcessor
/processorParam:Quality=Best
/build:Sounds/Click.wav
#begin Sounds/Place.wav
/importer:WavImporter
/processor:SoundEffectProcessor
/processorParam:Quality=Best
/build:Sounds/Place.wav
#begin Sounds/StarBuy.ogg
/importer:OggImporter
/processor:SoundEffectProcessor
/processorParam:Quality=Best
/build:Sounds/StarBuy.ogg
#begin Textures/Attractions.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/Attractions.png
#begin Textures/Tiles.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/Tiles.png
#begin Textures/Ui.png #begin Textures/Ui.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -25,30 +86,3 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/Ui.png /build:Textures/Ui.png
#begin Fonts/Regular.spritefont
/importer:FontDescriptionImporter
/processor:FontDescriptionProcessor
/build:Fonts/Regular.spritefont
#begin Textures/Attractions.png
/importer:TextureImporter
/processor:TextureProcessor
/build:Textures/Attractions.png
#begin Textures/Tiles.png
/importer:TextureImporter
/processor:TextureProcessor
/build:Textures/Tiles.png
#begin Localization/Localization.json
/copy:Localization/Localization.json
#begin Localization/News.json
/copy:Localization/News.json
#begin Localization/Localization.de.json
/copy:Localization/Localization.de.json
#begin Localization/News.de.json
/copy:Localization/News.de.json

View file

@ -4,6 +4,7 @@
"bin/" "bin/"
], ],
"overrides": { "overrides": {
".json": "Copy" ".json": "Copy",
"Sounds/": [null, "SoundEffectProcessor"]
} }
} }

View file

@ -11,6 +11,7 @@
"AppliedUpgrades": "Aktives Upgrade", "AppliedUpgrades": "Aktives Upgrade",
"Options": "Optionen", "Options": "Optionen",
"RainingTicketLimit": "Max. Fallende Tickets", "RainingTicketLimit": "Max. Fallende Tickets",
"SoundVolume": "Lautstärke",
"----- Tutorial -----": "", "----- Tutorial -----": "",
"Tutorial1": "Hi! Willkommen zu Touchy Tickets. Um das Spiel zu starten, tippe einfach den Ticket-Laden an, um ein <i ticket> zu verkaufen. Verkaufe erstmal 50<i ticket>!", "Tutorial1": "Hi! Willkommen zu Touchy Tickets. Um das Spiel zu starten, tippe einfach den Ticket-Laden an, um ein <i ticket> zu verkaufen. Verkaufe erstmal 50<i ticket>!",
"Tutorial2": "Super! Jetzt kannst du deine erste Attraktion kaufen. Wechsel durch Wischen zum rechten Menü und kaufe ein Karussell.", "Tutorial2": "Super! Jetzt kannst du deine erste Attraktion kaufen. Wechsel durch Wischen zum rechten Menü und kaufe ein Karussell.",

View file

@ -11,6 +11,7 @@
"AppliedUpgrades": "Active Upgrades", "AppliedUpgrades": "Active Upgrades",
"Options": "Options", "Options": "Options",
"RainingTicketLimit": "Max Raining Tickets", "RainingTicketLimit": "Max Raining Tickets",
"SoundVolume": "Sound Volume",
"----- Tutorial -----": "", "----- Tutorial -----": "",
"Tutorial1": "Hi! Welcome to Touchy Tickets. To start the game, simply tap the ticket booth to sell a <i ticket>. Start by racking up 50<i ticket>!", "Tutorial1": "Hi! Welcome to Touchy Tickets. To start the game, simply tap the ticket booth to sell a <i ticket>. Start by racking up 50<i ticket>!",
"Tutorial2": "Great! Now, you can buy your first attraction. Access the menu on the right by swiping and purchase a carousel.", "Tutorial2": "Great! Now, you can buy your first attraction. Access the menu on the right by swiping and purchase a carousel.",

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,5 +1,6 @@
using System.IO; using System.IO;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using Microsoft.Xna.Framework.Audio;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace TouchyTickets { namespace TouchyTickets {
@ -10,6 +11,15 @@ namespace TouchyTickets {
[DataMember] [DataMember]
public int RainingTicketLimit = 300; public int RainingTicketLimit = 300;
[DataMember]
public float SoundVolume {
get => this.soundVolume;
set {
this.soundVolume = value;
SoundEffect.MasterVolume = value;
}
}
private float soundVolume = 1;
public static void Save() { public static void Save() {
var file = GetOptionsFile(true); var file = GetOptionsFile(true);

View file

@ -6,7 +6,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Coroutine" Version="2.0.0" /> <PackageReference Include="Coroutine" Version="2.0.0" />
<PackageReference Include="MLEM.Startup" Version="4.0.0-221" /> <PackageReference Include="MLEM.Startup" Version="4.0.0-225" />
<PackageReference Include="MonoGame.Framework.Portable" Version="3.7.1.189"> <PackageReference Include="MonoGame.Framework.Portable" Version="3.7.1.189">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>

View file

@ -5,6 +5,7 @@ using System.Linq;
using System.Numerics; using System.Numerics;
using Coroutine; using Coroutine;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input.Touch; using Microsoft.Xna.Framework.Input.Touch;
using MLEM.Extensions; using MLEM.Extensions;
@ -30,6 +31,13 @@ namespace TouchyTickets {
public Ui(UiSystem uiSystem) { public Ui(UiSystem uiSystem) {
this.uiSystem = uiSystem; this.uiSystem = uiSystem;
this.uiSystem.Style.PanelTexture = this.uiSystem.Style.ScrollBarBackground = new NinePatch(Texture[2, 1], 4);
this.uiSystem.Style.ButtonTexture = this.uiSystem.Style.ScrollBarScrollerTexture = new NinePatch(Texture[3, 1], 4);
this.uiSystem.Style.ActionSound = new SoundEffectInfo(MlemGame.LoadContent<SoundEffect>("Sounds/Click"), 0.5F);
this.uiSystem.TextFormatter.AddImage("ticket", Texture[2, 0]);
this.uiSystem.TextFormatter.AddImage("star", Texture[3, 0]);
foreach (var modifier in AttractionModifier.Modifiers.Values)
this.uiSystem.TextFormatter.AddImage(modifier.Name, modifier.Texture);
// main ticket store ui // main ticket store ui
var rainingTickets = new List<RainingTicket>(); var rainingTickets = new List<RainingTicket>();
@ -119,6 +127,7 @@ namespace TouchyTickets {
OnPressed = e2 => this.FadeUi(false, () => this.uiSystem.Remove(e2.Root.Name)) OnPressed = e2 => this.FadeUi(false, () => this.uiSystem.Remove(e2.Root.Name))
}); });
infoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 30), Localization.Get("Remove")) { infoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 30), Localization.Get("Remove")) {
ActionSound = new SoundEffectInfo(MlemGame.LoadContent<SoundEffect>("Sounds/Place")),
OnPressed = e2 => { OnPressed = e2 => {
if (map.SelectedPosition == null) if (map.SelectedPosition == null)
return; return;
@ -161,6 +170,7 @@ namespace TouchyTickets {
OnPressed = e2 => this.FadeUi(false, () => this.uiSystem.Remove(e2.Root.Name)) OnPressed = e2 => this.FadeUi(false, () => this.uiSystem.Remove(e2.Root.Name))
}); });
yesNoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 30), Localization.Get("Place")) { yesNoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 30), Localization.Get("Place")) {
ActionSound = new SoundEffectInfo(MlemGame.LoadContent<SoundEffect>("Sounds/Place")),
OnPressed = e2 => { OnPressed = e2 => {
GameImpl.Instance.Tickets -= price; GameImpl.Instance.Tickets -= price;
GameImpl.Instance.Platform.AddResourceEvent(true, "Tickets", price, "Attraction", attraction.Key); GameImpl.Instance.Platform.AddResourceEvent(true, "Tickets", price, "Attraction", attraction.Key);
@ -224,6 +234,7 @@ namespace TouchyTickets {
OnPressed = e2 => this.FadeUi(false, () => this.uiSystem.Remove(e2.Root.Name)) OnPressed = e2 => this.FadeUi(false, () => this.uiSystem.Remove(e2.Root.Name))
}); });
var addButton = infoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 30), string.Empty) { var addButton = infoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 30), string.Empty) {
ActionSound = new SoundEffectInfo(MlemGame.LoadContent<SoundEffect>("Sounds/Place")),
OnPressed = e2 => { OnPressed = e2 => {
if (map.SelectedPosition == null) if (map.SelectedPosition == null)
return; return;
@ -300,6 +311,7 @@ namespace TouchyTickets {
upgradeHeader.AddChild(new Paragraph(Anchor.AutoCenter, 1, p => GameImpl.Instance.Stars + "<i star>", true) {TextScale = 0.3F}); upgradeHeader.AddChild(new Paragraph(Anchor.AutoCenter, 1, p => GameImpl.Instance.Stars + "<i star>", true) {TextScale = 0.3F});
upgradeHeader.AddChild(new Button(Anchor.AutoCenter, new Vector2(0.8F, 30), Localization.Get("EarnStar")) { upgradeHeader.AddChild(new Button(Anchor.AutoCenter, new Vector2(0.8F, 30), Localization.Get("EarnStar")) {
PositionOffset = new Vector2(0, 4), PositionOffset = new Vector2(0, 4),
ActionSound = new SoundEffectInfo(MlemGame.LoadContent<SoundEffect>("Sounds/StarBuy")),
OnUpdated = (e, time) => ((Button) e).IsDisabled = GameImpl.Instance.Tickets < GameImpl.Instance.GetStarPrice(), OnUpdated = (e, time) => ((Button) e).IsDisabled = GameImpl.Instance.Tickets < GameImpl.Instance.GetStarPrice(),
OnPressed = e => { OnPressed = e => {
var infoBox = new Group(Anchor.TopLeft, Vector2.One, false) { var infoBox = new Group(Anchor.TopLeft, Vector2.One, false) {
@ -356,6 +368,15 @@ namespace TouchyTickets {
Options.Save(); Options.Save();
} }
}); });
optionList.AddChild(new Paragraph(Anchor.AutoLeft, 1, p => Localization.Get("SoundVolume") + ": " + (int) (Options.Instance.SoundVolume * 100)));
optionList.AddChild(new Slider(Anchor.AutoLeft, new Vector2(1, 20), 10, 100) {
PositionOffset = new Vector2(0, 1),
CurrentValue = Options.Instance.SoundVolume * 100,
OnValueChanged = (s, v) => {
Options.Instance.SoundVolume = v / 100;
Options.Save();
}
});
this.uiSystem.Add("Options", optionsUi); this.uiSystem.Add("Options", optionsUi);
this.swipeRelations = new Element[] {optionsUi, upgradeUi, main, buyUi, modifierUi}; this.swipeRelations = new Element[] {optionsUi, upgradeUi, main, buyUi, modifierUi};
@ -418,13 +439,7 @@ namespace TouchyTickets {
uiSystem.AutoScaleWithScreen = true; uiSystem.AutoScaleWithScreen = true;
uiSystem.AutoScaleReferenceSize = new Point(720, 1280); uiSystem.AutoScaleReferenceSize = new Point(720, 1280);
uiSystem.Style.Font = new GenericSpriteFont(MlemGame.LoadContent<SpriteFont>("Fonts/Regular")); uiSystem.Style.Font = new GenericSpriteFont(MlemGame.LoadContent<SpriteFont>("Fonts/Regular"));
uiSystem.Style.PanelTexture = uiSystem.Style.ScrollBarBackground = new NinePatch(Texture[2, 1], 4);
uiSystem.Style.ButtonTexture = uiSystem.Style.ScrollBarScrollerTexture = new NinePatch(Texture[3, 1], 4);
uiSystem.Style.TextScale = 0.1F; uiSystem.Style.TextScale = 0.1F;
uiSystem.TextFormatter.AddImage("ticket", Texture[2, 0]);
uiSystem.TextFormatter.AddImage("star", Texture[3, 0]);
foreach (var modifier in AttractionModifier.Modifiers.Values)
uiSystem.TextFormatter.AddImage(modifier.Name, modifier.Texture);
} }
public static IEnumerator<Wait> DisplaySplash(Action loadGame) { public static IEnumerator<Wait> DisplaySplash(Action loadGame) {
@ -533,6 +548,7 @@ namespace TouchyTickets {
SetHeightBasedOnChildren = true, SetHeightBasedOnChildren = true,
PositionOffset = new Vector2(0, 1), PositionOffset = new Vector2(0, 1),
ChildPadding = new Vector2(4), ChildPadding = new Vector2(4),
ActionSound = new SoundEffectInfo(MlemGame.LoadContent<SoundEffect>("Sounds/StarBuy")),
OnPressed = e => { OnPressed = e => {
GameImpl.Instance.Stars -= upgrade.Price; GameImpl.Instance.Stars -= upgrade.Price;
GameImpl.Instance.Platform.AddResourceEvent(true, "Stars", upgrade.Price, "Upgrade", upgrade.Name); GameImpl.Instance.Platform.AddResourceEvent(true, "Stars", upgrade.Price, "Upgrade", upgrade.Name);