Edit:
If someone wants to check the full code, the repository is this:
https://github.com/CartridgeSoft/game-e … testBranch
Hi. So Im trying to create a dialog class to send story mesages, object descriptions etc for my game. The dialog class works... more or less, but I can't separate the dialog thing of the player actions ive tried several things, googled a bit but sighted people usually uses sprite fonts to draw text. Here is my code, if Anyone can help i will be very grateful.
I will put the dialog class and the object class wich is the clas im trying to make work
this is the actually dialog clas. For some reason when y try to use the clas, the game crashes.
using DavyKager;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
namespace Game3
{
public class DialogBox
{
public Map Map
{
get { return map; }
}
Map map;
public ISoundEngine engine = new ISoundEngine();
public bool IsInDialog;
KeyboardState keystate = Keyboard.GetState();
public DialogBox(Map map)
{
this.map = map;
Tolk.Load();
}
public void dlg(string message)
{
Tolk.Speak(message, true);
engine.Play2D("sounds/UI/menuback.mp3");
while (true)
{
if (Input.WasKeyPressed(Keys.E))
{
Tolk.Speak(message, true);
}
else if (Input.WasKeyPressed(Keys.Enter))
{
engine.Play2D("sounds/UI/menuconfirm.mp3");
break;
}
}
}
}
}
now the object class:
public class Object
{
public Map Map
{
get { return map; }
}
Map map;
public int x, y, z;
public string name;
public bool IsInteractable;
public Object(Map map, int ox, int oy, int oz, string oname, bool interactable=false)
{
this.map = map;
this.x = ox;
this.y = oy;
this.z = oz;
this.name = oname;
this.IsInteractable = interactable;
map.engine.Play3D("sounds/rooms/" + oname + ".mp3", ox, oy, oz, true);
}
public void Update(GameTime gameTime)
{
}
public void interact()
{
map.dialog.dlg("this is a"+name);
}
}
}