/// <summary> /// Resets the player to life. /// </summary> /// <param name="position">The position to come to life at.</param> public void Reset(Vector2 position) { Position = position; Velocity = Vector2.Zero; isAlive = true; sprite.PlayAnimation(idleAnimation); player_move_type = enum_move_type.move_type_idle; }
/// <summary> /// Resets the player to life. /// </summary> /// <param name="position">The position to come to life at.</param> public void Reset(Vector2 position) { possession = PossessionStatus.None; Position = position; Velocity = Vector2.Zero; isAlive = true; sprite.PlayAnimation(idleAnimation); }
/// <summary> /// Resets the player to life. /// </summary> /// <param name="position">The position to come to life at.</param> public void Reset(Vector2 position) { Position = position; Velocity = Vector2.Zero; isAlive = true; sprite.PlayAnimation(idleAnimation); px = (int)position.X; py = (int)position.Y; vx = 0; vy = 0; movement2 = 0; }
/// <summary> /// Loads a particular enemy sprite sheet and sounds. /// </summary> public void LoadContent(string spriteSet) { // Load animations. spriteSet = "Sprites/" + spriteSet + "/"; runAnimation = new Animation(Level.Content.Load <Texture2D>(spriteSet + "Run"), 0.1f, true); idleAnimation = new Animation(Level.Content.Load <Texture2D>(spriteSet + "Idle"), 0.15f, true); sprite.PlayAnimation(idleAnimation); // Calculate bounds within texture size. int width = (int)(idleAnimation.FrameWidth * 0.35); int left = (idleAnimation.FrameWidth - width) / 2; int height = (int)(idleAnimation.FrameWidth * 0.7); int top = idleAnimation.FrameHeight - height; localBounds = new Rectangle(left, top, width, height); }
public void LoadContent() { int rand = PlatformerGame.RandomBetween(0, 100); if (rand >= 0 && rand <= 25) { idleAnimation = new Animation(Level.Content.Load <Texture2D>("Sprites/donut"), 0.1f, false); } else if (rand > 25 && rand <= 50) { idleAnimation = new Animation(Level.Content.Load <Texture2D>("Sprites/duff"), 0.1f, false, 71); } else if (rand > 50 && rand <= 75) { idleAnimation = new Animation(Level.Content.Load <Texture2D>("Sprites/chunli"), 0.1f, false, 40); } else if (rand > 75) { idleAnimation = new Animation(Level.Content.Load <Texture2D>("Sprites/winning"), 0.1f, false, 200); } sprite.PlayAnimation(idleAnimation); // Calculate bounds within texture size. int width = (int)(idleAnimation.FrameWidth * 1.5); int left = (idleAnimation.FrameWidth - width) / 2; int height = (int)(idleAnimation.FrameWidth * 0.7); int top = idleAnimation.FrameHeight - height; localBounds = new Rectangle(left, top, width, height); }
public override void Update(GameTime gameTime) { if (IsRecoiling && recoilTicks == TimeSpan.MinValue) { recoilTicks = gameTime.TotalGameTime + new TimeSpan(0, 0, 0, 0, 250); } else if (IsRecoiling && recoilTicks >= gameTime.TotalGameTime) { if (gameTime.TotalGameTime - recoilTicks < new TimeSpan(0, 0, 0, 0, 83) && recoilCount == 0) { recoilCount++; MapLocation += recoilVector; } else if (gameTime.TotalGameTime - recoilTicks < new TimeSpan(0, 0, 0, 0, 166) && recoilCount == 1) { recoilCount++; MapLocation += recoilVector; } } else if (IsRecoiling && recoilTicks < gameTime.TotalGameTime) { IsRecoiling = false; recoilTicks = TimeSpan.MinValue; } sprite.PlayAnimation(idleAnimation, false); }
/// <summary> /// Loads a particular knife sprite sheet and sounds. /// </summary> public void LoadContent() { idleAnimation = new Animation(game.Content.Load <Texture2D>("Sprites/Weapons/knife_idle"), 0.1f, false, 50); attackAnimation = new Animation(game.Content.Load <Texture2D>("Sprites/Weapons/knife"), 0.1f, false, 50); sprite.PlayAnimation(idleAnimation); knifeSound = game.Content.Load <SoundEffect>("Sounds/knifeSound"); // Calculate bounds within texture size. int width = (int)(idleAnimation.FrameWidth * 0.4); int left = (idleAnimation.FrameWidth - width) / 2; int height = 10; int top = idleAnimation.FrameHeight - height; localBounds = new Rectangle(left, top, width, height); }
private void playAnimationForSprite(int i, Animation animation) { AnimationPlayer player = sprites[i]; player.PlayAnimation(animation); sprites[i] = player; }
/// <summary> /// Loads a particular enemy sprite sheet and sounds. /// </summary> public void LoadContent(string spriteSet) { // tag what monster it is switch (spriteSet) { case "Lantern": monsterType = MonsterType.Lantern; break; case "Sushi": monsterType = MonsterType.Sushi; break; case "Sandals": monsterType = MonsterType.Sandals; break; default: break; } // Load animations. spriteSet = "Sprites/" + spriteSet + "/"; runAnimation = new Animation(Level.Content.Load <Texture2D>(spriteSet + "Good/Run"), 0.1f, true); idleAnimation = new Animation(Level.Content.Load <Texture2D>(spriteSet + "Good/Idle"), 0.1f, true); evilRunAnimation = new Animation(Level.Content.Load <Texture2D>(spriteSet + "Evil/Run"), 0.1f, true); evilRunAnimationGlow = new Animation(Level.Content.Load <Texture2D>(spriteSet + "Evil/RunGlow"), 0.1f, true); evilIdleAnimation = new Animation(Level.Content.Load <Texture2D>(spriteSet + "Evil/Idle"), 0.1f, true); evilIdleAnimationGlow = new Animation(Level.Content.Load <Texture2D>(spriteSet + "Evil/IdleGlow"), 0.1f, true); if (monsterType == MonsterType.Lantern) { evilJumpAnimation = new Animation(Level.Content.Load <Texture2D>(spriteSet + "Evil/Jump"), 0.1f, true); } sprite.PlayAnimation(idleAnimation); spriteGlow.PlayAnimation(evilIdleAnimationGlow); // Calculate bounds within texture size. int width = (int)(idleAnimation.FrameWidth * 0.35); int left = (idleAnimation.FrameWidth - width) / 2; int height = (int)(idleAnimation.FrameWidth * 0.7); int top = idleAnimation.FrameHeight - height; localBounds = new Rectangle(left, top, width, height); }
/// <summary> /// Resets the player to life. /// </summary> /// <param name="position">The position to come to life at.</param> public void Reset(Vector2 position) { Position = position; MediaPlayer.Stop(); Velocity = Vector2.Zero; powerUpTime = 0.0f; powerDownTime = 0.0f; isAlive = true; sprite.PlayAnimation(idleAnimation); }
/// <summary> /// Resets the player to life. /// </summary> /// <param name="position">The position to come to life at.</param> public void Reset(Vector2 position) { Position = position; Velocity = Vector2.Zero; isAlive = true; isRolling = false; isJumping = false; pulseRed = false; pulseRedTime = 0.0f; health = 100; sprite.PlayAnimation(idleAnimation); }
public void Update(GameTime gameTime) { if (IsAttacking && attackTicks == TimeSpan.MinValue) { attackTicks = gameTime.TotalGameTime + new TimeSpan(0, 0, 0, 0, 250); swordAnimator.PlayAnimation(swordSlash, true); } else if (IsAttacking && attackTicks < gameTime.TotalGameTime) { IsAttacking = false; attackTicks = TimeSpan.MinValue; } if (isMoving) { sprite.PlayAnimation(runningAnimation, false); } else { sprite.PlayAnimation(idleAnimation, false); } }
/// <summary> /// Resets the player to life. /// </summary> /// <param name="position">The position to come to life at.</param> public void Reset(Vector2 position) { Position = position; Velocity = Vector2.Zero; isAlive = true; sprite.PlayAnimation(idleAnimation); }
/// <summary> /// Loads a particular spike sprite sheet and sounds. /// </summary> public void LoadContent() { idleAnimation = new Animation(Level.Content.Load <Texture2D>("Tiles/spike"), 0.1f, false); sprite.PlayAnimation(idleAnimation); // Calculate bounds within texture size. int width = (int)(idleAnimation.FrameWidth * 0.35); int left = (idleAnimation.FrameWidth - width) / 2; int height = (int)(idleAnimation.FrameWidth * 0.7); int top = idleAnimation.FrameHeight - height; localBounds = new Rectangle(left, top, width, height); }
/// <summary> /// Update the gun position and animated muzzle fire /// </summary> public override void Update(GameTime gameTime, Vector2 position, SpriteEffects flip) { float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds; Vector2 offset = (flip == SpriteEffects.None) ? new Vector2(45, 0) : new Vector2(-45, 0); Flip = flip; Position = position + offset; sprite.PlayAnimation(baseGraphic); if (isShooting) { muzzleAnimationTimer += elapsed; muzzle.PlayAnimation(muzzleFire); if (muzzleAnimationTimer > 0.20f) { muzzleAnimationTimer = 0.0f; isShooting = false; muzzle.StopAnimation(); } } if (!canShoot) { rateOfFire += elapsed; if (rateOfFire > MAXFIRERATE) { rateOfFire = 0f; canShoot = true; } } // Update call for bullets foreach (HandgunBullet bullet in _bullets) { bullet.Update(gameTime); } }