public override void Draw(SpriteBatch spriteBatch) { foreach (Bullet bullet in bullets) { bullet.Draw(spriteBatch); } base.Draw(spriteBatch); if (TurretAnim != null) { if (turretShowOnAttack) { if (showTurret) { TurretAnim.Draw(spriteBatch); } } else { TurretAnim.Draw(spriteBatch); } } }
public override void Draw(SpriteBatch spriteBatch) { if (isDead) { currentAnimation.Draw(spriteBatch, Position, 0.0f, Vector2.Zero, Game1.SCALE); currentHandAnimation.Draw(spriteBatch, Position, 0.0f, Vector2.Zero, Game1.SCALE); return; } shadow.Draw(spriteBatch); currentAnimation.Draw(spriteBatch, Position, 0.0f, Vector2.Zero, Game1.SCALE); base.Draw(spriteBatch); currentHandAnimation.Draw(spriteBatch, Position, 0.0f, Vector2.Zero, Game1.SCALE); }
public void Draw(SpriteBatch spriteBatch) { _spriteAnim.SetScale(_size); _spriteAnim.SetRotation(_rotation, _centerOfRotation); _spriteAnim.SetPos(_position); _spriteAnim.Draw(spriteBatch); }
public override void Draw(SpriteBatch spriteBatch, GameTime gameTime) { if (_dayNightCycle.IsNight) { _animation.Draw(spriteBatch, Position); } }
public void DrawSpook(SpriteBatch sb, Vector2 cameraOffset) { if (_showSpook) { spookAnim.Draw(sb, spookFrame, SPOOK_MAIN_OFFSET + cameraOffset); } }
/// <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) { MousePosition = Mouse.GetState().Position; GraphicsDevice.Clear(Color.Chocolate); Camera.Pos = Player.GetPosition(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, Camera.GetTransformation()); movePointer.Draw(spriteBatch); Noms.ForEach(nom => nom.Draw(spriteBatch)); #if DEBUG DebugDraw(); #endif var pos = Mouse.GetState().Position.ToVector2() + Camera.TopLeftPos; cursor.SetPos(pos); cursor.Draw(spriteBatch); spriteBatch.End(); #if DEBUG var transform = Matrix.CreateOrthographicOffCenter( ConvertUnits.ToSimUnits(Camera.TopLeftPos.X), ConvertUnits.ToSimUnits(Camera.TopLeftPos.X + GraphicsDevice.Viewport.Width), ConvertUnits.ToSimUnits(Camera.TopLeftPos.Y + GraphicsDevice.Viewport.Height), ConvertUnits.ToSimUnits(Camera.TopLeftPos.Y), 0f, 1f); DebugView.RenderDebugData(ref transform); #endif base.Draw(gameTime); }
public void Draw(SpriteBatch spriteBatch, GameTime gameTime) { if (IsAlive) { if (State == TrexState.Idle) { idleBackgroundSprite.Draw(spriteBatch, Position); _blinkAnimation.Draw(spriteBatch, Position); } else if (State == TrexState.Jumping || State == TrexState.Falling) { _idleSprite.Draw(spriteBatch, Position); } else if (State == TrexState.Running) { _runAnimation.Draw(spriteBatch, Position); } else if (State == TrexState.Ducking) { _duckAnimation.Draw(spriteBatch, Position); } } else { _deathSprite.Draw(spriteBatch, Position); } //spriteBatch.Draw(ShowHitBox, new Vector2(HitBox.X, HitBox.Y), Color.White); }
public void TestQueue() { var spriteComp = CreateSpriteComponent(20); // check queue before play SpriteAnimation.Queue(spriteComp, 1, 3, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(0))); Assert.Equal(1, spriteComp.CurrentFrame); // check queue sequence SpriteAnimation.Queue(spriteComp, new[] { 5, 9, 4 }, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Queue(spriteComp, new[] { 6 }, AnimationRepeatMode.LoopInfinite, 1); SpriteAnimation.Queue(spriteComp, new[] { 7 }, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2))); Assert.Equal(3, spriteComp.CurrentFrame); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1))); Assert.Equal(5, spriteComp.CurrentFrame); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2))); Assert.Equal(4, spriteComp.CurrentFrame); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1))); Assert.Equal(6, spriteComp.CurrentFrame); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10))); Assert.Equal(6, spriteComp.CurrentFrame); }
public void TestPauseResume() { var spriteComp = CreateSpriteComponent(15); SpriteAnimation.Play(spriteComp, 0, 10, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Pause(spriteComp); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2))); Assert.Equal(0, spriteComp.CurrentFrame); SpriteAnimation.Play(spriteComp, 0, 10, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2))); Assert.Equal(2, spriteComp.CurrentFrame); SpriteAnimation.Pause(spriteComp); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2))); Assert.Equal(2, spriteComp.CurrentFrame); SpriteAnimation.Resume(spriteComp); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2))); Assert.Equal(4, spriteComp.CurrentFrame); }
public void Draw(SpriteBatch spriteBatch, GameTime gameTime) { if (IsAlive) { if (State == TRexState.Idle) { _idleBackgroundSprite.Draw(spriteBatch, Position); _blinkAnimation.Draw(spriteBatch, Position); } else if (State == TRexState.Jumping || State == TRexState.Falling) { _idleSprite.Draw(spriteBatch, Position); } else if (State == TRexState.Running) { _runAnimation.Draw(spriteBatch, Position); } else if (State == TRexState.Ducking) { _duckAnimation.Draw(spriteBatch, Position); } } else { _deadSprite.Draw(spriteBatch, Position); } }
public void Draw(SpriteBatch spriteBatch, GameTime gameTime) { if (State == TrexState.Idle) { _idleBackgroundSprite.Draw(spriteBatch, Position); _blinkAnimation.Draw(spriteBatch, Position); } }
public override void Draw(SpriteBatch spriteBatch) { switch (_state) { case State.Idle: _flyingAnimation.TimeBetweenFrames = 400; _flyingAnimation.Draw(spriteBatch, Position, _isDirectionLeft); break; case State.Moving: _flyingAnimation.TimeBetweenFrames = 200; _flyingAnimation.Draw(spriteBatch, Position, _isDirectionLeft); break; case State.Dead: spriteBatch.Draw(_deadTexture, Position, Color.White); break; } }
public override void Draw(GameTime gameTime) { SB.Begin(); //------------------------------------- paddleSprite.Draw(SB, 300, 200, 500, 300); //------------------------------------- SB.End(); base.Draw(gameTime); }
public void Draw(SpriteBatch spriteBatch, GameTime gameTime) { if (State == TrexState.Idle) { _idleTrexBackgroundSprite.Draw(spriteBatch, this.Position); _blinkAnimation.Draw(spriteBatch, Position); } else if (State == TrexState.Jumping || State == TrexState.Falling) { _idleSprite.Draw(spriteBatch, Position); } }
private void DrawAnimations(SpriteBatch spriteBatch) { if (teleporting) { teleportOutAnimation.Draw(spriteBatch, newPosition, 0.0f, Vector2.Zero, Game1.SCALE); handTeleportOutAnimation.Draw(spriteBatch, newPosition, 0.0f, Vector2.Zero, Game1.SCALE); } else if (inIceBlock) { iceBlockAnimation.Draw(spriteBatch, Position, 0.0f, Vector2.Zero, Game1.SCALE); } }
public override void Draw(GameTime gameTime) { spriteBatch.Begin(); spriteBatch.Draw(background, new Rectangle(0, 0, 1280, 720), Color.White); spriteBatch.DrawString(font, "Lifts: " + Constants.numberOfDumbbells, new Vector2(400, 10), Color.Red); dumbbellAnimation.Draw(spriteBatch); #region Tamer Avatar +bubble box draw spriteBatch.Draw(avatar, new Rectangle(10, 400, avatar.Width * 2, avatar.Height * 2), Color.White); spriteBatch.Draw(bubbleBox, new Rectangle(avatar.Width, 380, bubbleBox.Width, bubbleBox.Height * 2), Color.White); #endregion playScreen.bar.Draw(spriteBatch); spriteBatch.End(); base.Draw(gameTime); }
public void TestStop() { var spriteComp = CreateSpriteComponent(20); SpriteAnimation.Play(spriteComp, 0, 1, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1))); Assert.Equal(1, spriteComp.CurrentFrame); // check that is it correctly updated by default SpriteAnimation.Stop(spriteComp); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1))); Assert.Equal(1, spriteComp.CurrentFrame); // check that current frame does not increase any more SpriteAnimation.Play(spriteComp, 2, 3, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(0))); Assert.Equal(2, spriteComp.CurrentFrame); // check that frame is correctly set to first animation frame SpriteAnimation.Play(spriteComp, 2, 3, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Queue(spriteComp, 5, 6, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(0))); Assert.Equal(2, spriteComp.CurrentFrame); // check that is it correctly updated by default SpriteAnimation.Stop(spriteComp); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2))); Assert.Equal(2, spriteComp.CurrentFrame); // check that queue is correctly reset SpriteAnimation.Play(spriteComp, 2, 3, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(3))); Assert.Equal(3, spriteComp.CurrentFrame); // check that queue is correctly reset SpriteAnimation.Stop(spriteComp); SpriteAnimation.Queue(spriteComp, 5, 6, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(0))); Assert.Equal(5, spriteComp.CurrentFrame); // check that indices are correctly reseted during stop }
public void Draw(SpriteBatch spriteBatch) { if (_isVisible) { switch (_state) { case PlayerState.Idle: _idleSprite.Draw(spriteBatch, _position, isDirectionBack); break; case PlayerState.Jump: _jumpSprite.Draw(spriteBatch, _position, isDirectionBack); break; case PlayerState.Run: _runAnimation.Draw(spriteBatch, _position, isDirectionBack); break; } } }
public void Draw(GameTime gameTime, SpriteBatch sb) { if (State != UIState.Office) { return; } Vector2 shake = Vector2.Zero; if (Level.IsJumpscaring && Level.Monsters.currentJumpscarer.ShakesOnJumpscare) { shake = Level.jumpscareShakeOffset; } officeSprites["Entry"].Draw(sb, CameraOffset + ENTRY_OFFSET + shake); Level.Monsters.BBB.DrawSpook(sb, CameraOffset + shake); Level.Monsters.Flumpty.DrawSpook(sb, CameraOffset + shake); Level.Monsters.Eyesaur.DrawSpook(sb, CameraOffset + shake); if (IsLightOn) { // Only light on office is drawn from center Vector2 mainOffset = new Vector2(-MAX_CAMERA_OFFSET / 2.0f, 0); officeSprites["Main"].Draw(sb, Level.Main.WindowCenter + mainOffset + CameraOffset + shake); officeVentAnim.Draw(sb, _ventAnimProgress, VENT_OFFSET + CameraOffset + shake); if (Vent == VentState.Left) { officeSprites["VentOnL"].Draw(sb, BUTTON_LEFT_OFFSET + CameraOffset + shake); } else { officeSprites["VentOnR"].Draw(sb, BUTTON_RIGHT_OFFSET + CameraOffset + shake); } recordSprites[_recordAnimProgress.ToString()].Draw(sb, RECORD_OFFSET + CameraOffset + shake); if (IsWormholeOpen) { officeSprites["Wormhole"].Draw(sb, WORMHOLE_OFFSET + CameraOffset + shake); } if (IsPigletCreepier) { officeSprites["CreepyPiglet"].Draw(sb, CREEPY_PIGLET_OFFSET + CameraOffset + shake); } } else { officeSprites["Dark"].Draw(sb, CameraOffset + shake); if (Vent == VentState.Left) { officeSprites["DarkVentOnL"].Draw(sb, BUTTON_DARK_LEFT_OFFSET + CameraOffset + shake); } else { officeSprites["DarkVentOnR"].Draw(sb, BUTTON_DARK_RIGHT_OFFSET + CameraOffset + shake); } } Level.Monsters.Clown.DrawSpook(sb, CameraOffset + shake); Level.Monsters.GoldenFlumpty.DrawInOffice(sb, CameraOffset + shake); if (muteIntroInput.IsEnabled) { Level.gameUISprites["MuteSongButton"].Draw(sb, MUTE_INTRO_INPUTBOX.TopLeft); } if (Level.CHEAT_MapDebug && !Level.IsJumpscaring) { Level.gameUISprites["Map"].Draw(sb, Laptop.MAP_OFFSET, Util.MakeTransparency(120), Vector2.One); Level.Monsters.DrawOnLaptop(sb); } }
public override void Draw(SpriteBatch spriteBatch, GameTime gameTime) { _animation.Draw(spriteBatch, Position); }
/// <summary> /// Draws the specified sprite batch. /// </summary> /// <param name="spriteBatch">The sprite batch.</param> /// <param name="font">The font.</param> public void Draw(SpriteBatch spriteBatch, SpriteFont font) { spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); Vector2 firstSquare = new Vector2(Camera.Location.X / Tile.TileStepX, Camera.Location.Y / Tile.TileStepY); int firstX = (int)firstSquare.X; int firstY = (int)firstSquare.Y; Vector2 squareOffset = new Vector2(Camera.Location.X % Tile.TileStepX, Camera.Location.Y % Tile.TileStepY); int offsetX = (int)squareOffset.X; int offsetY = (int)squareOffset.Y; float maxdepth = ((myMap.MapWidth + 1) + ((myMap.MapHeight + 1) * Tile.TileWidth)) * 10; float depthOffset; for (int y = 0; y < squaresDown; y++) { int rowOffset = 0; if ((firstY + y) % 2 == 1) { rowOffset = Tile.OddRowXOffset; } for (int x = 0; x < squaresAcross; x++) { int mapx = (firstX + x); int mapy = (firstY + y); depthOffset = 0.7f - ((mapx + (mapy * Tile.TileWidth)) / maxdepth); if ((mapx >= myMap.MapWidth) || (mapy >= myMap.MapHeight)) { continue; } foreach (int tileID in myMap.Rows[mapy].Columns[mapx].BaseTiles) { spriteBatch.Draw( Tile.TileSetTexture, Camera.WorldToScreen( new Vector2((mapx * Tile.TileStepX) + rowOffset, mapy * Tile.TileStepY)), Tile.GetSourceRectangle(tileID), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 1.0f); } int heightRow = 0; foreach (int tileID in myMap.Rows[mapy].Columns[mapx].HeightTiles) { spriteBatch.Draw( Tile.TileSetTexture, Camera.WorldToScreen( new Vector2( (mapx * Tile.TileStepX) + rowOffset, mapy * Tile.TileStepY - (heightRow * Tile.HeightTileOffset))), Tile.GetSourceRectangle(tileID), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, depthOffset - ((float)heightRow * heightRowDepthMod)); heightRow++; } foreach (int tileID in myMap.Rows[y + firstY].Columns[x + firstX].TopperTiles) { spriteBatch.Draw( Tile.TileSetTexture, Camera.WorldToScreen( new Vector2((mapx * Tile.TileStepX) + rowOffset, mapy * Tile.TileStepY)), Tile.GetSourceRectangle(tileID), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, depthOffset - ((float)heightRow * heightRowDepthMod)); } if (_showHelp) { spriteBatch.DrawString(font, (x + firstX).ToString() + ", " + (y + firstY).ToString(), new Vector2((x * Tile.TileStepX) - offsetX + rowOffset + baseOffsetX + 24, (y * Tile.TileStepY) - offsetY + baseOffsetY + 48), Color.White, 0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.0f ); } } } // Draw character Point mainCharacterStandingOn = myMap.WorldToMapCell(new Point((int)_mainCharacter.Position.X, (int)_mainCharacter.Position.Y)); int mainCharacterHeight = myMap.Rows[mainCharacterStandingOn.Y].Columns[mainCharacterStandingOn.X].HeightTiles.Count() * Tile.HeightTileOffset; _mainCharacter.Draw(spriteBatch, 0, -mainCharacterHeight); // Draw mouse highlight Vector2 hilightLoc = Camera.ScreenToWorld(new Vector2(Mouse.GetState().X, Mouse.GetState().Y)); Point hilightPoint = myMap.WorldToMapCell(new Point((int)hilightLoc.X, (int)hilightLoc.Y)); int hilightrowOffset = 0; if ((hilightPoint.Y) % 2 == 1) { hilightrowOffset = Tile.OddRowXOffset; } float originX = (hilightPoint.X * Tile.TileStepX) + hilightrowOffset; float originY = (hilightPoint.Y + 2) * Tile.TileStepY; List <Transformation> transformations = new List <Transformation> { new Transformation { X = 0, Y = 0 }, // Origin new Transformation { X = -32, Y = 16 }, // Left one new Transformation { X = -64, Y = 32 }, // Left two new Transformation { X = -96, Y = 48 }, // Left three new Transformation { X = 32, Y = 16 }, // Right one new Transformation { X = 64, Y = 32 }, // Right one new Transformation { X = 96, Y = 48 }, // Right one new Transformation { X = 32, Y = -16 }, // Up one new Transformation { X = 64, Y = -32 }, // Up two new Transformation { X = 96, Y = -48 }, // Up three new Transformation { X = 0, Y = 32 }, // Up one, Right one new Transformation { X = -32, Y = 48 }, // Up one, Right two new Transformation { X = 32, Y = 48 }, // Up two, Right one new Transformation { X = 64, Y = 0 }, // Up one, Left one new Transformation { X = 96, Y = -16 }, // Up one, Left two new Transformation { X = 96, Y = 16 }, // Up one, Left two }; foreach (var trans in transformations) { spriteBatch.Draw( _mouseIcon, Camera.WorldToScreen( new Vector2( originX + trans.X, originY + trans.Y ) ), new Rectangle(0, 0, 64, 32), trans.IsHighlighted ? Color.CornflowerBlue * 0.3f : Color.White * 0.3f, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.0f ); } spriteBatch.End(); }
public void Draw(SpriteBatch spriteBatch) { animation.Draw(spriteBatch, position); }
public void Draw(GameTime gt, SpriteBatch sb) { if (_laptopFrame == 0) { return; } if (_laptopFrame < LAPTOP_FLIPUP_FRAMES - 1) { laptopAnim.Draw(sb, _laptopFrame - 1, Vector2.Zero); } if (UI.State != UIState.Laptop) { return; } if (Level.LaptopBattery <= 0.0f) { if (_powerDownFrame < POWERDOWN_FRAMES) { powerDownSprites[_powerDownFrame].Draw(sb, Vector2.Zero); } } else if (Level.Monsters.Redman.IsRedScreenOfDeathUp) { miscScreens["RedScreenOfDeath"].Draw(sb, Vector2.Zero); } else if (IsRebooting) { miscScreens["EggOS"].Draw(sb, Vector2.Zero); RectangleF sourceRect = new RectangleF(0, 0, REBOOT_BAR_SIZE.X * RebootProgress, REBOOT_BAR_SIZE.Y); miscScreens["RebootBar"].Draw(sb, REBOOT_BAR_OFFSET, sourceRect, Color.White); miscScreens["LaptopVignette"].Draw(sb, Vector2.Zero); } else { if (_isStaticIntermittent && _staticScreensLeft > 0) { UI.DrawNoise(sb, 255); } else { Vector2 offset = WINDOW_OFFSET; if (CAMERAS_WITH_PANNING.Contains(ActiveCamera)) { offset += Vector2.UnitX * cameraOffsets[ActiveCamera].CameraOffset; } cameraRoomSprites[ActiveCamera.ToString()].Draw(sb, offset); Level.Monsters.DrawOnCamera(sb, offset, ActiveCamera); } UI.DrawNoise(sb, OnafMain.STATIC_OVERLAY_ALPHA); miscScreens["ChillBar"].Draw(sb, new Vector2(0, _chillBarOffset)); if (_staticScreensLeft > 0) { staticBars[_currentStaticScreen].Draw(sb, Vector2.Zero); } miscScreens["Camera"].Draw(sb, Vector2.Zero); miscScreens["LaptopVignette"].Draw(sb, Vector2.Zero); gameUI["Map"].Draw(sb, MAP_OFFSET); string icon = _roomIconBright ? "CamSelectedLight" : "CamSelectedDark"; gameUI[icon].Draw(sb, MAP_OFFSET + MAP_CAMERA_OFFSETS[ActiveCamera]); icon = _youIconBright ? "YouSmall" : "YouLarge"; gameUI[icon].Draw(sb, YOU_ICON_OFFSET); foreach (KeyValuePair <CameraIndex, Vector2> kvp in MAP_CAMERA_OFFSETS) { string str = "CAM\n" + ((int)kvp.Key); sb.DrawString(retroFontSmall, str, kvp.Value + MAP_OFFSET + MAP_TEXT_OFFSET, Color.White); } Level.Monsters.DrawOnLaptop(sb); } }
public void Draw(Transform2 parentTransform) { _glow.Draw(parentTransform + Transform + CurrentTileLocation + _glowOff); _currentAnimation.Draw(parentTransform + Transform + CurrentTileLocation + _offset); }
public void TestPlay() { var spriteComp = CreateSpriteComponent(20); SpriteAnimation.Play(spriteComp, 1, 5, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(0))); Assert.Equal(1, spriteComp.CurrentFrame); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1))); Assert.Equal(2, spriteComp.CurrentFrame); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(0.5))); Assert.Equal(2, spriteComp.CurrentFrame); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(9), TimeSpan.FromSeconds(9))); Assert.Equal(5, spriteComp.CurrentFrame); // check that it does not exceed last frame SpriteAnimation.Play(spriteComp, 5, 7, AnimationRepeatMode.LoopInfinite, 1); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(0))); Assert.Equal(5, spriteComp.CurrentFrame); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(3))); Assert.Equal(5, spriteComp.CurrentFrame); // check looping SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(4))); Assert.Equal(6, spriteComp.CurrentFrame); // check looping SpriteAnimation.Play(spriteComp, new[] { 9, 5, 10, 9 }, AnimationRepeatMode.LoopInfinite, 1); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(0))); Assert.Equal(9, spriteComp.CurrentFrame); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1))); Assert.Equal(5, spriteComp.CurrentFrame); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1))); Assert.Equal(10, spriteComp.CurrentFrame); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1))); Assert.Equal(9, spriteComp.CurrentFrame); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1))); Assert.Equal(9, spriteComp.CurrentFrame); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1))); Assert.Equal(5, spriteComp.CurrentFrame); // check queue reset SpriteAnimation.Queue(spriteComp, 1, 2, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Queue(spriteComp, 3, 4, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Play(spriteComp, 7, 8, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(4))); Assert.Equal(8, spriteComp.CurrentFrame); // check queue reset SpriteAnimation.Queue(spriteComp, 1, 2, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Queue(spriteComp, 3, 4, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Play(spriteComp, new[] { 7, 8 }, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(4))); Assert.Equal(8, spriteComp.CurrentFrame); // check queue reset SpriteAnimation.Play(spriteComp, 0, 0, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Queue(spriteComp, 1, 2, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Queue(spriteComp, 3, 4, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Play(spriteComp, 7, 8, AnimationRepeatMode.PlayOnce, 1, false); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10))); Assert.Equal(4, spriteComp.CurrentFrame); // check queue no reset SpriteAnimation.Play(spriteComp, 0, 0, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Queue(spriteComp, 1, 2, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Queue(spriteComp, 3, 4, AnimationRepeatMode.PlayOnce, 1); SpriteAnimation.Play(spriteComp, new[] { 7, 8 }, AnimationRepeatMode.PlayOnce, 1, false); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10))); Assert.Equal(4, spriteComp.CurrentFrame); // check queue no reset // check default fps speed SpriteAnimation.Play(spriteComp, 0, 15, AnimationRepeatMode.PlayOnce); SpriteAnimation.Draw(new GameTime(TimeSpan.FromSeconds(0.51), TimeSpan.FromSeconds(0.51))); Assert.Equal(15, spriteComp.CurrentFrame); // check queue no reset }
public void Draw(SpriteBatch spriteBatch, SpriteAnimation vlad) { Vector2 firstSquare, squareOffset, hilightLoc; Point vladMapPoint, vladStandingOn, hilightPoint; int firstX, firstY, offsetX, offsetY, rowOffset, mapx, mapy, heightRow, vladHeight, hilightrowOffset; float maxdepth, depthOffset; maxdepth = ((myMap.MapWidth + 1) + ((myMap.MapHeight + 1) * tile.Tile.TileWidth)) * 10; firstSquare = new Vector2(Camera.Instance.Location.X / tile.Tile.TileStepX, Camera.Instance.Location.Y / tile.Tile.TileStepY); firstX = (int)firstSquare.X; firstY = (int)firstSquare.Y; squareOffset = new Vector2(Camera.Instance.Location.X % tile.Tile.TileStepX, Camera.Instance.Location.Y % tile.Tile.TileStepY); offsetX = (int)squareOffset.X; offsetY = (int)squareOffset.Y; // calculate squares down / across for (int y = 0; y < squaresDown; y++) { rowOffset = 0; if ((firstY + y) % 2 == 1) { rowOffset = tile.Tile.OddRowXOffset; } for (int x = 0; x < squaresAcross; x++) { mapx = (firstX + x); mapy = (firstY + y); vladMapPoint = myMap.WorldToMapCell(new Point((int)vlad.Position.X, (int)vlad.Position.Y)); depthOffset = 0.7f - ((mapx + (mapy * tile.Tile.TileWidth)) / maxdepth); if ((mapx >= myMap.MapWidth) || (mapy >= myMap.MapHeight)) { continue; } foreach (int tileID in myMap.Rows[mapy].Columns[mapx].BaseTiles) { spriteBatch.Draw( tile.Tile.TileSetTexture, Camera.Instance.WorldToScreen(new Vector2((mapx * tile.Tile.TileStepX) + rowOffset, mapy * tile.Tile.TileStepY)), tile.Tile.GetSourceRectangle(tileID), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 1.0f); } heightRow = 0; foreach (int tileID in myMap.Rows[mapy].Columns[mapx].HeightTiles) { spriteBatch.Draw( tile.Tile.TileSetTexture, Camera.Instance.WorldToScreen(new Vector2((mapx * tile.Tile.TileStepX) + rowOffset, mapy * tile.Tile.TileStepY - (heightRow * tile.Tile.HeightTileOffset))), tile.Tile.GetSourceRectangle(tileID), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, depthOffset - ((float)heightRow * heightRowDepthMod)); heightRow++; } foreach (int tileID in myMap.Rows[y + firstY].Columns[x + firstX].TopperTiles) { spriteBatch.Draw( tile.Tile.TileSetTexture, Camera.Instance.WorldToScreen(new Vector2((mapx * tile.Tile.TileStepX) + rowOffset, mapy * tile.Tile.TileStepY)), tile.Tile.GetSourceRectangle(tileID), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, depthOffset - ((float)heightRow * heightRowDepthMod)); } if ((mapx == vladMapPoint.X) && (mapy == vladMapPoint.Y)) { vlad.DrawDepth = depthOffset - (float)(heightRow + 2) * heightRowDepthMod; } if (coOrds) { spriteBatch.DrawString( pericles6, (x + firstX).ToString() + ", " + (y + firstY).ToString(), new Vector2((x * tile.Tile.TileStepX) - offsetX + rowOffset + baseOffsetX + 24, (y * tile.Tile.TileStepY) - offsetY + baseOffsetY + 48), Color.White, 0f, Vector2.Zero,1.0f, SpriteEffects.None, 0.0f); } } } vladStandingOn = myMap.WorldToMapCell(new Point((int)vlad.Position.X, (int)vlad.Position.Y)); vladHeight = myMap.Rows[vladStandingOn.Y].Columns[vladStandingOn.X].HeightTiles.Count * tile.Tile.HeightTileOffset; vlad.Draw(spriteBatch, 0, -myMap.GetOverallHeight(vlad.Position)); hilightLoc = Camera.Instance.ScreenToWorld(new Vector2(managers.CursorManager.Instance.VirtualMouseX, managers.CursorManager.Instance.VirtualMouseY)); hilightPoint = myMap.WorldToMapCell(new Point((int)hilightLoc.X, (int)hilightLoc.Y)); hilightrowOffset = 0; if ((hilightPoint.Y) % 2 == 1) { hilightrowOffset = map.tile.Tile.OddRowXOffset; } spriteBatch.Draw( hilight, Camera.Instance.WorldToScreen(new Vector2((hilightPoint.X * tile.Tile.TileStepX) + hilightrowOffset, (hilightPoint.Y + 2) * tile.Tile.TileStepY)), new Rectangle(0, 0, 64, 32), Color.White * 0.3f, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.0f); }
public virtual void Draw(SpriteBatch spriteBatch) { animation.Draw(spriteBatch); }
public void Draw(SpriteBatch spriteBatch) { playerAnimation.Draw(spriteBatch); }