public WiiController(Game game, GameState gm, InputBuffer b) : base(game, gm, b) { wm = new WiimoteLib.Wiimote(); wm.Connect(); wm.SetReportType(WiimoteLib.InputReport.IRAccel, WiimoteLib.IRSensitivity.Maximum, true); }
public WorldMapController(GameEngine g, GameState gm, SpriteBatch sb, InputBuffer bf) { game = g; gameState = gm; worldView = new WorldMapView(sb); spriteBatch = sb; buffer = bf; MediaPlayer.IsRepeating = true; }
public SatisfactionQueue(InputBuffer b) { queue = new Satisfaction[MAX_IN_QUEUE]; head = 0; tail = -1; queueSize = 0; for (int ii = 0; ii < MAX_IN_QUEUE; ii++) { queue[ii] = new Satisfaction(); } origin = new Vector2(); maxAge = MAX_AGE; buf = b; }
/// <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() { spriteBatch = new SpriteBatch(GraphicsDevice); buffer = new InputBuffer(); gameState = new GameState(); gameState.LoadContent(Content); // hack try { input = new WiiController(this, gameState, buffer); } catch (WiimoteLib.WiimoteNotFoundException) { input = new MouseController(this, gameState, buffer); } Services.AddService(typeof(GameState), gameState); menuController = new MenuController(this, gameState, spriteBatch); menuController.Initialize(); levelController = new LevelSelectController(gameState, spriteBatch); levelController.Initialize(); playlevel = new PlayLevel(this, gameState, spriteBatch, buffer); playlevel.Initialize(); worldController = new WorldMapController(this, gameState, spriteBatch, buffer); worldController.Initialize(); gameState.world = worldController; pauseController = new PauseScreenController(this, spriteBatch); pauseController.Initialize(); Components.Add(new GamerServicesComponent(this)); Components.Add(new Components.SaveManager(this)); Components.Add(new BatonView(this, spriteBatch)); base.Initialize(); }
public PlayLevel(Game g, GameState gm, SpriteBatch sb, InputBuffer buf) : base(g) { gameState = gm; actionList = new LinkedList<Movement>(); drawSet = new HashSet<Movement>(); buffer = buf; spriteBatch = sb; DrawOrder = 0; comboOn = false; comboCount = -1; started = false; failed = false; ended = false; failCount = 0; volume = 5; scaledVol = (float)(0.524 * Math.Pow(Math.E, volume / 10) - 0.425); BrokenStrings = new SoundEffect[3]; }
public MouseController(Game game, GameState gm, InputBuffer b) : base(game, gm, b) { }
public InputController(Game game, GameState gm, InputBuffer b) : base(game) { buffer = b; gameState = gm; }
/** public bool Timing(InputBuffer inputs, Point p, bool start) { if (inputs.Count != 0) { Vector2 coords = new Vector2(p.X, GameEngine.HEIGHT - p.Y); Vector2 pos = (start ? inputs[0].Position : inputs[inputs.Count - 1].Position); // Console.WriteLine("coords is " + coords); // Console.WriteLine("pos is " + pos); // Console.WriteLine("difference in pos is " + Vector2.Distance(coords, pos)+"\n"); return Vector2.Distance(coords, pos) <= 100; } else { return false; } } */ /*Returns a floating number 0 to 1 which indicates how well the input is matching the movement */ public float Accuracy(Movement m, InputBuffer inputs, GameTime t) { int totalInput = inputs.Count; int correct = 0; if (CurrentMovement != null) { switch (CurrentMovement.myType) { case Movement.Types.Noop: return (totalInput > 20 ? -0.5f : 0.0f); case Movement.Types.Shake: if (totalInput < 20) { return 0.0f; } else { foreach (InputState state in inputs) { if (Math.Abs(state.Acceleration.X) > ACC_THRESHOLD || Math.Abs(state.Acceleration.Y) > ACC_THRESHOLD) { correct++; } } return (float)correct / totalInput / 2; } case Movement.Types.Wave: if (totalInput < 5) { return -0.3f; } else { Vector2 startPos = new Vector2(CurrentMovement.startCoordinate.X, CurrentMovement.startCoordinate.Y); Vector2 endPos = new Vector2(CurrentMovement.endCoordinate.X, CurrentMovement.endCoordinate.Y); float DIST_THRESHOLD = 0.55f * Vector2.Distance(startPos, endPos); Vector2[] slopes = CurrentMovement.f.Slope(totalInput - 1); float errorSum = 0.0f; float dist = Vector2.Distance(inputs[totalInput - 1].Position, inputs[0].Position); if (dist >= DIST_THRESHOLD) { for (int i = 1; i < totalInput; i++) { Vector2 normVel = Vector2.Normalize(inputs[i].Velocity); Vector2 slope = slopes[i]; errorSum += (normVel.X - slope.X) * (normVel.X - slope.X) + (normVel.Y - slope.Y) * (normVel.Y - slope.Y); } float rmsError = (float)Math.Sqrt((double)errorSum / (double)(totalInput - 1)); float accuracy = (1 - rmsError * MAGIC_WAVE_THRESHOLD); return (accuracy > FAIL_THRESHOLD ? accuracy : -0.3f); } else { return -0.3f; } } default: return 0.0f; } } else { return 0.0f; } }