public void AHHHH() { if (!Game1.currentLocation.shouldHideCharacters()) { if (Game1.CurrentEvent == null) { foreach (NPC character in Game1.currentLocation.characters) { if (!(bool)(character.swimming) && !character.HideShadow && Game1.currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(character.getTileLocation())) { Game1.spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, character.Position + new Vector2((float)(character.Sprite.SpriteWidth * 4) / 2f, (float)(character.GetBoundingBox().Height + (character.IsMonster ? 0 : 12)))), new Microsoft.Xna.Framework.Rectangle?(Game1.shadowTexture.Bounds), Color.White, 0.0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), (float)(4.0 + (double)character.yJumpOffset / 40.0) * (float)(character.scale), SpriteEffects.None, Math.Max(0.0f, (float)character.getStandingY() / 10000f) - 1E-06f); } } } else { foreach (NPC actor in Game1.CurrentEvent.actors) { if (!(bool)(actor.swimming) && !actor.HideShadow && Game1.currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(actor.getTileLocation())) { Game1.spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, actor.Position + new Vector2((float)(actor.Sprite.SpriteWidth * 4) / 2f, (float)(actor.GetBoundingBox().Height + (actor.IsMonster ? 0 : 12)))), new Microsoft.Xna.Framework.Rectangle?(Game1.shadowTexture.Bounds), Color.White, 0.0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), (float)(4.0 + (double)actor.yJumpOffset / 40.0) * (float)(actor.scale), SpriteEffects.None, Math.Max(0.0f, (float)actor.getStandingY() / 10000f) - 1E-06f); } } } foreach (Farmer farmer in Game1.currentLocation.farmers) { if (!(bool)(farmer.swimming) && !farmer.isRidingHorse() && (Game1.currentLocation != null && Game1.currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(farmer.getTileLocation()))) { SpriteBatch spriteBatch = Game1.spriteBatch; Texture2D shadowTexture = Game1.shadowTexture; Vector2 local = Game1.GlobalToLocal(farmer.Position + new Vector2(32f, 24f)); Microsoft.Xna.Framework.Rectangle?sourceRectangle = new Microsoft.Xna.Framework.Rectangle?(Game1.shadowTexture.Bounds); Color white = Color.White; double num1 = 0.0; Microsoft.Xna.Framework.Rectangle bounds = Game1.shadowTexture.Bounds; double x = (double)bounds.Center.X; bounds = Game1.shadowTexture.Bounds; double y = (double)bounds.Center.Y; Vector2 origin = new Vector2((float)x, (float)y); double num2 = 4.0 - (!farmer.running && !farmer.UsingTool || farmer.FarmerSprite.currentAnimationIndex <= 1 ? 0.0 : (double)Math.Abs(FarmerRenderer.featureYOffsetPerFrame[farmer.FarmerSprite.CurrentFrame]) * 0.5); int num3 = 0; double num4 = 0.0; spriteBatch.Draw(shadowTexture, local, sourceRectangle, white, (float)num1, origin, (float)num2, (SpriteEffects)num3, (float)num4); } } } if ((Game1.eventUp || Game1.killScreen) && (!Game1.killScreen && Game1.currentLocation.currentEvent != null)) { Game1.currentLocation.currentEvent.draw(Game1.spriteBatch); } if (Game1.player.currentUpgrade != null && Game1.player.currentUpgrade.daysLeftTillUpgradeDone <= 3 && Game1.currentLocation.Name.Equals("Farm")) { Game1.spriteBatch.Draw(Game1.player.currentUpgrade.workerTexture, Game1.GlobalToLocal(Game1.viewport, Game1.player.currentUpgrade.positionOfCarpenter), new Microsoft.Xna.Framework.Rectangle?(Game1.player.currentUpgrade.getSourceRectangle()), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, (float)(((double)Game1.player.currentUpgrade.positionOfCarpenter.Y + 48.0) / 10000.0)); } Game1.currentLocation.draw(Game1.spriteBatch); if (Game1.eventUp && Game1.currentLocation.currentEvent != null) { string messageToScreen = Game1.currentLocation.currentEvent.messageToScreen; } if (Game1.player.ActiveObject == null && (Game1.player.UsingTool || Game1.pickingTool) && (Game1.player.CurrentTool != null && (!Game1.player.CurrentTool.Name.Equals("Seeds") || Game1.pickingTool))) { Game1.drawTool(Game1.player); } if (Game1.currentLocation.Name.Equals("Farm")) { Monitor.Log("DRAW farm buildings here"); } //getInvokeMethod((Game1.currentLocation as GameLocation), "drawFarmBuildings", new object[] { }); if (Game1.tvStation >= 0) { Game1.spriteBatch.Draw(Game1.tvStationTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2(400f, 160f)), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(Game1.tvStation * 24, 0, 24, 15)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 1E-08f); } if (Game1.panMode) { Game1.spriteBatch.Draw(Game1.fadeToBlackRect, new Microsoft.Xna.Framework.Rectangle((int)Math.Floor((double)(Game1.getOldMouseX() + Game1.viewport.X) / 64.0) * 64 - Game1.viewport.X, (int)Math.Floor((double)(Game1.getOldMouseY() + Game1.viewport.Y) / 64.0) * 64 - Game1.viewport.Y, 64, 64), Color.Lime * 0.75f); foreach (Warp warp in (Game1.currentLocation.warps)) { Game1.spriteBatch.Draw(Game1.fadeToBlackRect, new Microsoft.Xna.Framework.Rectangle(warp.X * 64 - Game1.viewport.X, warp.Y * 64 - Game1.viewport.Y, 64, 64), Color.Red * 0.75f); } } Game1.mapDisplayDevice.BeginScene(Game1.spriteBatch); Game1.currentLocation.Map.GetLayer("Front").Draw(Game1.mapDisplayDevice, Game1.viewport, Location.Origin, false, 4); Game1.mapDisplayDevice.EndScene(); //Game1.currentLocation.drawAboveFrontLayer(Game1.spriteBatch); //Game1.spriteBatch.End(); }
public override void MovePosition(GameTime time, xTile.Dimensions.Rectangle viewport, GameLocation currentLocation) { lastPosition = base.Position; if (xVelocity != 0f || yVelocity != 0f) { if (double.IsNaN((double)xVelocity) || double.IsNaN((double)yVelocity)) { xVelocity = 0f; yVelocity = 0f; } Microsoft.Xna.Framework.Rectangle nextPosition = GetBoundingBox(); nextPosition.X += (int)xVelocity; nextPosition.Y -= (int)yVelocity; if (!currentLocation.isCollidingPosition(nextPosition, viewport, false, DamageToFarmer, isGlider, this)) { position.X += xVelocity; position.Y -= yVelocity; if (Slipperiness < 1000) { xVelocity -= xVelocity / (float)Slipperiness; yVelocity -= yVelocity / (float)Slipperiness; if (Math.Abs(xVelocity) <= 0.05f) { xVelocity = 0f; } if (Math.Abs(yVelocity) <= 0.05f) { yVelocity = 0f; } } if (!isGlider && invincibleCountdown > 0) { slideAnimationTimer -= time.ElapsedGameTime.Milliseconds; if (slideAnimationTimer < 0 && (Math.Abs(xVelocity) >= 3f || Math.Abs(yVelocity) >= 3f)) { slideAnimationTimer = 100 - (int)(Math.Abs(xVelocity) * 2f + Math.Abs(yVelocity) * 2f); ModEntry.mp.broadcastSprites(currentLocation, new TemporaryAnimatedSprite[] { new TemporaryAnimatedSprite(6, base.getStandingPosition() + new Vector2(-32f, -32f), Color.White * 0.75f, 8, Game1.random.NextDouble() < 0.5, 20f, 0, -1, -1f, -1, 0) { scale = 0.75f } }); } } } else if (isGlider || Slipperiness >= 8) { bool[] array = Utility.horizontalOrVerticalCollisionDirections(nextPosition, this, false); if (array[0]) { xVelocity = -xVelocity; position.X += (float)Math.Sign(xVelocity); rotation += (float)(3.1415926535897931 + (double)Game1.random.Next(-10, 11) * 3.1415926535897931 / 500.0); } if (array[1]) { yVelocity = -yVelocity; position.Y -= (float)Math.Sign(yVelocity); rotation += (float)(3.1415926535897931 + (double)Game1.random.Next(-10, 11) * 3.1415926535897931 / 500.0); } if (Slipperiness < 1000) { xVelocity -= xVelocity / (float)Slipperiness / 4f; yVelocity -= yVelocity / (float)Slipperiness / 4f; if (Math.Abs(xVelocity) <= 0.05f) { xVelocity = 0f; } if (Math.Abs(yVelocity) <= 0.051f) { yVelocity = 0f; } } } else { xVelocity -= xVelocity / (float)Slipperiness; yVelocity -= yVelocity / (float)Slipperiness; if (Math.Abs(xVelocity) <= 0.05f) { xVelocity = 0f; } if (Math.Abs(yVelocity) <= 0.05f) { yVelocity = 0f; } } if (isGlider) { return; } } if (moveUp) { if (((!Game1.eventUp || Game1.IsMultiplayer) && !currentLocation.isCollidingPosition(nextPosition(0), viewport, false, DamageToFarmer, isGlider, this)) || isCharging) { position.Y -= (float)(base.speed + base.addedSpeed); if (!ignoreMovementAnimations) { Sprite.AnimateUp(time, 0, ""); } base.FacingDirection = 0; faceDirection(0); } else { Microsoft.Xna.Framework.Rectangle tmp = nextPosition(0); tmp.Width /= 4; bool leftCorner = currentLocation.isCollidingPosition(tmp, viewport, false, DamageToFarmer, isGlider, this); tmp.X += tmp.Width * 3; bool rightCorner = currentLocation.isCollidingPosition(tmp, viewport, false, DamageToFarmer, isGlider, this); if (leftCorner && !rightCorner && !currentLocation.isCollidingPosition(nextPosition(1), viewport, false, DamageToFarmer, isGlider, this)) { position.X += (float)base.speed * ((float)time.ElapsedGameTime.Milliseconds / 64f); } else if (rightCorner && !leftCorner && !currentLocation.isCollidingPosition(nextPosition(3), viewport, false, DamageToFarmer, isGlider, this)) { position.X -= (float)base.speed * ((float)time.ElapsedGameTime.Milliseconds / 64f); } if (!currentLocation.isTilePassable(nextPosition(0), viewport) || !base.willDestroyObjectsUnderfoot) { Halt(); } else if (base.willDestroyObjectsUnderfoot) { new Vector2((float)(base.getStandingX() / 64), (float)(base.getStandingY() / 64 - 1)); if (currentLocation.characterDestroyObjectWithinRectangle(nextPosition(0), true)) { currentLocation.playSound("stoneCrack", NetAudio.SoundContext.Default); position.Y -= (float)(base.speed + base.addedSpeed); } else { blockedInterval += time.ElapsedGameTime.Milliseconds; } } if (onCollision != null) { onCollision(currentLocation); } } } else if (moveRight) { if (((!Game1.eventUp || Game1.IsMultiplayer) && !currentLocation.isCollidingPosition(nextPosition(1), viewport, false, DamageToFarmer, isGlider, this)) || isCharging) { position.X += (float)(base.speed + base.addedSpeed); if (!ignoreMovementAnimations) { Sprite.AnimateRight(time, 0, ""); } base.FacingDirection = 1; faceDirection(1); } else { Microsoft.Xna.Framework.Rectangle tmp2 = nextPosition(1); tmp2.Height /= 4; bool topCorner = currentLocation.isCollidingPosition(tmp2, viewport, false, DamageToFarmer, isGlider, this); tmp2.Y += tmp2.Height * 3; bool bottomCorner = currentLocation.isCollidingPosition(tmp2, viewport, false, DamageToFarmer, isGlider, this); if (topCorner && !bottomCorner && !currentLocation.isCollidingPosition(nextPosition(2), viewport, false, DamageToFarmer, isGlider, this)) { position.Y += (float)base.speed * ((float)time.ElapsedGameTime.Milliseconds / 64f); } else if (bottomCorner && !topCorner && !currentLocation.isCollidingPosition(nextPosition(0), viewport, false, DamageToFarmer, isGlider, this)) { position.Y -= (float)base.speed * ((float)time.ElapsedGameTime.Milliseconds / 64f); } if (!currentLocation.isTilePassable(nextPosition(1), viewport) || !base.willDestroyObjectsUnderfoot) { Halt(); } else if (base.willDestroyObjectsUnderfoot) { new Vector2((float)(base.getStandingX() / 64 + 1), (float)(base.getStandingY() / 64)); if (currentLocation.characterDestroyObjectWithinRectangle(nextPosition(1), true)) { currentLocation.playSound("stoneCrack", NetAudio.SoundContext.Default); position.X += (float)(base.speed + base.addedSpeed); } else { blockedInterval += time.ElapsedGameTime.Milliseconds; } } if (onCollision != null) { onCollision(currentLocation); } } } else if (moveDown) { if (((!Game1.eventUp || Game1.IsMultiplayer) && !currentLocation.isCollidingPosition(nextPosition(2), viewport, false, DamageToFarmer, isGlider, this)) || isCharging) { position.Y += (float)(base.speed + base.addedSpeed); if (!ignoreMovementAnimations) { Sprite.AnimateDown(time, 0, ""); } base.FacingDirection = 2; faceDirection(2); } else { Microsoft.Xna.Framework.Rectangle tmp3 = nextPosition(2); tmp3.Width /= 4; bool leftCorner2 = currentLocation.isCollidingPosition(tmp3, viewport, false, DamageToFarmer, isGlider, this); tmp3.X += tmp3.Width * 3; bool rightCorner2 = currentLocation.isCollidingPosition(tmp3, viewport, false, DamageToFarmer, isGlider, this); if (leftCorner2 && !rightCorner2 && !currentLocation.isCollidingPosition(nextPosition(1), viewport, false, DamageToFarmer, isGlider, this)) { position.X += (float)base.speed * ((float)time.ElapsedGameTime.Milliseconds / 64f); } else if (rightCorner2 && !leftCorner2 && !currentLocation.isCollidingPosition(nextPosition(3), viewport, false, DamageToFarmer, isGlider, this)) { position.X -= (float)base.speed * ((float)time.ElapsedGameTime.Milliseconds / 64f); } if (!currentLocation.isTilePassable(nextPosition(2), viewport) || !base.willDestroyObjectsUnderfoot) { Halt(); } else if (base.willDestroyObjectsUnderfoot) { new Vector2((float)(base.getStandingX() / 64), (float)(base.getStandingY() / 64 + 1)); if (currentLocation.characterDestroyObjectWithinRectangle(nextPosition(2), true)) { currentLocation.playSound("stoneCrack", NetAudio.SoundContext.Default); position.Y += (float)(base.speed + base.addedSpeed); } else { blockedInterval += time.ElapsedGameTime.Milliseconds; } } if (onCollision != null) { onCollision(currentLocation); } } } else if (moveLeft) { if (((!Game1.eventUp || Game1.IsMultiplayer) && !currentLocation.isCollidingPosition(nextPosition(3), viewport, false, DamageToFarmer, isGlider, this)) || isCharging) { position.X -= (float)(base.speed + base.addedSpeed); base.FacingDirection = 3; if (!ignoreMovementAnimations) { Sprite.AnimateLeft(time, 0, ""); } faceDirection(3); } else { Microsoft.Xna.Framework.Rectangle tmp4 = nextPosition(3); tmp4.Height /= 4; bool topCorner2 = currentLocation.isCollidingPosition(tmp4, viewport, false, DamageToFarmer, isGlider, this); tmp4.Y += tmp4.Height * 3; bool bottomCorner2 = currentLocation.isCollidingPosition(tmp4, viewport, false, DamageToFarmer, isGlider, this); if (topCorner2 && !bottomCorner2 && !currentLocation.isCollidingPosition(nextPosition(2), viewport, false, DamageToFarmer, isGlider, this)) { position.Y += (float)base.speed * ((float)time.ElapsedGameTime.Milliseconds / 64f); } else if (bottomCorner2 && !topCorner2 && !currentLocation.isCollidingPosition(nextPosition(0), viewport, false, DamageToFarmer, isGlider, this)) { position.Y -= (float)base.speed * ((float)time.ElapsedGameTime.Milliseconds / 64f); } if (!currentLocation.isTilePassable(nextPosition(3), viewport) || !base.willDestroyObjectsUnderfoot) { Halt(); } else if (base.willDestroyObjectsUnderfoot) { new Vector2((float)(base.getStandingX() / 64 - 1), (float)(base.getStandingY() / 64)); if (currentLocation.characterDestroyObjectWithinRectangle(nextPosition(3), true)) { currentLocation.playSound("stoneCrack", NetAudio.SoundContext.Default); position.X -= (float)(base.speed + base.addedSpeed); } else { blockedInterval += time.ElapsedGameTime.Milliseconds; } } if (onCollision != null) { onCollision(currentLocation); } } } else if (!ignoreMovementAnimations) { if (moveUp) { Sprite.AnimateUp(time, 0, ""); } else if (moveRight) { Sprite.AnimateRight(time, 0, ""); } else if (moveDown) { Sprite.AnimateDown(time, 0, ""); } else if (moveLeft) { Sprite.AnimateLeft(time, 0, ""); } } if ((blockedInterval < 3000 || (float)blockedInterval > 3750f) && blockedInterval >= 5000) { base.speed = 4; isCharging = true; blockedInterval = 0; } if (DamageToFarmer > 0 && Game1.random.NextDouble() < 0.00033333333333333332) { if (base.Name.Equals("Shadow Guy") && Game1.random.NextDouble() < 0.3) { if (Game1.random.NextDouble() < 0.5) { currentLocation.playSound("grunt", NetAudio.SoundContext.Default); return; } currentLocation.playSound("shadowpeep", NetAudio.SoundContext.Default); return; } else if (!base.Name.Equals("Shadow Girl")) { if (base.Name.Equals("Ghost")) { currentLocation.playSound("ghost", NetAudio.SoundContext.Default); return; } if (!base.Name.Contains("Slime")) { base.Name.Contains("Jelly"); } } } }