public ProtagonistsAnimation(Simulator simulator, Mothership mothership) { Simulator = simulator; Mothership = mothership; Protagonist = new SpaceshipCursor(simulator.Scene, new Vector3(-200, -600, 0), 5, VisualPriorities.Cutscenes.IntroProtagonist, new Color(95, 71, 255), "Cursor1", true); Wife = new SpaceshipCursor(Simulator.Scene, new Vector3(-200, -600, 0), 5, VisualPriorities.Cutscenes.IntroWife, new Color(255, 0, 136), "Cursor2", true); Protagonist.FadeIn(); Wife.FadeIn(); ProtagonistText = new ManualTextBubble(Simulator.Scene, new Text("I must warn the\n\nother colonies!", @"Pixelite") { SizeX = 2 }, Protagonist.Position, VisualPriorities.Cutscenes.IntroProtagonist - 0.00001) { Alpha = 0 }; State = ProtagonistState.None; TimeBeforeArrival = IntroCutscene.Timing["ProtagonistIn"]; TimeBeforeAbduction = TimeBeforeArrival + 20000; TimeBeforeGoGetHelp = TimeBeforeAbduction + 4000; TimeBeforeFireAgainAtMothership = TimeBeforeGoGetHelp + 2000; TimeBeforeGoInCenter = TimeBeforeFireAgainAtMothership + 18000; TimeBeforeWarnColonies = TimeBeforeGoInCenter + 20000; TimeBeforeTeleport = TimeBeforeWarnColonies + 10000; PathArrivalProtagonist = GetPathArrivalProtagonist(); PathArrivalWife = GetPathArrivalWife(); TimeOnPathProtaAndWife = 0; }
/// <summary> /// Resets the state of the protagonist /// </summary> public void ResetGame() { Position = initialPosition; RectangleBounds = new BoundingRectangle(initialPosition, idleWidth, idleHeight); Shift = false; SpeedMultiplier = 1; Status = ProtagonistState.Idle; }
/// <summary> /// Updates the keyboard state of the game /// </summary> /// <param name="gameTime"></param> public void Update(GameTime gameTime) { //base state of Input priorKeyboardState = currentKeyboardState; currentKeyboardState = Keyboard.GetState(); Status = ProtagonistState.Idle; Attacking = false; Shift = false; //Check inputs if (PressingLeft() && !PressingRight()) { Flipped = true; Status = ProtagonistState.Walking; } if (PressingRight() && !PressingLeft()) { Flipped = false; Status = ProtagonistState.Walking; } if (PressingUp()) { JumpStatus = JumpState.Jumping; } if (PressingDown()) { JumpStatus = JumpState.Falling; } //Attacking if (PressingSpace()) { Status = ProtagonistState.Attacking; } //Holding Shift if (PressingShift()) { Shift = true; } //Exit game if (currentKeyboardState.IsKeyDown(Keys.Escape)) { Exit = true; } }
/// <summary> /// The Update method to move, jump, ...etc /// the protagonist sprite /// </summary> /// <param name="gameTime">the game time</param> /// <param name="movement">enum which direction we need to move</param> /// <param name="moving">to help animate the character sprite</param> /// <param name="flipTexture">to help animate the character sprite</param> /// <param name="jumping">determines if we are actively holding the up key</param> /// <param name="attacking">determines if we are pressing the attack key</param> /// <param name="pressingShift">determines if we are pressing the shift key</param> public void Update(GameTime gameTime, ProtagonistState status, JumpState jumpStatus, bool flipTexture, bool pressingShift, bool onPlatform, bool stopLeftMovement, bool stopRightMovement, bool stopJump, bool stopFall, bool stopMoving) { #region Load in Updates //Update state of protagonist Status = status; Flipped = flipTexture; JumpStatus = jumpStatus; Shift = pressingShift; OnPlatform = onPlatform; #endregion if (stopMoving) { return; } //Horizontal Movements if (Status == ProtagonistState.Walking) { switch (Flipped) { case true: Position += -HorizontalVelocity * SpeedMultiplier; updateBounds(); break; case false: Position += HorizontalVelocity * SpeedMultiplier; updateBounds(); break; } } //Vertical Movements jumpingTimer += gameTime.ElapsedGameTime.TotalSeconds; //HandleJump //if (JumpStatus == JumpState.Jumping && OnPlatform && !stopJump) //{ // jump(gameTime); // //If we need to stop jumping // if(jumpingTimer > 3) // { // jumpingTimer = 0; // Jump = new Vector2(0, -150); // } // OnPlatform = false; //} //TODO: Determine if we want to always apply gravity //I don't think we should if (OnPlatform == false && JumpStatus == JumpState.Falling) { applyGravity(gameTime); } //We are falling, We landed, so keep the horizontal //Velocity, but reset gravity and jumping forces if (stopFall) { Velocity = new Vector2(Velocity.X, 0); } }
public void Update() { TimeBeforeArrival -= Preferences.TargetElapsedTimeMs; TimeBeforeAbduction -= Preferences.TargetElapsedTimeMs; TimeBeforeGoGetHelp -= Preferences.TargetElapsedTimeMs; TimeBeforeFireAgainAtMothership -= Preferences.TargetElapsedTimeMs; TimeBeforeGoInCenter -= Preferences.TargetElapsedTimeMs; TimeBeforeWarnColonies -= Preferences.TargetElapsedTimeMs; TimeBeforeTeleport -= Preferences.TargetElapsedTimeMs; switch (State) { case ProtagonistState.None: if (TimeBeforeArrival < 0) State = ProtagonistState.Arrival; break; case ProtagonistState.Arrival: DoArrival(); if (TimeBeforeAbduction < 0) { DoAbduction(); State = ProtagonistState.Abduction; } break; case ProtagonistState.Abduction: if (TimeBeforeGoGetHelp < 0) { DoGoGetHelp(); State = ProtagonistState.GoGetHelp; } break; case ProtagonistState.GoGetHelp: if (TimeBeforeFireAgainAtMothership < 0) { DoFireAgainAtMothership(); State = ProtagonistState.FireAgainAtMothership; } break; case ProtagonistState.FireAgainAtMothership: if (TimeBeforeGoInCenter < 0) { DoGoInCenter(); State = ProtagonistState.GoInCenter; } break; case ProtagonistState.GoInCenter: if (TimeBeforeWarnColonies < 0) { DoWarnColonies(); State = ProtagonistState.WarnColonies; } break; case ProtagonistState.WarnColonies: if (TimeBeforeTeleport < 0) { DoTeleport(); State = ProtagonistState.Teleport; } break; } ProtagonistText.Position = Protagonist.Position; ProtagonistText.Update(); }