/// <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> // This method is provided fully complete as part of the activity starter. protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } // has some animation short already started if (isPlayer1Throwing) { player1.Animate(gameTime); // advance to next frame if it's time if (!player1.IsAnimating()) // see if animation short has completed { snowball.IsAlive = true; isPlayer1Throwing = false; } } else if (isPlayer2Throwing) { player2.Animate(gameTime); // advance to next frame if it's time if (!player2.IsAnimating()) // see if animation short has completed { snowball.IsAlive = true; isPlayer2Throwing = false; } } else if (isPlayer1Hit) { player1.Animate(gameTime); // advance to next frame if it's time if (!player1.IsAnimating()) // see if animation short has completed { isPlayer1Hit = false; } } else if (isPlayer2Hit) { player2.Animate(gameTime); // advance to next frame if it's time if (!player2.IsAnimating()) // see if animation short has completed { isPlayer2Hit = false; } } // handle all user input handleKeyPress(); //Optionally handle Xbox gamepad input handleXboxGamepads(); // move the snowball if in flight moveSnowball(); // check to see if the snowball hits anything checkCollisions(); base.Update(gameTime); }
protected override void updateSlaveAnimation(GameTime time) { if (holdingStar || holdingBundle) { Sprite.Animate(time, 44, 4, 200f); return; } if (!position.IsInterpolating()) { Sprite.Animate(time, 8, 4, 100f); return; } if (FacingDirection == 1) { flip = false; Sprite.Animate(time, 16, 8, 50f); return; } if (FacingDirection == 3) { Sprite.Animate(time, 16, 8, 50f); flip = true; return; } if (FacingDirection == 0) { Sprite.Animate(time, 32, 8, 50f); return; } Sprite.Animate(time, 0, 8, 50f); }
public override void update(GameTime time, GameLocation location, long id, bool move) { LastColliding = Colliding; Colliding = false; if (!isGlowing) { if (Name == "MoongateWax") { CurrentDialogue.Clear(); startGlowing(Color.FromNonPremultiplied(0, 236, 222, 255), false, 0.01f); } else if (Name == "MoongateWane") { CurrentDialogue.Clear(); startGlowing(Color.FromNonPremultiplied(236, 0, 183, 255), false, 0.01f); } else if (Name == "MoongateEbb") { CurrentDialogue.Clear(); startGlowing(Color.FromNonPremultiplied(187, 255, 57, 255), false, 0.01f); } else if (Name == "MoongateFlow") { CurrentDialogue.Clear(); startGlowing(Color.FromNonPremultiplied(179, 129, 255, 255), false, 0.01f); } } //base.update(time, location, id, move); updateGlow(); Sprite.Animate(time, 0, 4, 200f); }
public override void behaviorAtGameTick(GameTime time) { if (!throwing) { base.behaviorAtGameTick(time); } if (!spottedPlayer && !base.wildernessFarmMonster && Utility.doesPointHaveLineOfSightInMine(base.currentLocation, getTileLocation(), base.Player.getTileLocation(), 8)) { controller = new PathFindController(this, base.currentLocation, new Point(base.Player.getStandingX() / 64, base.Player.getStandingY() / 64), Game1.random.Next(4), null, 200); spottedPlayer = true; Halt(); facePlayer(base.Player); base.currentLocation.playSound("skeletonStep"); base.IsWalkingTowardPlayer = true; } else if ((bool)throwing) { if (invincibleCountdown > 0) { invincibleCountdown -= time.ElapsedGameTime.Milliseconds; if (invincibleCountdown <= 0) { stopGlowing(); } } Sprite.Animate(time, 20, 5, 150f); if (Sprite.currentFrame == 24) { throwing.Value = false; Sprite.currentFrame = 0; faceDirection(2); Vector2 v = Utility.getVelocityTowardPlayer(new Point((int)base.Position.X, (int)base.Position.Y), 8f, base.Player); base.currentLocation.projectiles.Add(new BasicProjectile(base.DamageToFarmer, 4, 0, 0, (float)Math.PI / 16f, v.X, v.Y, new Vector2(base.Position.X, base.Position.Y), "skeletonHit", "skeletonStep", explode: false, damagesMonsters: false, base.currentLocation, this)); } } else if (spottedPlayer && controller == null && Game1.random.NextDouble() < 0.002 && !base.wildernessFarmMonster && Utility.doesPointHaveLineOfSightInMine(base.currentLocation, getTileLocation(), base.Player.getTileLocation(), 8)) { throwing.Value = true; Halt(); Sprite.currentFrame = 20; shake(750); } else if (withinPlayerThreshold(2)) { controller = null; } else if (spottedPlayer && controller == null && controllerAttemptTimer <= 0) { controller = new PathFindController(this, base.currentLocation, new Point(base.Player.getStandingX() / 64, base.Player.getStandingY() / 64), Game1.random.Next(4), null, 200); Halt(); facePlayer(base.Player); controllerAttemptTimer = (base.wildernessFarmMonster ? 2000 : 1000); } else if (base.wildernessFarmMonster) { spottedPlayer = true; base.IsWalkingTowardPlayer = true; } controllerAttemptTimer -= time.ElapsedGameTime.Milliseconds; }
protected override void updateMonsterSlaveAnimation(GameTime time) { if ((bool)casting) { Sprite.Animate(time, 16, 4, 200f); rotationTimer = (float)((double)((float)time.TotalGameTime.Milliseconds * ((float)Math.PI / 128f) / 24f) % (Math.PI * 1024.0)); } if (isMoving()) { if (base.FacingDirection == 0) { Sprite.AnimateUp(time); } else if (base.FacingDirection == 3) { Sprite.AnimateLeft(time); } else if (base.FacingDirection == 1) { Sprite.AnimateRight(time); } else if (base.FacingDirection == 2) { Sprite.AnimateDown(time); } } else { Sprite.StopAnimation(); } }
/// <summary> /// Update method for the Guy that's called once a frame. /// </summary> /// <param name="gameTime">Snapshot of the game timing state.</param> /// <param name="shoes">A reference to the Shoes.</param> /// <param name="level">A reference to the current Level.</param> public void Update(GameTime gameTime, ref Shoes shoes, ref Level level) { currentLevel = level; fadeHandler.Update(gameTime); setCurrentAndPreviousCollisionTiles(); handleMovement(gameTime, ref shoes); Sprite.Animate(gameTime); }
protected override void updateAnimation(GameTime time) { base.updateAnimation(time); if (wasHitCounter >= 0) { wasHitCounter -= time.ElapsedGameTime.Milliseconds; } Sprite.Animate(time, 0, 9, 40f); if (withinPlayerThreshold() && invincibleCountdown <= 0) { float xSlope3 = -(base.Player.GetBoundingBox().Center.X - GetBoundingBox().Center.X); float ySlope3 = base.Player.GetBoundingBox().Center.Y - GetBoundingBox().Center.Y; float t = Math.Max(1f, Math.Abs(xSlope3) + Math.Abs(ySlope3)); if (t < 64f) { xVelocity = Math.Max(-7f, Math.Min(7f, xVelocity * 1.1f)); yVelocity = Math.Max(-7f, Math.Min(7f, yVelocity * 1.1f)); } xSlope3 /= t; ySlope3 /= t; if (wasHitCounter <= 0) { targetRotation = (float)Math.Atan2(0f - ySlope3, xSlope3) - (float)Math.PI / 2f; if ((double)(Math.Abs(targetRotation) - Math.Abs(rotation)) > Math.PI * 7.0 / 8.0 && Game1.random.NextDouble() < 0.5) { turningRight = true; } else if ((double)(Math.Abs(targetRotation) - Math.Abs(rotation)) < Math.PI / 8.0) { turningRight = false; } if (turningRight) { rotation -= (float)Math.Sign(targetRotation - rotation) * ((float)Math.PI / 64f); } else { rotation += (float)Math.Sign(targetRotation - rotation) * ((float)Math.PI / 64f); } rotation %= (float)Math.PI * 2f; wasHitCounter = 5 + Game1.random.Next(-1, 2); } float maxAccel = Math.Min(7f, Math.Max(2f, 7f - t / 64f / 2f)); xSlope3 = (float)Math.Cos((double)rotation + Math.PI / 2.0); ySlope3 = 0f - (float)Math.Sin((double)rotation + Math.PI / 2.0); xVelocity += (0f - xSlope3) * maxAccel / 6f + (float)Game1.random.Next(-10, 10) / 100f; yVelocity += (0f - ySlope3) * maxAccel / 6f + (float)Game1.random.Next(-10, 10) / 100f; if (Math.Abs(xVelocity) > Math.Abs((0f - xSlope3) * 7f)) { xVelocity -= (0f - xSlope3) * maxAccel / 6f; } if (Math.Abs(yVelocity) > Math.Abs((0f - ySlope3) * 7f)) { yVelocity -= (0f - ySlope3) * maxAccel / 6f; } } resetAnimationSpeed(); }
protected override void updateAnimation(GameTime time) { base.updateAnimation(time); if (wasHitCounter >= 0) { wasHitCounter -= time.ElapsedGameTime.Milliseconds; } Sprite.Animate(time, 0, 9, 40f); float xSlope = (float)(-(float)(base.Player.GetBoundingBox().Center.X - GetBoundingBox().Center.X)); float ySlope = (float)(base.Player.GetBoundingBox().Center.Y - GetBoundingBox().Center.Y); float t = Math.Max(1f, Math.Abs(xSlope) + Math.Abs(ySlope)); if (t < 64f) { xVelocity = Math.Max(-7f, Math.Min(7f, xVelocity * 1.1f)); yVelocity = Math.Max(-7f, Math.Min(7f, yVelocity * 1.1f)); } xSlope /= t; ySlope /= t; if (wasHitCounter <= 0) { targetRotation = (float)Math.Atan2((double)(-(double)ySlope), (double)xSlope) - 1.57079637f; if ((double)(Math.Abs(targetRotation) - Math.Abs(rotation)) > 2.748893571891069 && Game1.random.NextDouble() < 0.5) { turningRight = true; } else if ((double)(Math.Abs(targetRotation) - Math.Abs(rotation)) < 0.39269908169872414) { turningRight = false; } if (turningRight) { rotation -= (float)Math.Sign(targetRotation - rotation) * 0.0490873866f; } else { rotation += (float)Math.Sign(targetRotation - rotation) * 0.0490873866f; } rotation %= 6.28318548f; wasHitCounter = 5 + Game1.random.Next(-1, 2); } float maxAccel = Math.Min(7f, Math.Max(2f, 7f - t / 64f / 2f)); xSlope = (float)Math.Cos((double)rotation + 1.5707963267948966); ySlope = -(float)Math.Sin((double)rotation + 1.5707963267948966); xVelocity += -xSlope * maxAccel / 6f + (float)Game1.random.Next(-10, 10) / 100f; yVelocity += -ySlope * maxAccel / 6f + (float)Game1.random.Next(-10, 10) / 100f; if (Math.Abs(xVelocity) > Math.Abs(-xSlope * 7f)) { xVelocity -= -xSlope * maxAccel / 6f; } if (Math.Abs(yVelocity) > Math.Abs(-ySlope * 7f)) { yVelocity -= -ySlope * maxAccel / 6f; } base.resetAnimationSpeed(); }
protected override void updateAnimation(GameTime time) { if (base.focusedOnFarmers || withinPlayerThreshold(6) || (bool)seenPlayer || magmaSprite.Value) { Sprite.Animate(time, 0, 4, 80f); if (Sprite.currentFrame % 3 == 0 && Utility.isOnScreen(base.Position, 512) && (batFlap == null || !batFlap.IsPlaying) && Game1.soundBank != null && base.currentLocation == Game1.currentLocation && !cursedDoll) { batFlap = Game1.soundBank.GetCue("batFlap"); batFlap.Play(); } if (cursedDoll.Value) { shakeTimer -= time.ElapsedGameTime.Milliseconds; if (shakeTimer < 0) { shakeTimer = 50; if (magmaSprite.Value) { shakeTimer = ((lungeTimer > 0) ? 50 : 100); base.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite("Characters\\Monsters\\Magma Sprite", new Rectangle(0, 64, 8, 8), position + new Vector2(Game1.random.Next(32), -16 - Game1.random.Next(32)), flipped: false, 0f, Color.White) { scale = 4f, scaleChange = -0.05f, motion = new Vector2((lungeTimer > 0) ? ((float)Game1.random.Next(-30, 31) / 10f) : 0f, (0f - maxSpeed) / ((lungeTimer > 0) ? 2f : 8f)), layerDepth = 0.9f, animationLength = 6, totalNumberOfLoops = 1, interval = 50f, xPeriodic = (lungeTimer <= 0), xPeriodicLoopTime = Game1.random.Next(500, 800), xPeriodicRange = 4 * ((lungeTimer <= 0) ? 1 : 2) }); } else if (!hauntedSkull.Value) { base.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite("Maps\\springobjects", Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, 103, 16, 16), position + new Vector2(0f, -32f), flipped: false, 0.1f, new Color(255, 50, 255) * 0.8f) { scale = 4f }); } } previousPositions.Add(base.Position); if (previousPositions.Count > 8) { previousPositions.RemoveAt(0); } } } else { Sprite.currentFrame = 4; Halt(); } resetAnimationSpeed(); }
public override void Update(ref GameTime gameTime) { base.Update(ref gameTime); if (NightmareMode) { Sprite.Animate(3, 4); } else { Sprite.Animate(0, 4); } }
public override void ResetPose() { base.ResetPose(); if (NightmareMode) { Sprite.Animate(3, 4); } else { Sprite.Animate(0, 4); } }
protected override void updateAnimation(GameTime time) { if ((bool)leaping) { Sprite.CurrentFrame = 2; } else { Sprite.Animate(time, 0, 2, 500f); } Sprite.UpdateSourceRect(); }
protected override void updateAnimation(GameTime time) { Sprite.Animate(time, 0, 4, 80f); if (Sprite.currentFrame % 3 == 0 && Utility.isOnScreen(Position, 512) && !sound.IsPlaying && currentLocation.Equals(Game1.currentLocation)) { Utilities.TryPlayCue(sound); } resetAnimationSpeed(); }
public override void update(GameTime time, GameLocation location) { base.update(time, location); Sprite.Animate(time, 0, 4, 200f); farmerPassesThrough = true; if (Game1.player.currentLocation == currentLocation) { if (Game1.player.getTileLocationPoint() == getTileLocationPoint()) { collisionWithFarmerBehavior(); } } }
public override void Update(ref GameTime gameTime) { base.Update(ref gameTime); // Animate the projectile Sprite.Animate(0, 4); // If hits a wall, then remove if (CollidingWithBoundries) { LifeTime = 0; } // Distance to the nearest non-owner creature float proximity = float.MaxValue; // New distance to the nearest non-owner creature float distance; // Checks all players foreach (Creature creature in Game1.WindowManager.GetGameplayWindow().CurrentLevel.Creatures) { // Skip if creature is owner if (creature == Owner) { continue; } // If it hits a creature deal massive damage and remove the ball if (HitBox.Intersects(creature.HitBox)) { creature.TakeDamage(15000); LifeTime = 0; } // Calculate distance distance = Vector2.Distance(creature.Position, Position); // Check if another creature is closer and change who the ball follows if (distance < proximity) { following = creature; } // Normalise velocity based on difference of position and angles Velocity = Vector2.Normalize(following.Position - Position) * Speed; } }
protected override void updateMonsterSlaveAnimation(GameTime time) { if ((bool)pupating) { base.Scale = 1f + (float)Math.Sin((float)time.TotalGameTime.Milliseconds * ((float)Math.PI / 8f)) / 12f; metamorphCounter -= time.ElapsedGameTime.Milliseconds; } else if (base.Health <= 8 || ((bool)hard && base.Health < base.MaxHealth)) { metamorphCounter -= time.ElapsedGameTime.Milliseconds; if (metamorphCounter <= 0) { Sprite.Animate(time, 16, 4, 125f); if (Sprite.currentFrame == 19) { metamorphCounter = 4500; } } } else if (isMoving()) { if (base.FacingDirection == 0) { Sprite.AnimateUp(time); } else if (base.FacingDirection == 3) { Sprite.AnimateLeft(time); } else if (base.FacingDirection == 1) { Sprite.AnimateRight(time); } else if (base.FacingDirection == 2) { Sprite.AnimateDown(time); } rotation = 0f; base.Scale = 1f; } else if (!withinPlayerThreshold()) { Halt(); rotation = targetRotation; } }
public void PerformHoverAction(int x, int y) { if (Monster != Monster.CursedDoll) { if (containsPoint(x, y)) { Sprite.Animate(Game1.currentGameTime, StartFrame, NumberOfFrames, Interval); } else { if (Sprite.CurrentFrame != StartFrame) { Sprite.CurrentFrame = StartFrame; } } } }
public override void Update() { float now = Time.time; wiggler.Update(now); notSameCycler.Update(now); if (solved) { return; } if (shapes.touchedAtSameTime(now) && triangleShowing()) { messagePromptCoordinator.clearTouch(); messagePromptCoordinator.progress("stop shapes from changing"); Handheld.Vibrate(); wiggler.wiggleNow(now); endScene(); } else { messagePromptCoordinator.hintWhenTouched(GameObject => {}, sensor, now, new Dictionary <GameObject, ActionResponsePair[]> { { circle.gameObject, new [] { new ActionResponsePair("stop circle from changing", new[] { "Nope." }) } }, { triangle.gameObject, new [] { new ActionResponsePair("stop triangle from changing", new[] { "Nope." }) } }, }); } AnimateShapes(now); // if touched circle, draw its bright first frame if (sensor.changeInsideSprite(Camera.main, circle)) { circle.setFrame(0); circle.Animate(); } // if touched triangle, ditto if (sensor.changeInsideSprite(Camera.main, triangle) && triangleShowing()) { triangle.setFrame(0); triangle.Animate(); } }
protected override void updateMonsterSlaveAnimation(GameTime time) { if (throwing.Value) { if (invincibleCountdown > 0) { invincibleCountdown -= time.ElapsedGameTime.Milliseconds; if (invincibleCountdown <= 0) { stopGlowing(); } } Sprite.Animate(time, 20, 5, 50f); if (Sprite.currentFrame == 24) { Sprite.currentFrame = 23; } } else if (isMoving()) { switch (FacingDirection) { case 0: Sprite.AnimateUp(time); break; case 3: Sprite.AnimateLeft(time); break; case 1: Sprite.AnimateRight(time); break; case 2: Sprite.AnimateDown(time); break; } } else { Sprite.StopAnimation(); } }
protected override void updateMonsterSlaveAnimation(GameTime time) { if ((bool)throwing) { if (invincibleCountdown > 0) { invincibleCountdown -= time.ElapsedGameTime.Milliseconds; if (invincibleCountdown <= 0) { stopGlowing(); } } Sprite.Animate(time, 20, 5, 150f); if (Sprite.currentFrame == 24) { Sprite.currentFrame = 23; } } else if (isMoving()) { if (FacingDirection == 0) { Sprite.AnimateUp(time); } else if (FacingDirection == 3) { Sprite.AnimateLeft(time); } else if (FacingDirection == 1) { Sprite.AnimateRight(time); } else if (FacingDirection == 2) { Sprite.AnimateDown(time); } } else { Sprite.StopAnimation(); } }
public override void Update(GameTime gameTime) { base.Update(gameTime); timer.CheckTimer(gameTime); if (timer.TimerOn && fireDuration <= 0 && r.NextDouble() < 0.01) // 1% Chance every second to light the sword on fire { fireDuration = 10; } fireDuration -= gameTime.ElapsedGameTime.TotalSeconds; if (fireDuration > 0) { Sprite.Animate(0, 5); } else { Sprite.Animate(0, 1); } }
protected override void updateAnimation(GameTime time) { if (yJumpOffset == 0) { if ((bool)isHardModeMonster && CaughtInWeb()) { Sprite.Animate(time, 5, 3, 200f); return; } jumpWithoutSound(); yJumpVelocity = (float)Game1.random.Next(50, 70) / 10f; if (Game1.random.NextDouble() < 0.1 && (meep == null || !meep.IsPlaying) && Utility.isOnScreen(base.Position, 64) && Game1.soundBank != null && Game1.currentLocation == base.currentLocation) { meep = Game1.soundBank.GetCue("dustMeep"); meep.SetVariable("Pitch", voice * 100 + Game1.random.Next(-100, 100)); meep.Play(); } } Sprite.AnimateDown(time); resetAnimationSpeed(); }
public override void behaviorAtGameTick(GameTime time) { if (base.IsWalkingTowardPlayer) { base.behaviorAtGameTick(time); } if (!seenPlayer) { if (withinPlayerThreshold()) { base.currentLocation.playSound("rockGolemSpawn"); seenPlayer.Value = true; } else { Sprite.currentFrame = 16; Sprite.loop = false; Sprite.UpdateSourceRect(); } } else if (Sprite.currentFrame >= 16) { Sprite.Animate(time, 16, 8, 75f); if (Sprite.currentFrame >= 24) { Sprite.loop = true; Sprite.currentFrame = 0; moveTowardPlayerThreshold.Value = 16; base.IsWalkingTowardPlayer = true; jitteriness.Value = 0.01; base.HideShadow = false; } } else if (base.IsWalkingTowardPlayer && Game1.random.NextDouble() < 0.001 && Utility.isOnScreen(getStandingPosition(), 0)) { controller = new PathFindController(this, base.currentLocation, new Point((int)base.Player.getTileLocation().X, (int)base.Player.getTileLocation().Y), -1, null, 200); } }
protected override void updateAnimation(GameTime time) { if (followingOwner) { Sprite.Animate(time, 0, 4, 80f); if (Sprite.currentFrame % 3 == 0 && Utility.isOnScreen(Position, 512) && (batFlap == null || !batFlap.IsPlaying) && Game1.soundBank != null && currentLocation == Game1.currentLocation && !cursedDoll) { batFlap = Game1.soundBank.GetCue("batFlap"); //batFlap.Play(); } if (cursedDoll.Value) { shakeTimer -= time.ElapsedGameTime.Milliseconds; if (shakeTimer < 0) { if (!hauntedSkull.Value) { currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite("Maps\\springobjects", Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, 103, 16, 16), position + new Vector2(0f, -32f), false, 0.1f, new Color(255, 50, 255) * 0.8f) { scale = 4f }); } shakeTimer = 50; } previousPositions.Add(Position); if (previousPositions.Count > 8) { previousPositions.RemoveAt(0); } } } else { Sprite.currentFrame = 4; Halt(); } resetAnimationSpeed(); }
protected override void updateMonsterSlaveAnimation(GameTime time) { if (base.IsWalkingTowardPlayer) { if (base.FacingDirection == 0) { Sprite.AnimateUp(time); } else if (base.FacingDirection == 3) { Sprite.AnimateLeft(time); } else if (base.FacingDirection == 1) { Sprite.AnimateRight(time); } else if (base.FacingDirection == 2) { Sprite.AnimateDown(time); } } if (!seenPlayer) { Sprite.currentFrame = 16; Sprite.loop = false; Sprite.UpdateSourceRect(); } else if (Sprite.currentFrame >= 16) { Sprite.Animate(time, 16, 8, 75f); if (Sprite.currentFrame >= 24) { Sprite.loop = true; Sprite.currentFrame = 0; Sprite.UpdateSourceRect(); } } }
protected override void updateAnimation(GameTime time) { if (focusedOnFarmers || withinPlayerThreshold(20) || seenPlayer) { Sprite.Animate(time, 0, 4, 80f); shakeTimer -= time.ElapsedGameTime.Milliseconds; if (shakeTimer < 0) { currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite("Maps\\springobjects", Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, 103, width, height), position + new Vector2(0f, -32f), false, 0.1f, new Color(255, 50, 255) * 0.8f) { scale = 4f }); shakeTimer = 50; } previousPositions.Add(Position); if (previousPositions.Count > 8) { previousPositions.RemoveAt(0); } } resetAnimationSpeed(); }
protected override void updateSlaveAnimation(GameTime time) { if ((bool)sayingGoodbye || (bool)temporaryJunimo) { return; } if ((bool)holdingStar || (bool)holdingBundle) { Sprite.Animate(time, 44, 4, 200f); } else if (position.IsInterpolating()) { if (FacingDirection == 1) { flip = false; Sprite.Animate(time, 16, 8, 50f); } else if (FacingDirection == 3) { Sprite.Animate(time, 16, 8, 50f); flip = true; } else if (FacingDirection == 0) { Sprite.Animate(time, 32, 8, 50f); } else { Sprite.Animate(time, 0, 8, 50f); } } else { Sprite.Animate(time, 8, 4, 100f); } }
public override void Update(ref GameTime gameTime) { base.Update(ref gameTime); Sprite.Animate(0, 5); if (CollidingWithBoundries) { LifeTime = 0; } foreach (Creature creature in Game1.WindowManager.GetGameplayWindow().CurrentLevel.Creatures) { if (creature == Owner) { continue; } if (HitBox.Intersects(creature.HitBox)) { creature.TakeDamage(damage); creature.AddEffect(new Effects.Burning(3)); LifeTime = 0; } } }
protected override void updateAnimation(GameTime time) { if (IsRoyalSerpent()) { if (segments.Count < segmentCount.Value) { for (int i = 0; i < segmentCount.Value; i++) { Vector2 position = base.Position; segments.Add(new Vector3(position.X, position.Y, 0f)); } } Vector2 last_position = base.Position; for (int j = 0; j < segments.Count; j++) { Vector2 current_position = new Vector2(segments[j].X, segments[j].Y); Vector2 offset = current_position - last_position; int segment_length = 64; int num = (int)offset.Length(); offset.Normalize(); if (num > segment_length) { current_position = offset * segment_length + last_position; } double angle = Math.Atan2(offset.Y, offset.X) - Math.PI / 2.0; segments[j] = new Vector3(current_position.X, current_position.Y, (float)angle); last_position = current_position; } } base.updateAnimation(time); if (wasHitCounter >= 0) { wasHitCounter -= time.ElapsedGameTime.Milliseconds; } if (!IsRoyalSerpent()) { Sprite.Animate(time, 0, 9, 40f); } if (withinPlayerThreshold() && invincibleCountdown <= 0) { float xSlope = -(base.Player.GetBoundingBox().Center.X - GetBoundingBox().Center.X); float ySlope = base.Player.GetBoundingBox().Center.Y - GetBoundingBox().Center.Y; float t = Math.Max(1f, Math.Abs(xSlope) + Math.Abs(ySlope)); if (t < 64f) { xVelocity = Math.Max(-7f, Math.Min(7f, xVelocity * 1.1f)); yVelocity = Math.Max(-7f, Math.Min(7f, yVelocity * 1.1f)); } xSlope /= t; ySlope /= t; if (wasHitCounter <= 0) { targetRotation = (float)Math.Atan2(0f - ySlope, xSlope) - (float)Math.PI / 2f; if ((double)(Math.Abs(targetRotation) - Math.Abs(rotation)) > Math.PI * 7.0 / 8.0 && Game1.random.NextDouble() < 0.5) { turningRight = true; } else if ((double)(Math.Abs(targetRotation) - Math.Abs(rotation)) < Math.PI / 8.0) { turningRight = false; } if (turningRight) { rotation -= (float)Math.Sign(targetRotation - rotation) * ((float)Math.PI / 64f); } else { rotation += (float)Math.Sign(targetRotation - rotation) * ((float)Math.PI / 64f); } rotation %= (float)Math.PI * 2f; wasHitCounter = 5 + Game1.random.Next(-1, 2); } float maxAccel = Math.Min(7f, Math.Max(2f, 7f - t / 64f / 2f)); xSlope = (float)Math.Cos((double)rotation + Math.PI / 2.0); ySlope = 0f - (float)Math.Sin((double)rotation + Math.PI / 2.0); xVelocity += (0f - xSlope) * maxAccel / 6f + (float)Game1.random.Next(-10, 10) / 100f; yVelocity += (0f - ySlope) * maxAccel / 6f + (float)Game1.random.Next(-10, 10) / 100f; if (Math.Abs(xVelocity) > Math.Abs((0f - xSlope) * 7f)) { xVelocity -= (0f - xSlope) * maxAccel / 6f; } if (Math.Abs(yVelocity) > Math.Abs((0f - ySlope) * 7f)) { yVelocity -= (0f - ySlope) * maxAccel / 6f; } } resetAnimationSpeed(); }
public override void WalkAnimation() { base.WalkAnimation(); Sprite.Animate(0, 2); }