Jag behöver hjälp med min kod. Den vill inte fungera. C# XNA
Jag har gjort en kod med två olika klasser. Första klassen ska kolla vad du skriver och sedan spara det värdet i en string. Det ska fungera som en "fuskmeny".
Den andra klassen kollar vilken dag och månad det är. Den ska sedan byta bana beroende på vilket datum det är men jag har inte gjort det än. Problemet är att inget verka fungera. Jag har inga errors men de breakpoints jag har lagt ut fungerar inte. Jag skulle gärna vilja ha hjälp eftersom jag inte förstår vad som är fel.
Här är Koden
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace Sequence_cheat_test
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
public Cheat Fusk;
public DateMap DateMap;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
Fusk = new Cheat();
DateMap = new DateMap();
// TODO: Add your initialization logic here
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// all content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
#region BasicControls
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
#endregion
DateMap.Update();
Fusk.Update();
// TODO: Add your update logic here
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
base.Draw(gameTime);
}
}
}using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace Sequence_cheat_test
{
public class Cheat : Microsoft.Xna.Framework.Game
{
#region Cheats
int BallSizeX = 10;
int BallSizeY = 10;
int BallMoveY = 10;
int BallMoveX = 10;
public string text = "";
public bool PauseMenu = false;
int Counter = 300;
Keys[] oldkeys = new Keys[0];
#endregion
public Cheat()
{
}
public void Update()
{
#region Check
KeyboardState keystate = Keyboard.GetState();
Keys[] pressedKeys;
pressedKeys = keystate.GetPressedKeys();
for (int i = 0; i < pressedKeys.Length; i++)
{
bool foundIt = false;
for (int j = 0; j < oldkeys.Length; j++)
{
if (pressedKeys[i] == oldkeys[j])
{
foundIt = true;
break;
}
}
if (foundIt == false)
{
string keyString = "";
switch (pressedKeys[i])
{
case Keys.Space:
keyString = " ";
break;
case Keys.OemPeriod:
keyString = ".";
break;
case Keys.Enter:
keyString = "\n";
break;
default:
keyString = pressedKeys[i].ToString();
break;
}
text = text + keyString;
Console.WriteLine(text);
}
}
#endregion
#region Timer
Counter--;
if (Counter == 0)
{
text = "";
Counter = 300;
}
#endregion
#region Cheats
oldkeys = pressedKeys;
if (text == "FUSK")
{
Console.Beep(676, 460);
text = "";
}
if (text == "SPEED")
{
if (BallMoveX == 10 && BallMoveY == 10)
{
BallMoveX = 40;
BallMoveY = 40;
}
if (BallMoveX == 40 && BallMoveY == 40)
{
BallMoveX = 10;
BallMoveY = 10;
}
text = "";
}
if (text == "HUGE")
{
if (BallSizeX == 10 && BallSizeY == 10)
{
BallSizeX = 400;
BallSizeY = 400;
}
if (BallSizeX == 400 && BallSizeY == 400)
{
BallSizeX = 10;
BallSizeY = 10;
}
}
if (text == "SMALL")
{
if (BallSizeX == 10 && BallSizeY == 10)
{
BallSizeX = 1;
BallSizeY = 1;
}
if (BallSizeX == 1 && BallSizeY == 1)
{
BallSizeX = 10;
BallSizeY = 10;
}
}
#endregion
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace Sequence_cheat_test
{
public class DateMap : Microsoft.Xna.Framework.Game
{
#region DateMap
string Datemap = System.DateTime.Now.Date.Month.ToString() + System.DateTime.Now.Date.Day.ToString();
#endregion
public DateMap()
{
}
public void Update()
{
#region DateMap
if (Datemap == "1224")
{
Exit();
}
if (Datemap == "1031")
{
//Map = "Halloween";
}
#endregion
}
}
}