Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Money sound effect in some situations #345

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions WZIMopoly/Content/Content.mgcb
Original file line number Diff line number Diff line change
Expand Up @@ -3843,3 +3843,9 @@
/processorParam:Quality=Best
/build:Sounds/Dice.mp3

#begin Sounds/Money.wav
/importer:WavImporter
/processor:SoundEffectProcessor
/processorParam:Quality=Best
/build:Sounds/Money.wav

Binary file added WZIMopoly/Content/Sounds/Money.wav
Binary file not shown.
19 changes: 18 additions & 1 deletion WZIMopoly/Controllers/GameScene/TileController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using WZIMopoly.GUI.GameScene;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using WZIMopoly.GUI;
using WZIMopoly.GUI.GameScene;
using WZIMopoly.Models.GameScene;

namespace WZIMopoly.Controllers.GameScene
Expand All @@ -23,6 +26,20 @@ internal abstract class TileController : Controller<TileModel, GUITile>
/// </param>
protected TileController(TileModel model, GUITile view)
: base(model, view) { }

/// <summary>
/// Gets the sound effect of the money.
/// </summary>
// It is a temporary solution, because the deadline is coming
// and code is not adapted for playing sound effects.
public static SoundEffect MoneySound { get; private set; }

/// <inheritdoc/>
public override void Load(ContentManager content)
{
base.Load(content);
MoneySound ??= content.Load<SoundEffect>("Sounds/Money");
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Xml;
using WZIMopoly.Controllers.GameScene;

namespace WZIMopoly.Models.GameScene.TileModels
{
Expand All @@ -26,7 +27,11 @@ internal class ConditionalPassTileModel : TileModel
internal ConditionalPassTileModel(int id, int tax) : base(id)
{
Tax = tax;
OnStand += (player) => player.Money -= Tax;
OnStand += (player) =>
{
player.Money -= Tax;
TileController.MoneySound.Play();
};
}

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions WZIMopoly/Models/GameScene/TileModels/StartTileModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Xml;
using WZIMopoly.Controllers.GameScene;

namespace WZIMopoly.Models.GameScene.TileModels
{
Expand Down Expand Up @@ -54,6 +55,7 @@ public static StartTileModel LoadFromXml(XmlNode node)
void ICrossable.OnCross(PlayerModel player)
{
player.Money += _reward;
TileController.MoneySound.Play();
}
}
}
2 changes: 2 additions & 0 deletions WZIMopoly/Models/GameScene/TileModels/SubjectTileModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using WZIMopoly.Controllers.GameScene;
using WZIMopoly.Enums;
using WZIMopoly.Utils;

Expand Down Expand Up @@ -64,6 +65,7 @@ internal SubjectTileModel(int id, int price, int upgradedPrice, Dictionary<Subje
if (Owner != null && !player.Equals(Owner))
{
player.TransferMoneyTo(Owner, TaxPrices[Grade]);
TileController.MoneySound.Play();
}
};
}
Expand Down