/// <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) { // Allows the game to exit KeyboardState kb = Keyboard.GetState(); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || kb.IsKeyDown(Keys.Escape)) { this.Exit(); } if (kb.IsKeyDown(Keys.Space) && !oldKb.IsKeyDown(Keys.Space)) { int temp = (int)state; temp++; temp %= 4; state = (SubjectState)temp; } if (kb.IsKeyDown(Keys.Enter) && !oldKb.IsKeyDown(Keys.Enter)) { int index = (int)state; subjectIsFlipped[index] = !subjectIsFlipped[index]; } oldKb = kb; base.Update(gameTime); }
/// <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() { // TODO: Add your initialization logic here state = SubjectState.CompSci; images = new SubjectImage[4][]; subjectIsFlipped = new bool[4]; base.Initialize(); }
public ConcreteSubject(SubjectState subjectState) { SubjectState = subjectState; }
public Subject(Point loc, Bitmap refPikcher, SubjectState state) { Location = loc; subState = state; pikcher = refPikcher; }
public void TransitionTo(SubjectState state) { SubjectState = state; SubjectState.SetContext(this); }
public CourseAdminContext(SubjectState state) { this.TransitionTo(state); }
public TeacherContext(SubjectState state) { this.TransitionTo(state); }
public void Update(SubjectState subjectState) { SubjectState = subjectState; }
public void CourseAdminGivenValidState_Action_TransitionsToCorrectState(CourseAdminContext contextInstance, Action contextAction, SubjectState expectedState) { contextAction.Invoke(); var state = contextInstance.SubjectState; var theType = expectedState.GetType(); Assert.IsType(theType, state); }