Inflate() public method

public Inflate ( int width, int height ) : void
width int
height int
return void
Esempio n. 1
0
        public override void behaviorAtGameTick(GameTime time)
        {
            base.behaviorAtGameTick(time);
            this.isEmoting = false;
            Microsoft.Xna.Framework.Rectangle boundingBox = this.GetBoundingBox();
            if (this.sprite.currentFrame < 4)
            {
                boundingBox.Inflate(Game1.tileSize * 2, Game1.tileSize * 2);
                if (!this.isInvisible || boundingBox.Contains(Game1.player.getStandingX(), Game1.player.getStandingY()))
                {
                    if (this.isInvisible)
                    {
                        if (Game1.currentLocation.map.GetLayer("Back").Tiles[(int)Game1.player.getTileLocation().X, (int)Game1.player.getTileLocation().Y].Properties.ContainsKey("NPCBarrier") || !Game1.currentLocation.map.GetLayer("Back").Tiles[(int)Game1.player.getTileLocation().X, (int)Game1.player.getTileLocation().Y].TileIndexProperties.ContainsKey("Diggable") && Game1.currentLocation.map.GetLayer("Back").Tiles[(int)Game1.player.getTileLocation().X, (int)Game1.player.getTileLocation().Y].TileIndex != 0)
                        {
                            return;
                        }
                        this.position = new Vector2(Game1.player.position.X, Game1.player.position.Y + (float)Game1.player.sprite.spriteHeight - (float)this.sprite.spriteHeight);
                        Game1.playSound(nameof(Duggy));
                        this.sprite.interval = 100f;
                        this.position        = Game1.player.getTileLocation() * (float)Game1.tileSize;
                    }
                    this.isInvisible = false;
                    this.sprite.AnimateDown(time, 0, "");
                }
            }
            if (this.sprite.currentFrame >= 4 && this.sprite.CurrentFrame < 8)
            {
                if (!this.hasDugForTreasure)
                {
                    this.getTileLocation();
                }
                boundingBox.Inflate(-Game1.tileSize * 2, -Game1.tileSize * 2);
                Game1.currentLocation.isCollidingPosition(boundingBox, Game1.viewport, false, 8, false, (Character)this);
                this.sprite.AnimateRight(time, 0, "");
                this.sprite.interval = 220f;
            }
            if (this.sprite.currentFrame >= 8)
            {
                this.sprite.AnimateUp(time, 0, "");
            }
            if (this.sprite.currentFrame < 10)
            {
                return;
            }
            this.isInvisible         = true;
            this.sprite.currentFrame = 0;
            this.hasDugForTreasure   = false;
            int     num           = 0;
            Vector2 tileLocation1 = this.getTileLocation();

            Game1.currentLocation.map.GetLayer("Back").Tiles[(int)tileLocation1.X, (int)tileLocation1.Y].TileIndex = 0;
            Game1.currentLocation.removeEverythingExceptCharactersFromThisTile((int)tileLocation1.X, (int)tileLocation1.Y);
            for (Vector2 tileLocation2 = new Vector2((float)(Game1.player.GetBoundingBox().Center.X / Game1.tileSize + Game1.random.Next(-12, 12)), (float)(Game1.player.GetBoundingBox().Center.Y / Game1.tileSize + Game1.random.Next(-12, 12))); num < 4 && ((double)tileLocation2.X <= 0.0 || (double)tileLocation2.X >= (double)Game1.currentLocation.map.Layers[0].LayerWidth || ((double)tileLocation2.Y <= 0.0 || (double)tileLocation2.Y >= (double)Game1.currentLocation.map.Layers[0].LayerHeight) || (Game1.currentLocation.map.GetLayer("Back").Tiles[(int)tileLocation2.X, (int)tileLocation2.Y] == null || Game1.currentLocation.isTileOccupied(tileLocation2, "") || (!Game1.currentLocation.isTilePassable(new Location((int)tileLocation2.X, (int)tileLocation2.Y), Game1.viewport) || tileLocation2.Equals(new Vector2((float)(Game1.player.getStandingX() / Game1.tileSize), (float)(Game1.player.getStandingY() / Game1.tileSize))))) || (Game1.currentLocation.map.GetLayer("Back").Tiles[(int)tileLocation2.X, (int)tileLocation2.Y].Properties.ContainsKey("NPCBarrier") || !Game1.currentLocation.map.GetLayer("Back").Tiles[(int)tileLocation2.X, (int)tileLocation2.Y].TileIndexProperties.ContainsKey("Diggable") && Game1.currentLocation.map.GetLayer("Back").Tiles[(int)tileLocation2.X, (int)tileLocation2.Y].TileIndex != 0)); ++num)
            {
                tileLocation2 = new Vector2((float)(Game1.player.GetBoundingBox().Center.X / Game1.tileSize + Game1.random.Next(-2, 2)), (float)(Game1.player.GetBoundingBox().Center.Y / Game1.tileSize + Game1.random.Next(-2, 2)));
            }
        }
		public override void Update()
		{
			Rectangle value = new Rectangle(0, 0, 32, 48);
			value.Inflate(1600, 1600);
			int x = value.X;
			int y = value.Y;
			if (this.npc != -1)
			{
				if (!Main.npc[this.npc].active || Main.npc[this.npc].type != 488 || Main.npc[this.npc].ai[0] != (float)this.Position.X || Main.npc[this.npc].ai[1] != (float)this.Position.Y)
				{
					this.Deactivate();
					return;
				}
			}
			else
			{
				TETrainingDummy.FillPlayerHitboxes();
				value.X = (int)(this.Position.X * 16) + x;
				value.Y = (int)(this.Position.Y * 16) + y;
				bool flag = false;
				foreach (KeyValuePair<int, Rectangle> current in TETrainingDummy.playerBox)
				{
					if (current.Value.Intersects(value))
					{
						flag = true;
						break;
					}
				}
				if (flag)
				{
					this.Activate();
				}
			}
		}
Esempio n. 3
0
        public void update(GameTime gameTime)
        {
            move(player.getPos() - pos);

            camArea = levelManager.getCurrentLevelArea();
            camArea.Inflate(-200, -200);

            if (pos.X < camArea.Left)
                pos.X = camArea.Left;
            else if (pos.X > camArea.Right)
                pos.X = camArea.Right;
            if (pos.Y > camArea.Bottom)
                pos.Y = camArea.Bottom;
            else if (pos.Y < camArea.Top)
                pos.Y = camArea.Top;

            /*if (pos.X - screenPos.X < levelManager.getCurrentLevelArea().Left)
                pos.X = levelManager.getCurrentLevelArea().Left + screenPos.X;
            else if (pos.X + screenPos.X > levelManager.getCurrentLevelArea().Right)
                pos.X = levelManager.getCurrentLevelArea().Right - screenPos.X;
            if (pos.Y + screenPos.Y > levelManager.getCurrentLevelArea().Bottom)
                pos.Y = levelManager.getCurrentLevelArea().Bottom - screenPos.Y;
            else if (pos.Y - screenPos.Y < levelManager.getCurrentLevelArea().Top)
                pos.Y = levelManager.getCurrentLevelArea().Top + screenPos.Y;*/

            updateTransform();
            //Console.WriteLine(transform);
        }
Esempio n. 4
0
        public static Rectangle CreateCenteredRectangle(Vector2 location, int width, int height)
        {
            Rectangle rect = new Rectangle((int)location.X , (int)location.Y, 0, 0);
            rect.Inflate (width, height);

            return rect;
        }
Esempio n. 5
0
        public override void Update()
        {
            Rectangle rectangle = new Rectangle(0, 0, 32, 48);
            rectangle.Inflate(1600, 1600);
            int num1 = rectangle.X;
            int num2 = rectangle.Y;
            if (this.npc != -1)
            {
                if (Main.npc[npc].active && Main.npc[npc].type == 488 && (Main.npc[npc].ai[0] == Position.X && Main.npc[npc].ai[1] == Position.Y))
                    return;

                Deactivate();
            }
            else
            {
                FillPlayerHitboxes();
                rectangle.X = (int)Position.X * 16 + num1;
                rectangle.Y = (int)Position.Y * 16 + num2;
                bool flag = false;
                foreach (KeyValuePair<int, Rectangle> keyValuePair in playerBox)
                {
                    if (keyValuePair.Value.Intersects(rectangle))
                    {
                        flag = true;
                        break;
                    }
                }

                if (!flag)
                    return;

                Activate();
            }
        }
 /// <summary>
 /// Checks if the ship can be placed on its current position.
 /// If the placing is allowed for the fields, they will marked green.
 /// If the placing is forbidden for the fields, they will marked red.
 /// </summary>
 /// <param name="p">The playground with the fields</param>
 /// <param name="currentShip">The current ship</param>
 public static void HandleFieldCheck(Playground p, Ship currentShip)
 {
     int counter = 0;
     List<Field> markedFields = new List<Field>();
     foreach (Field field in p.fields)
     {
         int smaller = Convert.ToInt32(field.Size.Width / 2.1) * -1;
         Rectangle rect = new Rectangle(currentShip.Rectangle.X, currentShip.Rectangle.Y, currentShip.Rectangle.Width, currentShip.Rectangle.Height);
         rect.Inflate(smaller,smaller);
         if ((field.ReferencedShip == null || field.ReferencedShip == currentShip) && field.Rectangle.Intersects(rect))
         {
             field.SetColor(Enum.FieldColor.Green);
             counter++;
             markedFields.Add(field);
         }
         else
         {
             field.ResetColor();
         }
     }
     if (counter == currentShip.Size)
     {
         currentShip.OverlayColor = Color.Green;
         AppCache.CurrentMatch.FooterMenu.Get("btnPlace").Visible = true;
     }
     else
     {
         currentShip.OverlayColor = Color.Red;
         AppCache.CurrentMatch.FooterMenu.Get("btnPlace").Visible = false;
         foreach (Field f in markedFields)
         {
             f.SetColor(Enum.FieldColor.Red);
         }
     }
 }
Esempio n. 7
0
 public GameNode(SpriteSheet spriteSheet) : base(spriteSheet) 
 {
     bounds = new Rectangle(0, 0, Config.WorldBoundsX, Config.WorldBoundsY);
     bounds.Inflate((int)(this.Sprite.Origin.X * 3), (int)(this.Sprite.Origin.Y * 3));
     hitTimer = new Timer();
     hitTimer.Fire += new NotifyHandler(hitTimer_Fire);
 }
        /// <summary>
        /// Copys a rectangle and inflates it
        /// </summary>
        /// <param name="source">Rectangle to copy and inflate</param>
        /// <returns>Inflated rectangle</returns>
        public static Rectangle PadRectangle(Rectangle source, float scaleX, float scaleY)
        {
            //return new Rectangle((int)(source.X * scale), (int)(source.Y * scale), (int)(source.Width * scale), (int)(source.Height * scale));

            //inflate and return copy
            source.Inflate((int)(source.Width * scaleX), (int)(source.Height * scaleY));
            return source;
        }
Esempio n. 9
0
 public void AddStructure(Microsoft.Xna.Framework.Rectangle area, int padding = 0)
 {
     lock (this._lock)
     {
         area.Inflate(padding, padding);
         this._structures.Add(area);
     }
 }
Esempio n. 10
0
        public void Update(GraphicsDevice graphicsdevice)
        {
            var worldAtZero = ScreenToWorld(Vector2.Zero);
            var worldAtView = ScreenToWorld(new Vector2(Moxy.Graphics.Viewport.Width, Moxy.Graphics.Viewport.Height));
            ViewFrustrum = new Rectangle((int)Math.Floor(worldAtZero.X), (int)Math.Floor(worldAtZero.Y), (int)Math.Ceiling(worldAtView.X - worldAtZero.X),
                                         (int)Math.Ceiling(worldAtView.Y - worldAtZero.Y));
            ViewFrustrum.Inflate(150, 150);
            if (ViewTargets.Count > 0)
            {
                Vector2 min = ViewTargets[0].Location;
                Vector2 max = ViewTargets[0].Location;

                for (int i = 1; i < ViewTargets.Count; i++)
                {
                    if (ViewTargets[i].Location.X < min.X) min.X = ViewTargets[i].Location.X;
                    else if (ViewTargets[i].Location.X > max.X) max.X = ViewTargets[i].Location.X;
                    if (ViewTargets[i].Location.Y < min.Y) min.Y = ViewTargets[i].Location.Y;
                    else if (ViewTargets[i].Location.Y > max.Y) max.Y = ViewTargets[i].Location.Y;
                }

                Rectangle rect = new Rectangle ((int)min.X, (int)min.Y,
                    (int)(max.X - min.X), (int)(max.Y - min.Y));

                if (UseBounds)
                {
                    if (rect.Width < MinimumSize.Width)
                        rect.Inflate((int)(MinimumSize.Width - rect.Width) / 2, 0);

                    if (rect.Height < MinimumSize.Height)
                        rect.Inflate(0, (int)(MinimumSize.Height - rect.Height) / 2);
                }

                rect.Inflate (InflateAmount, InflateAmount);
                PlayerFrustrum = rect;

                desiredPosition = new Vector2(rect.X, rect.Y);

                float widthdiff = ((float)graphicsdevice.Viewport.Width) / ((float)rect.Width);
                float heightdiff = ((float)graphicsdevice.Viewport.Height) / ((float)rect.Height);
                desiredZoom = Math.Min (widthdiff, heightdiff);

            }

            Position = Vector2.Lerp(Position, desiredPosition, 0.1f);
            Zoom = MathHelper.Lerp(Zoom, desiredZoom, 0.1f);
        }
Esempio n. 11
0
 public void DrawCellBase(PathCell cell, Rectangle rectangle)
 {
     if (cell.Path != null && cell.Path.IsValid)
     {
         spriteBatch.Draw(parent.BlankTexture, rectangle, Color.Blue);
     }
     rectangle.Inflate(-CellSize / 8, -CellSize / 8);
     spriteBatch.Draw(parent.BlankTexture, rectangle, cell.Color.ToXnaColor());
 }
Esempio n. 12
0
 protected override bool _AttemptActivity(Farm farm)
 {
     Microsoft.Xna.Framework.Rectangle map_bounds = new Microsoft.Xna.Framework.Rectangle(0, 0, farm.map.Layers[0].LayerWidth, farm.map.Layers[0].LayerHeight);
     for (int i = 0; i < 5; i++)
     {
         Vector2 random_point = Utility.getRandomPositionInThisRectangle(map_bounds, Game1.random);
         random_point.X = (int)random_point.X;
         random_point.Y = (int)random_point.Y;
         Microsoft.Xna.Framework.Rectangle rect = new Microsoft.Xna.Framework.Rectangle((int)random_point.X, (int)random_point.Y, 1, 1);
         if (!farm.isTileLocationTotallyClearAndPlaceableIgnoreFloors(random_point))
         {
             continue;
         }
         rect.Inflate(1, 1);
         bool fail = false;
         for (int x = rect.Left; x < rect.Right; x++)
         {
             for (int y = rect.Top; y < rect.Bottom; y++)
             {
                 if ((float)x != random_point.X || (float)y != random_point.Y)
                 {
                     if (!farm.isTileOnMap(new Vector2(x, y)))
                     {
                         fail = true;
                         break;
                     }
                     if (farm.isTileOccupiedIgnoreFloors(new Vector2(x, y)))
                     {
                         fail = true;
                         break;
                     }
                     if (!farm.isTilePassable(new Location(x, y), Game1.viewport))
                     {
                         fail = true;
                         break;
                     }
                     if (farm.getBuildingAt(new Vector2(x, y)) != null)
                     {
                         fail = true;
                         break;
                     }
                 }
             }
             if (fail)
             {
                 break;
             }
         }
         if (!fail)
         {
             activityPosition  = random_point;
             activityDirection = 2;
             return(true);
         }
     }
     return(false);
 }
Esempio n. 13
0
        public override void DrawModel(SpriteBatch spriteBatch)
        {
            foreach (var selectedCard in selectedCards) {
                var halo = new Rectangle(selectedCard.Position.X, selectedCard.Position.Y, selectedCard.Position.Width, selectedCard.Position.Height);
                halo.Inflate(2, 2);
                spriteBatch.Draw(haloTexture, halo, Color.White);
            }

            base.DrawModel(spriteBatch);
        }
Esempio n. 14
0
 public TileBackground(Texture2D _sprite, Vector2 _pos, Vector2 _vel, int _hp, LevelManager l)
     : base(_sprite, _pos, _vel, _hp, l)
 {
     rect = l.getCurrentLevelArea();
     rect.Inflate(10000, 10000);
     pos.X -= 5000;
     pos.Y -= 5000;
     center.X += 5000;
     center.Y += 5000;
     rotation = (float)Game1.random.NextDouble() * (float)Math.PI * 2.0f;
 }
Esempio n. 15
0
        //Texture2D tank, turret;
        public void Init(Random r, Rectangle bounds)
        {
            bounds.Inflate(-boundingRadius, -boundingRadius);

            position.X = (float)(bounds.Left + bounds.Width * r.NextDouble());
            position.Y = (float)(bounds.Top + bounds.Height * r.NextDouble());

            rotation = (float)(r.NextDouble() * MathHelper.TwoPi);

            random = r;
        }
Esempio n. 16
0
        public WorldBorder(Game game, Rectangle innerBorder, PhysicsSimulator physicsSimulator)
        {
            this.game = game;

            var outerBorder = new Rectangle(innerBorder.X, innerBorder.X, innerBorder.Width, innerBorder.Height);
            outerBorder.Inflate(buffer, buffer);

            AddLeftBorder(physicsSimulator, innerBorder, outerBorder);
            AddRightBorder(physicsSimulator, innerBorder, outerBorder);
            AddTopBorder(physicsSimulator, innerBorder, outerBorder);
            AddBottomBorder(physicsSimulator, innerBorder, outerBorder);
        }
Esempio n. 17
0
 public Gauge(Rectangle pos, float max, Color color, Color fillColor)
 {
     // Init
     _max = max;
     _gaugeColor = color;
     _fillColor = fillColor;
     _position = new Vector2(pos.X, pos.Y);
     _current = 0;
     _gauge = pos;
     _fill = new Rectangle(pos.X, pos.Y, pos.Width, pos.Height);
     _fill.Inflate(-2, 0);
 }
		public static void UpdateDummies()
		{
			Dictionary<int, Rectangle> dictionary = new Dictionary<int, Rectangle>();
			bool flag = false;
			Rectangle value = new Rectangle(0, 0, 32, 48);
			value.Inflate(1600, 1600);
			int num = value.X;
			int num2 = value.Y;
			for (int i = 0; i < 1000; i++)
			{
				if (TargetDummy.dummies[i] != null)
				{
					TargetDummy.dummies[i].whoAmI = i;
					if (TargetDummy.dummies[i].npc != -1)
					{
						if (!Main.npc[TargetDummy.dummies[i].npc].active || Main.npc[TargetDummy.dummies[i].npc].type != 488 || Main.npc[TargetDummy.dummies[i].npc].ai[0] != (float)TargetDummy.dummies[i].x || Main.npc[TargetDummy.dummies[i].npc].ai[1] != (float)TargetDummy.dummies[i].y)
						{
							TargetDummy.dummies[i].Deactivate();
						}
					}
					else
					{
						if (!flag)
						{
							for (int j = 0; j < 255; j++)
							{
								if (Main.player[j].active)
								{
									dictionary[j] = Main.player[j].getRect();
								}
							}
							flag = true;
						}
						value.X = (int)(TargetDummy.dummies[i].x * 16) + num;
						value.Y = (int)(TargetDummy.dummies[i].y * 16) + num2;
						bool flag2 = false;
						foreach (KeyValuePair<int, Rectangle> current in dictionary)
						{
							if (current.Value.Intersects(value))
							{
								flag2 = true;
								break;
							}
						}
						if (flag2)
						{
							TargetDummy.dummies[i].Activate();
						}
					}
				}
			}
		}
Esempio n. 19
0
 public Hud(ContentManager content, Rectangle _safeArea)
 {
     safeArea = _safeArea;
     safeArea.Inflate(-40, -40);
     lives = 0;
     score = 0;
     fuel = 0;
     peeps = 0;
     text = content.Load<SpriteFont>("Fonts/OCR");
     lifeIcon = new Sprite(content.Load<Texture2D>("Sprites/lifeIcon"));
     peepIcon = new Sprite(content.Load<Texture2D>("Sprites/peepIcon"));
     bar = new Sprite(content.Load<Texture2D>("Sprites/pixel"));
 }
        public Castle(GameContent gameContent, Shape shape, Vector2 tileCenter)
        {
            this.Shape = shape;
            this.gameContent = gameContent;

            this.position = tileCenter;

            int halfSize = Tile.Width / 2;
            BoundingRectangle = new Rectangle((int)position.X - halfSize, (int)position.Y - halfSize,
                2 * halfSize, 2 * halfSize);

            AttackRectangle = BoundingRectangle; AttackRectangle.Inflate(200, 600);
        }
Esempio n. 21
0
 internal virtual void Draw()
 {
     int height = (int)GUIHelper.StrSize(text).Y + 8;
     Rectangle option = new Rectangle(owner.position.X, owner.position.Y + yOff, height + width, height);
     GUIHelper.FillRect(option, new Color(29, 29, 29, alpha));
     GUIHelper.OutlineRect(option, new Color(0, 0, 0, alpha));
     if (option.IntersectsMouse())
     {
         option.Inflate(-3, -3);
         GUIHelper.sb.Draw(SelectedTexture, option, new Color(255, 255, 255, alpha));
         GUIHelper.OutlineRect(option, new Color(0, 0, 0, alpha));
     }
     GUIHelper.DrawStr(text, owner.position + new Position(4 + height, 4 + yOff), new Color(255, 255, 255, alpha));
     GUIHelper.DrawLn(owner.position + new Position(height, yOff), owner.position + new Position(height, height + yOff), new Color(0, 0, 0, alpha));
 }
Esempio n. 22
0
        public TextBox(Game game, SpriteBatch spriteBatch, SpriteFont spriteFont, Rectangle bound)
            : base(game)
        {
            this.bound = bound;
            this.borderBound = bound;
            this.game = game;
            this.spriteBatch = spriteBatch;
            this.spriteFont = spriteFont;

            borderBound.Inflate(borderSize, borderSize);

            //bound.Inflate(-5, 5);
            borderTexture = new Texture2D(game.GraphicsDevice, 1, 1);
            texture = new Texture2D(game.GraphicsDevice, 1, 1);
            borderTexture.SetData(new[] { Color.Black });
            texture.SetData(new[] { Color.White });
        }
Esempio n. 23
0
 public static void UpdateDummies()
 {
     Dictionary<int, Rectangle> dictionary = new Dictionary<int, Rectangle>();
     bool flag1 = false;
     Rectangle rectangle = new Rectangle(0, 0, 32, 48);
     rectangle.Inflate(1600, 1600);
     int num1 = rectangle.X;
     int num2 = rectangle.Y;
     for (int index1 = 0; index1 < 1000; ++index1)
     {
         if (TargetDummy.dummies[index1] != null)
         {
             TargetDummy.dummies[index1].whoAmI = index1;
             if (TargetDummy.dummies[index1].npc != -1)
             {
                 if (!Main.npc[TargetDummy.dummies[index1].npc].active || Main.npc[TargetDummy.dummies[index1].npc].type != 488 || ((double)Main.npc[TargetDummy.dummies[index1].npc].ai[0] != (double)TargetDummy.dummies[index1].x || (double)Main.npc[TargetDummy.dummies[index1].npc].ai[1] != (double)TargetDummy.dummies[index1].y))
                     TargetDummy.dummies[index1].Deactivate();
             }
             else
             {
                 if (!flag1)
                 {
                     for (int index2 = 0; index2 < (int)byte.MaxValue; ++index2)
                     {
                         if (Main.player[index2].active)
                             dictionary[index2] = Main.player[index2].getRect();
                     }
                     flag1 = true;
                 }
                 rectangle.X = (int)TargetDummy.dummies[index1].x * 16 + num1;
                 rectangle.Y = (int)TargetDummy.dummies[index1].y * 16 + num2;
                 bool flag2 = false;
                 foreach (KeyValuePair<int, Rectangle> keyValuePair in dictionary)
                 {
                     if (keyValuePair.Value.Intersects(rectangle))
                     {
                         flag2 = true;
                         break;
                     }
                 }
                 if (flag2)
                     TargetDummy.dummies[index1].Activate();
             }
         }
     }
 }
Esempio n. 24
0
        public static bool GetBoundingBox_Prefix(Horse __instance, ref Rectangle __result)
        {
            if (__instance.Sprite == null)
            {
                __result = Microsoft.Xna.Framework.Rectangle.Empty;
                return(false);
            }

            Vector2 vector = __instance.Position;
            int     width  = __instance.GetSpriteWidthForPositioning() * 4 * 3 / 4;
            var     box    = new Microsoft.Xna.Framework.Rectangle((int)vector.X + 8, (int)vector.Y + 16, width, 32);

            box.Inflate(-36, 0);
            __result = box;

            return(false);
        }
Esempio n. 25
0
        /// <summary>
        /// clears nodes of any previous path specific information
        /// </summary>
        public void PrepForPath(Rectangle physBox, bool suppressReset = false)
        {
            if ( !suppressReset) BuildGridFromSnapshot();

            physBox.Inflate(physBox.Width / 2, physBox.Height / 2);

            foreach (GridNode node in nodes)
            {
                if (!suppressReset) node.SetTrace(null, 0, 0);
                node.ClearAdjustments();

                foreach (MetaObstacle obstacle in currentObstacles)
                {
                    if (obstacle.bounds.Intersects(CenterOnNode(node, physBox)))
                    {
                        node.ApplyAdjustment(obstacle.pathingWeight);
                    }
                }
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HypercubeDisplay"/> class.
        /// </summary>
        /// <param name="displayRectangle">The display rectangle.</param>
        /// <param name="hypercubeCount">The number of hypercubes.</param>
        /// <param name="random">The PRNG.</param>
        /// <param name="layerDepth">The layer depth.</param>
        public HypercubeDisplay(Rectangle displayRectangle, int hypercubeCount, Random random, float layerDepth)
        {
            this.DisplayRectangle = displayRectangle;
            this.layerDepth = layerDepth;
            this.hypercubes = new List<Hypercube>();
            Rectangle bounceRectangle = new Rectangle(this.DisplayRectangle.X, this.DisplayRectangle.Y, this.DisplayRectangle.Width, this.DisplayRectangle.Height);
            bounceRectangle.Inflate(this.DisplayRectangle.Height, this.DisplayRectangle.Width);

            for (int i = 0; i < hypercubeCount; i++)
            {
                float greyscale = MathHelper.Lerp(0f, 1f, (i + 1f) / (hypercubeCount + 2f));
                this.hypercubes.Add(new Hypercube(
                    new Vector2(displayRectangle.Center.X, displayRectangle.Center.Y),
                    new Color(0, 0, greyscale, 1f),
                    this.DisplayRectangle,
                    bounceRectangle,
                    random,
                    this.layerDepth + 0.001f * (i + 1)));
            }
        }
Esempio n. 27
0
            public virtual void FindNewTarget()
            {
                isPerchedParrot = false;
                firstBounce     = false;
                startPosition   = position;
                moveTime        = 0f;
                moveDuration    = 1f;
                Microsoft.Xna.Framework.Rectangle rect = _perch.upgradeRect;
                if ((UpgradeState)_perch.currentState == UpgradeState.Complete)
                {
                    flyAway      = true;
                    moveDuration = 5f;
                    rect.Inflate(5, 0);
                }
                targetPosition = (Utility.getRandomPositionInThisRectangle(rect, Game1.random) + new Vector2(0.5f, 0.5f)) * 64f;
                Vector2 offset = Vector2.Zero;

                offset.X = targetPosition.X - position.X;
                offset.Y = targetPosition.Y - position.Y;
                if (offset.X < 0f)
                {
                    flipped = false;
                }
                else if (offset.X > 0f)
                {
                    flipped = true;
                }
                if (Math.Abs(offset.X) > Math.Abs(offset.Y))
                {
                    baseFrame = 2;
                }
                else if (offset.Y > 0f)
                {
                    baseFrame = 5;
                }
                else
                {
                    baseFrame = 8;
                }
            }
 /// <summary>
 /// Returns all fields, which are good for placing the ship
 /// </summary>
 /// <param name="p">The playground with the fields</param>
 /// <param name="currentShip">The current ship</param>
 /// <returns></returns>
 public static List<Field> GetFields(Playground p, Ship currentShip)
 {
     List<Field> markedFields = new List<Field>();
     foreach (Field field in p.fields)
     {
         int smaller = Convert.ToInt32(field.Size.Width / 2.1) * -1;
         Rectangle rect = new Rectangle(currentShip.Rectangle.X, currentShip.Rectangle.Y, currentShip.Rectangle.Width, currentShip.Rectangle.Height);
         rect.Inflate(smaller, smaller);
         if ((field.ReferencedShip == null || field.ReferencedShip == currentShip) && field.Rectangle.Intersects(rect))
         {
             markedFields.Add(field);
         }
     }
     if (markedFields.Count == currentShip.Size)
     {
         return markedFields;
     }
     else
     {
         return null;
     }
 }
Esempio n. 29
0
 public bool IsNearRotated(BaseObject r, float factor)
 {
     Rectangle inflatedRectangle = new Rectangle(X, Y, Width, Height);
     inflatedRectangle.Inflate((int)(Width * factor), (int)(Height * factor));
     return r.Intersects(inflatedRectangle);
 }
Esempio n. 30
0
        public bool IsNear(Rectangle r, float factor)
        {
            /*Vector2 point1 = new Vector2(r.X, r.Y);
            Vector2 point2 = new Vector2(r.X + r.Width, r.Y);
            Vector2 point3 = new Vector2(r.X + r.Width, r.Y + r.Height);
            Vector2 point4 = new Vector2(r.X, r.Y + r.Height);
            return IsNear(point1, factor) || IsNear(point2, factor) || IsNear(point3, factor) || IsNear(point4, factor);*/

            //int adjustedWidth = (int)(this.Width + this.Width * factor * 2);
            //int adjustedHeight = (int)(this.Width + this.Height * factor * 2);
            //return new Rectangle((int)this.CenterPoint.X - adjustedWidth / 2, (int)this.CenterPoint.Y - adjustedHeight / 2, adjustedWidth, adjustedHeight).Intersects(r);
            Rectangle inflatedRectangle = new Rectangle(X, Y, Width, Height);
            inflatedRectangle.Inflate((int)(Width * factor), (int)(Height * factor));
            return inflatedRectangle.Intersects(r);
        }
Esempio n. 31
0
 public bool IsNear(Vector2 point, float factor)
 {
     /*int factorWidth = (int)(this.Width * factor),
         factorHeight = (int)(this.Height * factor);
     return (point.X > this.X - factorWidth && point.X < this.X + this.Width + factorWidth &&
         point.Y > this.Y - factorHeight && point.Y < this.Y + this.Height + factorHeight);*/
     Rectangle inflatedRectangle = new Rectangle(X, Y, Width, Height);
     inflatedRectangle.Inflate((int)(Width * factor), (int)(Height * factor));
     return inflatedRectangle.Contains((int)point.X, (int)point.Y);
 }
Esempio n. 32
0
 public bool IsNear(Vector2 point)
 {
     Rectangle inflatedRectangle = new Rectangle(X, Y, Width, Height);
     inflatedRectangle.Inflate((int)(Width), (int)(Height));
     return inflatedRectangle.Contains((int)point.X, (int)point.Y);
 }
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here
            backgroundRect = new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
            saviour.Update(gameTime, Game.Window.ClientBounds);
            if (((Game1)Game).chances4 > 0)
                loose = false;
            else if (((Game1)Game).chances4 <= 0 && steps == -1)
                loose = true;
            if (((Game1)Game).avataar == 1)
            {
                saviour.currentFrame.Y = 1;
            }
            else if (((Game1)Game).avataar == 2)
            {
                saviour.currentFrame.Y = 2;
            }
            else if (((Game1)Game).avataar == 3)
            {
                saviour.currentFrame.Y = 3;
            }
            else if (((Game1)Game).avataar == 3)
            {
                saviour.currentFrame.Y = 3;
            }
            MouseState mouseState = Mouse.GetState();
            if (mouseState.X != prevMouseState.X ||
            mouseState.Y != prevMouseState.Y)
            {
                arr_position = new Vector2(mouseState.X, mouseState.Y);
                prevMouseState = mouseState;
            }
            arrowRect = new Rectangle((int)arr_position.X, (int)arr_position.Y, 32, 32);
            homeRect = new Rectangle(900, 150, 250, 150);
            retryRect = new Rectangle(50, 150, 250, 150);
            if (arrowRect.Intersects(homeRect) && mouseState.LeftButton == ButtonState.Pressed)
            {
                homeRect.Inflate(10, 10);
                Game.Exit();

            }
            else if (arrowRect.Intersects(homeRect))
            {
                homeRect.Inflate(10, 10);
            }

            foreach (Brick s in spriteList)
            {
                s.Update(gameTime, Game.Window.ClientBounds);
                if (s.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 0))
                    saviour.position.X = s.position.X + 50;
                if (s.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 1))
                    saviour.position.Y = s.position.Y + 50;
                if (s.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 2))
                    saviour.position.Y = s.position.Y - 50;
                if (s.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 3))
                    saviour.position.X = s.position.X - 50;
            }
            KeyboardState keyboardState = Keyboard.GetState();

            if (arrowRect.Intersects(retryRect) && mouseState.LeftButton == ButtonState.Pressed)
            {
                retryRect.Inflate(10, 10);
                isRetry = true;

            }
            else if (arrowRect.Intersects(retryRect))
            {
                retryRect.Inflate(10, 10);
            }
            dest1.Update(gameTime, Game.Window.ClientBounds);
            dest2.Update(gameTime, Game.Window.ClientBounds);
            dest3.Update(gameTime, Game.Window.ClientBounds);
            dest4.Update(gameTime, Game.Window.ClientBounds);
            dest5.Update(gameTime, Game.Window.ClientBounds);
            dest6.Update(gameTime, Game.Window.ClientBounds);

            goal1.Update(gameTime, Game.Window.ClientBounds);
            goal2.Update(gameTime, Game.Window.ClientBounds);
            goal3.Update(gameTime, Game.Window.ClientBounds);
            goal4.Update(gameTime, Game.Window.ClientBounds);
            goal5.Update(gameTime, Game.Window.ClientBounds);
            goal6.Update(gameTime, Game.Window.ClientBounds);
            if (goal1.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 0) && (keyboardState.IsKeyDown(Keys.Left)))
            {
                if ((goal1.position.Y == goal5.position.Y) && ((goal5.position.X == goal1.position.X - 50)))
                {
                    goal1.position.X = goal1.position.X;
                    saviour.position.X = goal1.position.X + 50;
                }
                else if ((goal1.position.Y == goal2.position.Y) && ((goal2.position.X == goal1.position.X - 50)))
                {
                    goal1.position.X = goal1.position.X;
                    saviour.position.X = goal1.position.X + 50;
                }
                else if ((goal1.position.Y == goal3.position.Y) && ((goal3.position.X == goal1.position.X - 50)))
                {
                    goal1.position.X = goal1.position.X;
                    saviour.position.X = goal1.position.X + 50;
                }
                else if ((goal1.position.Y == goal4.position.Y) && ((goal4.position.X == goal1.position.X - 50)))
                {
                    goal1.position.X = goal1.position.X;
                    saviour.position.X = goal1.position.X + 50;
                }
                else if ((goal1.position.Y == goal6.position.Y) && ((goal6.position.X == goal1.position.X - 50)))
                {
                    goal1.position.X = goal1.position.X;
                    saviour.position.X = goal1.position.X + 50;
                }
                else
                {
                    goal1.position.X = goal1.position.X - 50;
                    saviour.position.X = saviour.position.X;
                }

                if (saviour.position.X <= 400)
                    saviour.position.X = 400;
                if (goal1.position.X <= 350)
                    goal1.position.X = 350;

            }
            if (goal1.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 2) && (keyboardState.IsKeyDown(Keys.Down)))
            {
                if ((goal1.position.X == goal5.position.X) && ((goal1.position.Y == goal5.position.Y - 50)))
                {
                    goal1.position.Y = goal1.position.Y;
                    saviour.position.Y = goal1.position.Y - 50;
                }
                else if ((goal1.position.X == goal2.position.X) && ((goal1.position.Y == goal2.position.Y - 50)))
                {
                    goal1.position.Y = goal1.position.Y;
                    saviour.position.Y = goal1.position.Y - 50;
                }
                else if ((goal1.position.X == goal3.position.X) && ((goal1.position.Y == goal3.position.Y - 50)))
                {
                    goal1.position.Y = goal1.position.Y;
                    saviour.position.Y = goal1.position.Y - 50;
                }
                else if ((goal1.position.X == goal4.position.X) && ((goal1.position.Y == goal4.position.Y - 50)))
                {
                    goal1.position.Y = goal1.position.Y;
                    saviour.position.Y = goal1.position.Y - 50;
                }
                else if ((goal1.position.X == goal6.position.X) && ((goal1.position.Y == goal6.position.Y - 50)))
                {
                    goal1.position.Y = goal1.position.Y;
                    saviour.position.Y = goal1.position.Y - 50;
                }
                else
                {
                    goal1.position.Y = goal1.position.Y + 50;
                    saviour.position.Y = saviour.position.Y;
                }

                if (saviour.position.Y >= 500)
                    saviour.position.Y = 500;
                if (goal1.position.Y >= 550)
                    goal1.position.Y = 550;

            }
            if (goal1.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 1) && (keyboardState.IsKeyDown(Keys.Up)))
            {
                if ((goal1.position.X == goal5.position.X) && ((goal1.position.Y == goal5.position.Y + 50)))
                {
                    goal1.position.Y = goal1.position.Y;
                    saviour.position.Y = goal1.position.Y + 50;
                }
                else if ((goal1.position.X == goal2.position.X) && ((goal1.position.Y == goal2.position.Y + 50)))
                {
                    goal1.position.Y = goal1.position.Y;
                    saviour.position.Y = goal1.position.Y + 50;
                }
                else if ((goal1.position.X == goal3.position.X) && ((goal1.position.Y == goal3.position.Y + 50)))
                {
                    goal1.position.Y = goal1.position.Y;
                    saviour.position.Y = goal1.position.Y + 50;
                }
                else if ((goal1.position.X == goal4.position.X) && ((goal1.position.Y == goal4.position.Y + 50)))
                {
                    goal1.position.Y = goal1.position.Y;
                    saviour.position.Y = goal1.position.Y + 50;
                }
                else if ((goal1.position.X == goal6.position.X) && ((goal1.position.Y == goal6.position.Y + 50)))
                {
                    goal1.position.Y = goal1.position.Y;
                    saviour.position.Y = goal1.position.Y + 50;
                }
                else
                {
                    goal1.position.Y = goal1.position.Y - 50;
                    saviour.position.Y = saviour.position.Y;
                }

                if (saviour.position.Y <= 200)
                    saviour.position.Y = 200;
                if (goal1.position.Y <= 150)
                    goal1.position.Y = 150;

            }
            if (goal1.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 3) && (keyboardState.IsKeyDown(Keys.Right)))
            {
                if ((goal1.position.Y == goal5.position.Y) && ((goal1.position.X == goal5.position.X - 50)))
                {
                    goal1.position.X = goal1.position.X;
                    saviour.position.X = goal1.position.X - 50;
                }
                else if ((goal1.position.Y == goal2.position.Y) && ((goal1.position.X == goal2.position.X - 50)))
                {
                    goal1.position.X = goal1.position.X;
                    saviour.position.X = goal1.position.X - 50;
                }
                else if ((goal1.position.Y == goal3.position.Y) && ((goal1.position.X == goal3.position.X - 50)))
                {
                    goal1.position.X = goal1.position.X;
                    saviour.position.X = goal1.position.X - 50;
                }
                else if ((goal1.position.Y == goal4.position.Y) && ((goal1.position.X == goal4.position.X - 50)))
                {
                    goal1.position.X = goal1.position.X;
                    saviour.position.X = goal1.position.X - 50;
                }
                else if ((goal1.position.Y == goal6.position.Y) && ((goal1.position.X == goal6.position.X - 50)))
                {
                    goal1.position.X = goal1.position.X;
                    saviour.position.X = goal1.position.X - 50;
                }
                else
                {
                    goal1.position.X = goal1.position.X + 50;
                    saviour.position.X = saviour.position.X;
                }

                if (saviour.position.X >= 700)
                    saviour.position.X = 700;
                if (goal1.position.X >= 750)
                    goal1.position.X = 750;

            }

            if (goal5.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 0) && (keyboardState.IsKeyDown(Keys.Left)))
            {

                if ((goal1.position.Y == goal5.position.Y) && ((goal1.position.X == goal5.position.X - 50)))
                {
                    goal5.position.X = goal5.position.X;
                    saviour.position.X = goal5.position.X + 50;
                }
                else if ((goal2.position.Y == goal5.position.Y) && ((goal2.position.X == goal5.position.X - 50)))
                {
                    goal5.position.X = goal5.position.X;
                    saviour.position.X = goal5.position.X + 50;
                }
                else if ((goal3.position.Y == goal5.position.Y) && ((goal3.position.X == goal5.position.X - 50)))
                {
                    goal5.position.X = goal5.position.X;
                    saviour.position.X = goal5.position.X + 50;
                }
                else if ((goal4.position.Y == goal5.position.Y) && ((goal4.position.X == goal5.position.X - 50)))
                {
                    goal5.position.X = goal5.position.X;
                    saviour.position.X = goal5.position.X + 50;
                }
                else if ((goal6.position.Y == goal5.position.Y) && ((goal6.position.X == goal5.position.X - 50)))
                {
                    goal5.position.X = goal5.position.X;
                    saviour.position.X = goal5.position.X + 50;
                }
                else
                {
                    goal5.position.X = goal5.position.X - 50;
                    saviour.position.X = saviour.position.X;
                }

                if (saviour.position.X <= 400)
                    saviour.position.X = 400;
                if (goal5.position.X <= 350)
                    goal5.position.X = 350;

            }
            if (goal5.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 2) && (keyboardState.IsKeyDown(Keys.Down)))
            {
                if ((goal1.position.X == goal5.position.X) && ((goal5.position.Y == goal1.position.Y - 50)))
                {
                    goal5.position.Y = goal5.position.Y;
                    saviour.position.Y = goal5.position.Y - 50;
                }
                else if ((goal2.position.X == goal5.position.X) && ((goal5.position.Y == goal2.position.Y - 50)))
                {
                    goal5.position.Y = goal5.position.Y;
                    saviour.position.Y = goal5.position.Y - 50;
                }
                else if ((goal3.position.X == goal5.position.X) && ((goal5.position.Y == goal3.position.Y - 50)))
                {
                    goal5.position.Y = goal5.position.Y;
                    saviour.position.Y = goal5.position.Y - 50;
                }
                else if ((goal4.position.X == goal5.position.X) && ((goal5.position.Y == goal4.position.Y - 50)))
                {
                    goal5.position.Y = goal5.position.Y;
                    saviour.position.Y = goal5.position.Y - 50;
                }
                else if ((goal6.position.X == goal5.position.X) && ((goal5.position.Y == goal6.position.Y - 50)))
                {
                    goal5.position.Y = goal5.position.Y;
                    saviour.position.Y = goal5.position.Y - 50;
                }
                else
                {
                    goal5.position.Y = goal5.position.Y + 50;
                    saviour.position.Y = saviour.position.Y;
                }

                if (saviour.position.Y >= 500)
                    saviour.position.Y = 500;
                if (goal5.position.Y >= 550)
                    goal5.position.Y = 550;

            }
            if (goal5.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 1) && (keyboardState.IsKeyDown(Keys.Up)))
            {
                if ((goal1.position.X == goal5.position.X) && ((goal5.position.Y == goal1.position.Y + 50)))
                {
                    goal5.position.Y = goal5.position.Y;
                    saviour.position.Y = goal5.position.Y + 50;
                }
                else if ((goal2.position.X == goal5.position.X) && ((goal5.position.Y == goal2.position.Y + 50)))
                {
                    goal5.position.Y = goal5.position.Y;
                    saviour.position.Y = goal5.position.Y + 50;
                }
                else if ((goal3.position.X == goal5.position.X) && ((goal5.position.Y == goal3.position.Y + 50)))
                {
                    goal5.position.Y = goal5.position.Y;
                    saviour.position.Y = goal5.position.Y + 50;
                }
                else if ((goal4.position.X == goal5.position.X) && ((goal5.position.Y == goal4.position.Y + 50)))
                {
                    goal5.position.Y = goal5.position.Y;
                    saviour.position.Y = goal5.position.Y + 50;
                }
                else if ((goal6.position.X == goal5.position.X) && ((goal5.position.Y == goal6.position.Y + 50)))
                {
                    goal5.position.Y = goal5.position.Y;
                    saviour.position.Y = goal5.position.Y + 50;
                }
                else
                {
                    goal5.position.Y = goal5.position.Y - 50;
                    saviour.position.Y = saviour.position.Y;
                }

                if (saviour.position.Y <= 200)
                    saviour.position.Y = 200;
                if (goal5.position.Y <= 150)
                    goal5.position.Y = 150;

            }
            if (goal5.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 3) && (keyboardState.IsKeyDown(Keys.Right)))
            {
                if ((goal1.position.Y == goal5.position.Y) && ((goal1.position.X == goal5.position.X + 50)))
                {
                    goal5.position.X = goal5.position.X;
                    saviour.position.X = goal5.position.X - 50;
                }
                else if ((goal2.position.Y == goal5.position.Y) && ((goal2.position.X == goal5.position.X + 50)))
                {
                    goal5.position.X = goal5.position.X;
                    saviour.position.X = goal5.position.X - 50;
                }
                else if ((goal3.position.Y == goal5.position.Y) && ((goal3.position.X == goal5.position.X + 50)))
                {
                    goal5.position.X = goal5.position.X;
                    saviour.position.X = goal5.position.X - 50;
                }
                else if ((goal4.position.Y == goal5.position.Y) && ((goal4.position.X == goal5.position.X + 50)))
                {
                    goal5.position.X = goal5.position.X;
                    saviour.position.X = goal5.position.X - 50;
                }
                else if ((goal6.position.Y == goal5.position.Y) && ((goal6.position.X == goal5.position.X + 50)))
                {
                    goal5.position.X = goal5.position.X;
                    saviour.position.X = goal5.position.X - 50;
                }
                else
                {
                    goal5.position.X = goal5.position.X + 50;
                    saviour.position.X = saviour.position.X;
                }

                if (saviour.position.X >= 700)
                    saviour.position.X = 700;
                if (goal5.position.X >= 750)
                    goal5.position.X = 750;

            }
            if (goal2.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 0) && (keyboardState.IsKeyDown(Keys.Left)))
            {
                if ((goal2.position.Y == goal5.position.Y) && ((goal5.position.X == goal2.position.X - 50)))
                {
                    goal2.position.X = goal2.position.X;
                    saviour.position.X = goal2.position.X + 50;
                }
                else if ((goal2.position.Y == goal1.position.Y) && ((goal1.position.X == goal2.position.X - 50)))
                {
                    goal2.position.X = goal2.position.X;
                    saviour.position.X = goal2.position.X + 50;
                }
                else if ((goal2.position.Y == goal3.position.Y) && ((goal3.position.X == goal2.position.X - 50)))
                {
                    goal2.position.X = goal2.position.X;
                    saviour.position.X = goal2.position.X + 50;
                }
                else if ((goal2.position.Y == goal4.position.Y) && ((goal4.position.X == goal2.position.X - 50)))
                {
                    goal2.position.X = goal2.position.X;
                    saviour.position.X = goal2.position.X + 50;
                }
                else if ((goal2.position.Y == goal6.position.Y) && ((goal6.position.X == goal2.position.X - 50)))
                {
                    goal2.position.X = goal2.position.X;
                    saviour.position.X = goal2.position.X + 50;
                }
                else
                {
                    goal2.position.X = goal2.position.X - 50;
                    saviour.position.X = saviour.position.X;
                }

                if (saviour.position.X <= 400)
                    saviour.position.X = 400;
                if (goal2.position.X <= 350)
                    goal2.position.X = 350;

            }
            if (goal2.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 2) && (keyboardState.IsKeyDown(Keys.Down)))
            {
                if ((goal2.position.X == goal5.position.X) && ((goal2.position.Y == goal5.position.Y - 50)))
                {
                    goal2.position.Y = goal2.position.Y;
                    saviour.position.Y = goal2.position.Y - 50;
                }
                else if ((goal2.position.X == goal1.position.X) && ((goal2.position.Y == goal1.position.Y - 50)))
                {
                    goal2.position.Y = goal2.position.Y;
                    saviour.position.Y = goal2.position.Y - 50;
                }
                else if ((goal2.position.X == goal3.position.X) && ((goal2.position.Y == goal3.position.Y - 50)))
                {
                    goal2.position.Y = goal2.position.Y;
                    saviour.position.Y = goal2.position.Y - 50;
                }
                else if ((goal2.position.X == goal4.position.X) && ((goal2.position.Y == goal4.position.Y - 50)))
                {
                    goal2.position.Y = goal2.position.Y;
                    saviour.position.Y = goal2.position.Y - 50;
                }
                else if ((goal2.position.X == goal6.position.X) && ((goal2.position.Y == goal6.position.Y - 50)))
                {
                    goal2.position.Y = goal2.position.Y;
                    saviour.position.Y = goal2.position.Y - 50;
                }
                else
                {
                    goal2.position.Y = goal2.position.Y + 50;
                    saviour.position.Y = saviour.position.Y;
                }

                if (saviour.position.Y >= 500)
                    saviour.position.Y = 500;
                if (goal2.position.Y >= 550)
                    goal2.position.Y = 550;

            }
            if (goal2.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 1) && (keyboardState.IsKeyDown(Keys.Up)))
            {
                if ((goal2.position.X == goal5.position.X) && ((goal2.position.Y == goal5.position.Y + 50)))
                {
                    goal2.position.Y = goal2.position.Y;
                    saviour.position.Y = goal2.position.Y + 50;
                }
                else if ((goal2.position.X == goal1.position.X) && ((goal2.position.Y == goal1.position.Y + 50)))
                {
                    goal2.position.Y = goal2.position.Y;
                    saviour.position.Y = goal2.position.Y + 50;
                }
                else if ((goal2.position.X == goal3.position.X) && ((goal2.position.Y == goal3.position.Y + 50)))
                {
                    goal2.position.Y = goal2.position.Y;
                    saviour.position.Y = goal2.position.Y + 50;
                }
                else if ((goal2.position.X == goal4.position.X) && ((goal2.position.Y == goal4.position.Y + 50)))
                {
                    goal2.position.Y = goal2.position.Y;
                    saviour.position.Y = goal2.position.Y + 50;
                }
                else if ((goal2.position.X == goal6.position.X) && ((goal2.position.Y == goal6.position.Y + 50)))
                {
                    goal2.position.Y = goal2.position.Y;
                    saviour.position.Y = goal2.position.Y + 50;
                }

                else
                {
                    goal2.position.Y = goal2.position.Y - 50;
                    saviour.position.Y = saviour.position.Y;
                }

                if (saviour.position.Y <= 200)
                    saviour.position.Y = 200;
                if (goal2.position.Y <= 150)
                    goal2.position.Y = 150;

            }
            if (goal2.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 3) && (keyboardState.IsKeyDown(Keys.Right)))
            {
                if ((goal2.position.Y == goal5.position.Y) && ((goal2.position.X == goal5.position.X - 50)))
                {
                    goal2.position.X = goal2.position.X;
                    saviour.position.X = goal2.position.X - 50;
                }
                else if ((goal2.position.Y == goal1.position.Y) && ((goal2.position.X == goal1.position.X - 50)))
                {
                    goal2.position.X = goal2.position.X;
                    saviour.position.X = goal2.position.X - 50;
                }
                else if ((goal2.position.Y == goal3.position.Y) && ((goal2.position.X == goal3.position.X - 50)))
                {
                    goal2.position.X = goal2.position.X;
                    saviour.position.X = goal2.position.X - 50;
                }
                else if ((goal2.position.Y == goal4.position.Y) && ((goal2.position.X == goal4.position.X - 50)))
                {
                    goal2.position.X = goal2.position.X;
                    saviour.position.X = goal2.position.X - 50;
                }
                else if ((goal2.position.Y == goal6.position.Y) && ((goal2.position.X == goal6.position.X - 50)))
                {
                    goal2.position.X = goal2.position.X;
                    saviour.position.X = goal2.position.X - 50;
                }
                else
                {
                    goal2.position.X = goal2.position.X + 50;
                    saviour.position.X = saviour.position.X;
                }

                if (saviour.position.X >= 700)
                    saviour.position.X = 700;
                if (goal2.position.X >= 750)
                    goal2.position.X = 750;

            }
            if (goal3.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 0) && (keyboardState.IsKeyDown(Keys.Left)))
            {
                if ((goal3.position.Y == goal5.position.Y) && ((goal5.position.X == goal3.position.X - 50)))
                {
                    goal3.position.X = goal3.position.X;
                    saviour.position.X = goal3.position.X + 50;
                }
                else if ((goal3.position.Y == goal1.position.Y) && ((goal1.position.X == goal3.position.X - 50)))
                {
                    goal3.position.X = goal3.position.X;
                    saviour.position.X = goal3.position.X + 50;
                }
                else if ((goal3.position.Y == goal2.position.Y) && ((goal2.position.X == goal3.position.X - 50)))
                {
                    goal3.position.X = goal3.position.X;
                    saviour.position.X = goal3.position.X + 50;
                }
                else if ((goal3.position.Y == goal4.position.Y) && ((goal4.position.X == goal3.position.X - 50)))
                {
                    goal3.position.X = goal3.position.X;
                    saviour.position.X = goal3.position.X + 50;
                }
                else if ((goal3.position.Y == goal6.position.Y) && ((goal6.position.X == goal3.position.X - 50)))
                {
                    goal3.position.X = goal3.position.X;
                    saviour.position.X = goal3.position.X + 50;
                }
                else
                {
                    goal3.position.X = goal3.position.X - 50;
                    saviour.position.X = saviour.position.X;
                }

                if (saviour.position.X <= 400)
                    saviour.position.X = 400;
                if (goal3.position.X <= 350)
                    goal3.position.X = 350;

            }
            if (goal3.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 2) && (keyboardState.IsKeyDown(Keys.Down)))
            {
                if ((goal3.position.X == goal5.position.X) && ((goal3.position.Y == goal5.position.Y - 50)))
                {
                    goal3.position.Y = goal3.position.Y;
                    saviour.position.Y = goal3.position.Y - 50;
                }
                else if ((goal3.position.X == goal1.position.X) && ((goal3.position.Y == goal1.position.Y - 50)))
                {
                    goal3.position.Y = goal3.position.Y;
                    saviour.position.Y = goal3.position.Y - 50;
                }
                else if ((goal3.position.X == goal2.position.X) && ((goal3.position.Y == goal2.position.Y - 50)))
                {
                    goal3.position.Y = goal3.position.Y;
                    saviour.position.Y = goal3.position.Y - 50;
                }
                else if ((goal3.position.X == goal4.position.X) && ((goal3.position.Y == goal4.position.Y - 50)))
                {
                    goal3.position.Y = goal3.position.Y;
                    saviour.position.Y = goal3.position.Y - 50;
                }
                else if ((goal3.position.X == goal6.position.X) && ((goal3.position.Y == goal6.position.Y - 50)))
                {
                    goal3.position.Y = goal3.position.Y;
                    saviour.position.Y = goal3.position.Y - 50;
                }
                else
                {
                    goal3.position.Y = goal3.position.Y + 50;
                    saviour.position.Y = saviour.position.Y;
                }

                if (saviour.position.Y >= 500)
                    saviour.position.Y = 500;
                if (goal3.position.Y >= 550)
                    goal3.position.Y = 550;

            }
            if (goal3.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 1) && (keyboardState.IsKeyDown(Keys.Up)))
            {
                if ((goal3.position.X == goal5.position.X) && ((goal3.position.Y == goal5.position.Y + 50)))
                {
                    goal3.position.Y = goal3.position.Y;
                    saviour.position.Y = goal3.position.Y + 50;
                }
                else if ((goal3.position.X == goal1.position.X) && ((goal3.position.Y == goal1.position.Y + 50)))
                {
                    goal3.position.Y = goal3.position.Y;
                    saviour.position.Y = goal3.position.Y + 50;
                }
                else if ((goal3.position.X == goal2.position.X) && ((goal3.position.Y == goal2.position.Y + 50)))
                {
                    goal3.position.Y = goal3.position.Y;
                    saviour.position.Y = goal3.position.Y + 50;
                }
                else if ((goal3.position.X == goal4.position.X) && ((goal3.position.Y == goal4.position.Y + 50)))
                {
                    goal3.position.Y = goal3.position.Y;
                    saviour.position.Y = goal3.position.Y + 50;
                }
                else if ((goal3.position.X == goal6.position.X) && ((goal3.position.Y == goal6.position.Y + 50)))
                {
                    goal3.position.Y = goal3.position.Y;
                    saviour.position.Y = goal3.position.Y + 50;
                }

                else
                {
                    goal3.position.Y = goal3.position.Y - 50;
                    saviour.position.Y = saviour.position.Y;
                }

                if (saviour.position.Y <= 200)
                    saviour.position.Y = 200;
                if (goal3.position.Y <= 150)
                    goal3.position.Y = 150;

            }
            if (goal3.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 3) && (keyboardState.IsKeyDown(Keys.Right)))
            {
                if ((goal3.position.Y == goal5.position.Y) && ((goal3.position.X == goal5.position.X - 50)))
                {
                    goal3.position.X = goal3.position.X;
                    saviour.position.X = goal3.position.X - 50;
                }
                else if ((goal3.position.Y == goal1.position.Y) && ((goal3.position.X == goal1.position.X - 50)))
                {
                    goal3.position.X = goal3.position.X;
                    saviour.position.X = goal3.position.X - 50;
                }
                else if ((goal3.position.Y == goal2.position.Y) && ((goal3.position.X == goal2.position.X - 50)))
                {
                    goal3.position.X = goal3.position.X;
                    saviour.position.X = goal3.position.X - 50;
                }
                else if ((goal3.position.Y == goal4.position.Y) && ((goal3.position.X == goal4.position.X - 50)))
                {
                    goal3.position.X = goal3.position.X;
                    saviour.position.X = goal3.position.X - 50;
                }
                else if ((goal3.position.Y == goal6.position.Y) && ((goal3.position.X == goal6.position.X - 50)))
                {
                    goal3.position.X = goal3.position.X;
                    saviour.position.X = goal3.position.X - 50;
                }
                else
                {
                    goal3.position.X = goal3.position.X + 50;
                    saviour.position.X = saviour.position.X;
                }

                if (saviour.position.X >= 700)
                    saviour.position.X = 700;
                if (goal3.position.X >= 750)
                    goal3.position.X = 750;

            }
            if (goal4.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 0) && (keyboardState.IsKeyDown(Keys.Left)))
            {
                if ((goal4.position.Y == goal5.position.Y) && ((goal5.position.X == goal4.position.X - 50)))
                {
                    goal4.position.X = goal4.position.X;
                    saviour.position.X = goal4.position.X + 50;
                }
                else if ((goal4.position.Y == goal1.position.Y) && ((goal1.position.X == goal4.position.X - 50)))
                {
                    goal4.position.X = goal4.position.X;
                    saviour.position.X = goal4.position.X + 50;
                }
                else if ((goal4.position.Y == goal2.position.Y) && ((goal2.position.X == goal4.position.X - 50)))
                {
                    goal4.position.X = goal4.position.X;
                    saviour.position.X = goal4.position.X + 50;
                }
                else if ((goal4.position.Y == goal3.position.Y) && ((goal3.position.X == goal4.position.X - 50)))
                {
                    goal4.position.X = goal4.position.X;
                    saviour.position.X = goal4.position.X + 50;
                }
                else if ((goal4.position.Y == goal6.position.Y) && ((goal6.position.X == goal4.position.X - 50)))
                {
                    goal4.position.X = goal4.position.X;
                    saviour.position.X = goal4.position.X + 50;
                }
                else
                {
                    goal4.position.X = goal4.position.X - 50;
                    saviour.position.X = saviour.position.X;
                }

                if (saviour.position.X <= 400)
                    saviour.position.X = 400;
                if (goal4.position.X <= 350)
                    goal4.position.X = 350;

            }
            if (goal4.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 2) && (keyboardState.IsKeyDown(Keys.Down)))
            {
                if ((goal4.position.X == goal5.position.X) && ((goal4.position.Y == goal5.position.Y - 50)))
                {
                    goal4.position.Y = goal4.position.Y;
                    saviour.position.Y = goal4.position.Y - 50;
                }
                else if ((goal4.position.X == goal1.position.X) && ((goal4.position.Y == goal1.position.Y - 50)))
                {
                    goal4.position.Y = goal4.position.Y;
                    saviour.position.Y = goal4.position.Y - 50;
                }
                else if ((goal4.position.X == goal2.position.X) && ((goal4.position.Y == goal2.position.Y - 50)))
                {
                    goal4.position.Y = goal4.position.Y;
                    saviour.position.Y = goal4.position.Y - 50;
                }
                else if ((goal4.position.X == goal3.position.X) && ((goal4.position.Y == goal3.position.Y - 50)))
                {
                    goal4.position.Y = goal4.position.Y;
                    saviour.position.Y = goal4.position.Y - 50;
                }
                else if ((goal4.position.X == goal6.position.X) && ((goal4.position.Y == goal6.position.Y - 50)))
                {
                    goal4.position.Y = goal4.position.Y;
                    saviour.position.Y = goal4.position.Y - 50;
                }
                else
                {
                    goal4.position.Y = goal4.position.Y + 50;
                    saviour.position.Y = saviour.position.Y;
                }

                if (saviour.position.Y >= 500)
                    saviour.position.Y = 500;
                if (goal4.position.Y >= 550)
                    goal4.position.Y = 550;

            }
            if (goal4.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 1) && (keyboardState.IsKeyDown(Keys.Up)))
            {
                if ((goal4.position.X == goal5.position.X) && ((goal4.position.Y == goal5.position.Y + 50)))
                {
                    goal4.position.Y = goal4.position.Y;
                    saviour.position.Y = goal4.position.Y + 50;
                }
                else if ((goal4.position.X == goal1.position.X) && ((goal4.position.Y == goal1.position.Y + 50)))
                {
                    goal4.position.Y = goal4.position.Y;
                    saviour.position.Y = goal4.position.Y + 50;
                }
                else if ((goal4.position.X == goal2.position.X) && ((goal4.position.Y == goal2.position.Y + 50)))
                {
                    goal4.position.Y = goal4.position.Y;
                    saviour.position.Y = goal4.position.Y + 50;
                }
                else if ((goal4.position.X == goal3.position.X) && ((goal4.position.Y == goal3.position.Y + 50)))
                {
                    goal4.position.Y = goal4.position.Y;
                    saviour.position.Y = goal4.position.Y + 50;
                }
                else if ((goal4.position.X == goal6.position.X) && ((goal4.position.Y == goal6.position.Y + 50)))
                {
                    goal4.position.Y = goal4.position.Y;
                    saviour.position.Y = goal4.position.Y + 50;
                }

                else
                {
                    goal4.position.Y = goal4.position.Y - 50;
                    saviour.position.Y = saviour.position.Y;
                }

                if (saviour.position.Y <= 200)
                    saviour.position.Y = 200;
                if (goal4.position.Y <= 150)
                    goal4.position.Y = 150;

            }
            if (goal4.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 3) && (keyboardState.IsKeyDown(Keys.Right)))
            {
                if ((goal4.position.Y == goal5.position.Y) && ((goal4.position.X == goal5.position.X - 50)))
                {
                    goal4.position.X = goal4.position.X;
                    saviour.position.X = goal4.position.X - 50;
                }
                else if ((goal4.position.Y == goal1.position.Y) && ((goal4.position.X == goal1.position.X - 50)))
                {
                    goal4.position.X = goal4.position.X;
                    saviour.position.X = goal4.position.X - 50;
                }
                else if ((goal4.position.Y == goal2.position.Y) && ((goal4.position.X == goal2.position.X - 50)))
                {
                    goal4.position.X = goal4.position.X;
                    saviour.position.X = goal4.position.X - 50;
                }
                else if ((goal4.position.Y == goal3.position.Y) && ((goal4.position.X == goal3.position.X - 50)))
                {
                    goal4.position.X = goal4.position.X;
                    saviour.position.X = goal4.position.X - 50;
                }
                else if ((goal4.position.Y == goal6.position.Y) && ((goal4.position.X == goal6.position.X - 50)))
                {
                    goal4.position.X = goal4.position.X;
                    saviour.position.X = goal4.position.X - 50;
                }
                else
                {
                    goal4.position.X = goal4.position.X + 50;
                    saviour.position.X = saviour.position.X;
                }

                if (saviour.position.X >= 700)
                    saviour.position.X = 700;
                if (goal4.position.X >= 750)
                    goal4.position.X = 750;

            }
            if (goal6.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 3) && (keyboardState.IsKeyDown(Keys.Right)))
            {
                if ((goal6.position.Y == goal5.position.Y) && ((goal6.position.X == goal5.position.X - 50)))
                {
                    goal6.position.X = goal6.position.X;
                    saviour.position.X = goal6.position.X - 50;
                }
                else if ((goal6.position.Y == goal1.position.Y) && ((goal6.position.X == goal1.position.X - 50)))
                {
                    goal6.position.X = goal6.position.X;
                    saviour.position.X = goal6.position.X - 50;
                }
                else if ((goal6.position.Y == goal2.position.Y) && ((goal6.position.X == goal2.position.X - 50)))
                {
                    goal6.position.X = goal6.position.X;
                    saviour.position.X = goal6.position.X - 50;
                }
                else if ((goal6.position.Y == goal3.position.Y) && ((goal6.position.X == goal3.position.X - 50)))
                {
                    goal6.position.X = goal6.position.X;
                    saviour.position.X = goal6.position.X - 50;
                }
                else if ((goal6.position.Y == goal4.position.Y) && ((goal6.position.X == goal4.position.X - 50)))
                {
                    goal6.position.X = goal6.position.X;
                    saviour.position.X = goal6.position.X - 50;
                }
                else
                {
                    goal6.position.X = goal6.position.X + 50;
                    saviour.position.X = saviour.position.X;
                }

                if (saviour.position.X >= 700)
                    saviour.position.X = 700;
                if (goal6.position.X >= 750)
                    goal6.position.X = 750;

            }
            if (goal6.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 0) && (keyboardState.IsKeyDown(Keys.Left)))
            {
                if ((goal6.position.Y == goal5.position.Y) && ((goal5.position.X == goal6.position.X - 50)))
                {
                    goal6.position.X = goal6.position.X;
                    saviour.position.X = goal6.position.X + 50;
                }
                else if ((goal6.position.Y == goal1.position.Y) && ((goal1.position.X == goal6.position.X - 50)))
                {
                    goal6.position.X = goal6.position.X;
                    saviour.position.X = goal6.position.X + 50;
                }
                else if ((goal6.position.Y == goal2.position.Y) && ((goal2.position.X == goal6.position.X - 50)))
                {
                    goal6.position.X = goal6.position.X;
                    saviour.position.X = goal6.position.X + 50;
                }
                else if ((goal6.position.Y == goal3.position.Y) && ((goal3.position.X == goal6.position.X - 50)))
                {
                    goal6.position.X = goal6.position.X;
                    saviour.position.X = goal6.position.X + 50;
                }
                else if ((goal6.position.Y == goal4.position.Y) && ((goal4.position.X == goal6.position.X - 50)))
                {
                    goal6.position.X = goal6.position.X;
                    saviour.position.X = goal6.position.X + 50;
                }
                else
                {
                    goal6.position.X = goal6.position.X - 50;
                    saviour.position.X = saviour.position.X;
                }

                if (saviour.position.X <= 400)
                    saviour.position.X = 400;
                if (goal6.position.X <= 350)
                    goal6.position.X = 350;

            }
            if (goal6.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 2) && (keyboardState.IsKeyDown(Keys.Down)))
            {
                if ((goal6.position.X == goal5.position.X) && ((goal6.position.Y == goal5.position.Y - 50)))
                {
                    goal6.position.Y = goal6.position.Y;
                    saviour.position.Y = goal6.position.Y - 50;
                }
                else if ((goal6.position.X == goal1.position.X) && ((goal6.position.Y == goal1.position.Y - 50)))
                {
                    goal6.position.Y = goal6.position.Y;
                    saviour.position.Y = goal6.position.Y - 50;
                }
                else if ((goal6.position.X == goal2.position.X) && ((goal6.position.Y == goal2.position.Y - 50)))
                {
                    goal6.position.Y = goal6.position.Y;
                    saviour.position.Y = goal6.position.Y - 50;
                }
                else if ((goal6.position.X == goal3.position.X) && ((goal6.position.Y == goal3.position.Y - 50)))
                {
                    goal6.position.Y = goal6.position.Y;
                    saviour.position.Y = goal6.position.Y - 50;
                }
                else if ((goal6.position.X == goal4.position.X) && ((goal6.position.Y == goal4.position.Y - 50)))
                {
                    goal6.position.Y = goal6.position.Y;
                    saviour.position.Y = goal6.position.Y - 50;
                }
                else
                {
                    goal6.position.Y = goal6.position.Y + 50;
                    saviour.position.Y = saviour.position.Y;
                }

                if (saviour.position.Y >= 450)
                    saviour.position.Y = 450;
                if (goal6.position.Y >= 500)
                    goal6.position.Y = 500;

            }
            if (goal6.collisionRect.Intersects(saviour.collisionRect) && (saviour.currentFrame.X == 1) && (keyboardState.IsKeyDown(Keys.Up)))
            {
                if ((goal6.position.X == goal5.position.X) && ((goal6.position.Y == goal5.position.Y + 50)))
                {
                    goal6.position.Y = goal6.position.Y;
                    saviour.position.Y = goal6.position.Y + 50;
                }
                else if ((goal6.position.X == goal1.position.X) && ((goal6.position.Y == goal1.position.Y + 50)))
                {
                    goal6.position.Y = goal6.position.Y;
                    saviour.position.Y = goal6.position.Y + 50;
                }
                else if ((goal6.position.X == goal2.position.X) && ((goal6.position.Y == goal2.position.Y + 50)))
                {
                    goal6.position.Y = goal6.position.Y;
                    saviour.position.Y = goal6.position.Y + 50;
                }
                else if ((goal6.position.X == goal3.position.X) && ((goal6.position.Y == goal3.position.Y + 50)))
                {
                    goal6.position.Y = goal6.position.Y;
                    saviour.position.Y = goal6.position.Y + 50;
                }
                else if ((goal6.position.X == goal4.position.X) && ((goal6.position.Y == goal4.position.Y + 50)))
                {
                    goal6.position.Y = goal6.position.Y;
                    saviour.position.Y = goal6.position.Y + 50;
                }

                else
                {
                    goal6.position.Y = goal6.position.Y - 50;
                    saviour.position.Y = saviour.position.Y;
                }

                if (saviour.position.Y <= 200)
                    saviour.position.Y = 200;
                if (goal6.position.Y <= 150)
                    goal6.position.Y = 150;

            }

            foreach (Brick s in spriteList)
            {

                if (s.collisionRect.Intersects(goal5.collisionRect) && (keyboardState.IsKeyDown(Keys.Left)))
                {
                    goal5.position.X = s.position.X + 50;
                    saviour.position.X = goal5.position.X + 50;
                }
                if (s.collisionRect.Intersects(goal5.collisionRect) && (keyboardState.IsKeyDown(Keys.Right)))
                {
                    goal5.position.X = s.position.X - 50;
                    saviour.position.X = goal5.position.X - 50;
                }
                if (s.collisionRect.Intersects(goal5.collisionRect) && (keyboardState.IsKeyDown(Keys.Up)))
                {
                    goal5.position.Y = s.position.Y + 50;
                    saviour.position.Y = goal5.position.Y + 50;
                }
                if (s.collisionRect.Intersects(goal5.collisionRect) && (keyboardState.IsKeyDown(Keys.Down)))
                {
                    goal5.position.Y = s.position.Y - 50;
                    saviour.position.Y = goal5.position.Y - 50;
                }

            }
            foreach (Brick s in spriteList)
            {

                if (s.collisionRect.Intersects(goal1.collisionRect) && (keyboardState.IsKeyDown(Keys.Left)))
                {
                    goal1.position.X = s.position.X + 50;
                    saviour.position.X = goal1.position.X + 50;
                }
                if (s.collisionRect.Intersects(goal1.collisionRect) && (keyboardState.IsKeyDown(Keys.Right)))
                {
                    goal1.position.X = s.position.X - 50;
                    saviour.position.X = goal1.position.X - 50;
                }
                if (s.collisionRect.Intersects(goal1.collisionRect) && (keyboardState.IsKeyDown(Keys.Up)))
                {
                    goal1.position.Y = s.position.Y + 50;
                    saviour.position.Y = goal1.position.Y + 50;
                }
                if (s.collisionRect.Intersects(goal1.collisionRect) && (keyboardState.IsKeyDown(Keys.Down)))
                {
                    goal1.position.Y = s.position.Y - 50;
                    saviour.position.Y = goal1.position.Y - 50;
                }

            }
            foreach (Brick s in spriteList)
            {

                if (s.collisionRect.Intersects(goal2.collisionRect) && (keyboardState.IsKeyDown(Keys.Left)))
                {
                    goal2.position.X = s.position.X + 50;
                    saviour.position.X = goal2.position.X + 50;
                }
                if (s.collisionRect.Intersects(goal2.collisionRect) && (keyboardState.IsKeyDown(Keys.Right)))
                {
                    goal2.position.X = s.position.X - 50;
                    saviour.position.X = goal2.position.X - 50;
                }
                if (s.collisionRect.Intersects(goal2.collisionRect) && (keyboardState.IsKeyDown(Keys.Up)))
                {
                    goal2.position.Y = s.position.Y + 50;
                    saviour.position.Y = goal2.position.Y + 50;
                }
                if (s.collisionRect.Intersects(goal2.collisionRect) && (keyboardState.IsKeyDown(Keys.Down)))
                {
                    goal2.position.Y = s.position.Y - 50;
                    saviour.position.Y = goal2.position.Y - 50;
                }

            }
            foreach (Brick s in spriteList)
            {

                if (s.collisionRect.Intersects(goal3.collisionRect) && (keyboardState.IsKeyDown(Keys.Left)))
                {
                    goal3.position.X = s.position.X + 50;
                    saviour.position.X = goal3.position.X + 50;
                }
                if (s.collisionRect.Intersects(goal3.collisionRect) && (keyboardState.IsKeyDown(Keys.Right)))
                {
                    goal3.position.X = s.position.X - 50;
                    saviour.position.X = goal3.position.X - 50;
                }
                if (s.collisionRect.Intersects(goal3.collisionRect) && (keyboardState.IsKeyDown(Keys.Up)))
                {
                    goal3.position.Y = s.position.Y + 50;
                    saviour.position.Y = goal3.position.Y + 50;
                }
                if (s.collisionRect.Intersects(goal3.collisionRect) && (keyboardState.IsKeyDown(Keys.Down)))
                {
                    goal3.position.Y = s.position.Y - 50;
                    saviour.position.Y = goal3.position.Y - 50;
                }

            }
            foreach (Brick s in spriteList)
            {

                if (s.collisionRect.Intersects(goal4.collisionRect) && (keyboardState.IsKeyDown(Keys.Left)))
                {
                    goal4.position.X = s.position.X + 50;
                    saviour.position.X = goal4.position.X + 50;
                }
                if (s.collisionRect.Intersects(goal4.collisionRect) && (keyboardState.IsKeyDown(Keys.Right)))
                {
                    goal4.position.X = s.position.X - 50;
                    saviour.position.X = goal4.position.X - 50;
                }
                if (s.collisionRect.Intersects(goal4.collisionRect) && (keyboardState.IsKeyDown(Keys.Up)))
                {
                    goal4.position.Y = s.position.Y + 50;
                    saviour.position.Y = goal4.position.Y + 50;
                }
                if (s.collisionRect.Intersects(goal4.collisionRect) && (keyboardState.IsKeyDown(Keys.Down)))
                {
                    goal4.position.Y = s.position.Y - 50;
                    saviour.position.Y = goal4.position.Y - 50;
                }

            }
            foreach (Brick s in spriteList)
            {

                if (s.collisionRect.Intersects(goal6.collisionRect) && (keyboardState.IsKeyDown(Keys.Left)))
                {
                    goal6.position.X = s.position.X + 50;
                    saviour.position.X = goal6.position.X + 50;
                }
                if (s.collisionRect.Intersects(goal6.collisionRect) && (keyboardState.IsKeyDown(Keys.Right)))
                {
                    goal6.position.X = s.position.X - 50;
                    saviour.position.X = goal6.position.X - 50;
                }
                if (s.collisionRect.Intersects(goal6.collisionRect) && (keyboardState.IsKeyDown(Keys.Up)))
                {
                    goal6.position.Y = s.position.Y + 50;
                    saviour.position.Y = goal6.position.Y + 50;
                }
                if (s.collisionRect.Intersects(goal6.collisionRect) && (keyboardState.IsKeyDown(Keys.Down)))
                {
                    goal6.position.Y = s.position.Y - 50;
                    saviour.position.Y = goal6.position.Y - 50;
                }

            }
            if (newPosition.X != saviour.position.X || newPosition.Y != saviour.position.Y)
            {
                steps += 1;
                newPosition.X = saviour.position.X;
                newPosition.Y = saviour.position.Y;
            }

            base.Update(gameTime);
        }
Esempio n. 34
0
        private static void MakeBuildings(Map map, TileLayer wallLayer, TileLayer terrainLayer, TileLayer roofLayer, Compound newCompound)
        {
            Rectangle innerBounds = newCompound.InnerBounds;
            innerBounds.Inflate(-2, -2);

            // Helipad
            Building heliPad = null;

            for (int i = 0; i < 10; i++)
            {
                Point pos = new Point(innerBounds.Left + rand.Next(innerBounds.Width), innerBounds.Top + rand.Next(innerBounds.Height));
                Rectangle rect = new Rectangle(pos.X - 3, pos.Y - 3, 6, 6);

                bool canPlace = true;

                foreach (Building b in newCompound.Buildings)
                {
                    Rectangle br = b.Rect;
                    br.Inflate(2, 2);
                    if (br.Intersects(rect)) canPlace = false;
                }

                if (!innerBounds.Contains(rect)) canPlace = false;

                if (canPlace)
                {
                    heliPad = new Building() { Rect = rect, Type = BuildingType.Helipad };
                    break;
                }
            }

            if (heliPad != null)
            {
                newCompound.Buildings.Add(heliPad);

                //for (int xx = heliPad.Rect.Left; xx < heliPad.Rect.Right; xx++)
                //    for (int yy = heliPad.Rect.Top; yy < heliPad.Rect.Bottom; yy++)
                //        terrainLayer.Tiles[xx, yy] = map.Tiles[CARPARK];
            }

            // Buildings!
            for (int i = 0; i < 100; i++)
            {
                Building newBuilding = null;

                Point pos = new Point(innerBounds.Left + 4 + rand.Next(innerBounds.Width - 8), innerBounds.Top + 4 + rand.Next(innerBounds.Height-8));
                Rectangle rect = new Rectangle(pos.X, pos.Y, 1, 1);
                rect.Inflate(5 + rand.Next(10), 5 + rand.Next(10));

                bool canPlace = true;

                foreach (Building b in newCompound.Buildings)
                {
                    Rectangle br = b.Rect;
                    br.Inflate(2, 2);
                    if (br.Intersects(rect)) canPlace = false;
                }

                if (!innerBounds.Contains(rect)) canPlace = false;

                if (canPlace)
                {
                    newBuilding = new Building() { Rect = rect, Type = BuildingType.Building };
                }

                if (newBuilding != null)
                {
                    newCompound.Buildings.Add(newBuilding);

                    // Outer walls
                    wallLayer.Tiles[rect.Left, rect.Top] = map.Tiles[WALL_TL];
                    wallLayer.Tiles[rect.Right, rect.Top] = map.Tiles[WALL_TR];
                    wallLayer.Tiles[rect.Left, rect.Bottom] = map.Tiles[WALL_BL];
                    wallLayer.Tiles[rect.Right, rect.Bottom] = map.Tiles[WALL_BR];

                    roofLayer.Tiles[rect.Left, rect.Top] = map.Tiles[ROOF_TL];
                    roofLayer.Tiles[rect.Right, rect.Top] = map.Tiles[ROOF_TR];
                    roofLayer.Tiles[rect.Left, rect.Bottom] = map.Tiles[ROOF_BL];
                    roofLayer.Tiles[rect.Right, rect.Bottom] = map.Tiles[ROOF_BR];

                    for (int xx = rect.Left + 1; xx <= rect.Right - 1; xx++)
                    {
                        wallLayer.Tiles[xx, rect.Top] = map.Tiles[WALL_EDGE_UP];
                        wallLayer.Tiles[xx, rect.Bottom] = map.Tiles[WALL_EDGE_DOWN];

                        roofLayer.Tiles[xx, rect.Top] = map.Tiles[ROOF_EDGE_UP];
                        roofLayer.Tiles[xx, rect.Bottom] = map.Tiles[ROOF_EDGE_DOWN];
                    }
                    for (int yy = rect.Top + 1; yy <= rect.Bottom - 1; yy++)
                    {
                        wallLayer.Tiles[rect.Left,yy] = map.Tiles[WALL_EDGE_LEFT];
                        wallLayer.Tiles[rect.Right,yy] = map.Tiles[WALL_EDGE_RIGHT];

                        roofLayer.Tiles[rect.Left, yy] = map.Tiles[ROOF_EDGE_LEFT];
                        roofLayer.Tiles[rect.Right, yy] = map.Tiles[ROOF_EDGE_RIGHT];
                    }

                    for (int xx = rect.Left+1; xx <= rect.Right-1; xx++)
                    {
                        for (int yy = rect.Top+1; yy <= rect.Bottom-1; yy++)
                        {
                            roofLayer.Tiles[xx, yy] = map.Tiles[ROOF];
                        }
                    }

                    // Exits
                    bool[] exits = new bool[4] { false, false, false, false };
                        exits[rand.Next(4)] = true;

                    if (exits[0])
                    {
                        int doorx = rand.Next(rect.Width - 7) + 3;
                        for (int xx = rect.Left + doorx; xx < (rect.Left + doorx) + 4; xx++) { wallLayer.Tiles[xx, rect.Top] = null; roofLayer.Tiles[xx, rect.Top] = null; }
                    }
                    if (exits[1])
                    {
                        int doorx = rand.Next(rect.Width - 7) + 3;
                        for (int xx = rect.Left + doorx; xx < (rect.Left + doorx) + 4; xx++) { wallLayer.Tiles[xx, rect.Bottom] = null; roofLayer.Tiles[xx, rect.Bottom] = null; }
                    }
                    if (exits[2])
                    {
                        int doory = rand.Next(rect.Height - 7) + 3;
                        for (int yy = rect.Top + doory; yy < (rect.Top + doory) + 4; yy++) {wallLayer.Tiles[rect.Left, yy] = null; roofLayer.Tiles[rect.Left, yy] = null;}
                    }
                    if (exits[3])
                    {
                        int doory = rand.Next(rect.Height - 7) + 3;
                        for (int yy = rect.Top + doory; yy < (rect.Top + doory) + 4; yy++){ wallLayer.Tiles[rect.Right, yy] = null; roofLayer.Tiles[rect.Right, yy] = null;}
                    }

                    //for (int xx = newBuilding.Rect.Left; xx < newBuilding.Rect.Right; xx++)
                    //    for (int yy = newBuilding.Rect.Top; yy < newBuilding.Rect.Bottom; yy++)
                    //        terrainLayer.Tiles[xx, yy] = map.Tiles[WALL_HORIZ];
                }
            }
        }
Esempio n. 35
0
        private static void CreateCompounds(Map map, TileLayer terrainLayer, TileLayer wallLayer, TileLayer roofLayer, List<Compound> compounds, float[][] noise, float height, float distance, int minsize, LightingEngine lightingEngine, GraphicsDevice gd)
        {
            for (int y = 40; y < map.Width - 40; y++)
            {
                for (int x = 40; x < map.Height - 40; x++)
                {
                    if (noise[y][x] > height)
                    {
                        Vector2 thisLoc = new Vector2(x * map.TileWidth, y * map.TileHeight);

                        bool tooClose = false;
                        foreach (Compound c in compounds)
                            if ((c.Position - thisLoc).Length() < distance) tooClose = true;

                        if (!tooClose)
                        {
                            Rectangle bounds = new Rectangle(x, y, 1, 1);
                            bounds.Inflate(minsize, minsize);
                            bounds.Inflate(rand.Next(5) * 2, rand.Next(5) * 2);

                            bool tooBig = true;
                            while (tooBig)
                            {
                                if (GetTileIndex(map, terrainLayer, bounds.Left, bounds.Top) != GRASS ||
                                    GetTileIndex(map, terrainLayer, bounds.Right, bounds.Top) != GRASS ||
                                    GetTileIndex(map, terrainLayer, bounds.Left, bounds.Bottom) != GRASS ||
                                    GetTileIndex(map, terrainLayer, bounds.Right, bounds.Bottom) != GRASS)
                                {
                                    tooBig = true;
                                    bounds.Inflate(-1, -1);
                                }
                                else tooBig = false;
                            }

                            if (bounds.Width >= minsize && bounds.Height >= minsize)
                            {
                                Compound newCompound = new Compound() { Position = thisLoc };

                                for (int xx = bounds.Left; xx <= bounds.Right; xx++)
                                {
                                    for (int yy = bounds.Top; yy <= bounds.Bottom; yy++)
                                    {
                                        wallLayer.Tiles[xx, yy] = null;
                                        if (xx > bounds.Left + 2 && xx < bounds.Right - 2 && yy > bounds.Top + 2 && yy < bounds.Bottom - 2)
                                            terrainLayer.Tiles[xx, yy] = map.Tiles[MUD];
                                    }
                                }

                                Rectangle innerBounds = bounds;
                                innerBounds.Inflate(-3, -3);

                                // Outer walls
                                wallLayer.Tiles[innerBounds.Left, innerBounds.Top] = map.Tiles[WALL_TL];
                                wallLayer.Tiles[innerBounds.Right, innerBounds.Top] = map.Tiles[WALL_TR];
                                wallLayer.Tiles[innerBounds.Left, innerBounds.Bottom] = map.Tiles[WALL_BL];
                                wallLayer.Tiles[innerBounds.Right, innerBounds.Bottom] = map.Tiles[WALL_BR];

                                for (int xx = innerBounds.Left + 1; xx <= innerBounds.Right - 1; xx++)
                                {
                                    wallLayer.Tiles[xx, innerBounds.Top] = map.Tiles[WALL_EDGE_UP];
                                    wallLayer.Tiles[xx, innerBounds.Bottom] = map.Tiles[WALL_EDGE_DOWN];
                                }
                                for (int yy = innerBounds.Top + 1; yy <= innerBounds.Bottom - 1; yy++)
                                {
                                    wallLayer.Tiles[innerBounds.Left, yy] = map.Tiles[WALL_EDGE_LEFT];
                                    wallLayer.Tiles[innerBounds.Right,yy] = map.Tiles[WALL_EDGE_RIGHT];
                                }

                                newCompound.Bounds = bounds;
                                newCompound.InnerBounds = innerBounds;

                                // Exits
                                bool[] exits = new bool[4] { false, false, false, false };
                                for(int i=0;i<4;i++)
                                    exits[rand.Next(4)] = true;

                                bool carparkPlaced = false;
                                Building carpark = null;

                                if (exits[0])
                                {
                                    int doorx = rand.Next(innerBounds.Width - 7) + 3;
                                    for (int xx = innerBounds.Left + doorx; xx < (innerBounds.Left + doorx) + 4; xx++) wallLayer.Tiles[xx, innerBounds.Top] = null;
                                    if (!carparkPlaced && rand.Next(2) == 0)
                                    {
                                        carpark = new Building() { Type = BuildingType.Carpark, Rect = new Rectangle((innerBounds.Left + doorx), innerBounds.Top + 2, 4, 4) };
                                        newCompound.Buildings.Add(carpark);
                                        carparkPlaced = true;
                                    }
                                }
                                if (exits[1])
                                {
                                    int doorx = rand.Next(innerBounds.Width - 7) + 3;
                                    for (int xx = innerBounds.Left + doorx; xx < (innerBounds.Left + doorx) + 4; xx++) wallLayer.Tiles[xx, innerBounds.Bottom] = null;
                                    if (!carparkPlaced && rand.Next(2) == 0)
                                    {
                                        carpark = new Building() { Type = BuildingType.Carpark, Rect = new Rectangle((innerBounds.Left + doorx), innerBounds.Bottom - 6, 4, 4) };
                                        newCompound.Buildings.Add(carpark);
                                        carparkPlaced = true;
                                    }
                                }
                                if (exits[2])
                                {
                                    int doory = rand.Next(innerBounds.Height - 7) + 3;
                                    for (int yy = innerBounds.Top + doory; yy < (innerBounds.Top + doory) + 4; yy++) wallLayer.Tiles[innerBounds.Left,yy] = null;
                                    if (!carparkPlaced && rand.Next(2) == 0)
                                    {
                                        carpark = new Building() { Type = BuildingType.Carpark, Rect = new Rectangle(innerBounds.Left + 2, (innerBounds.Top + doory), 4, 4) };
                                        newCompound.Buildings.Add(carpark);
                                        carparkPlaced = true;
                                    }
                                }
                                if (exits[3])
                                {
                                    int doory = rand.Next(innerBounds.Height - 7) + 3;
                                    for (int yy = innerBounds.Top + doory; yy < (innerBounds.Top + doory) + 4; yy++) wallLayer.Tiles[innerBounds.Right, yy] = null;
                                    if (!carparkPlaced && rand.Next(2) == 0)
                                    {
                                        carpark = new Building() { Type = BuildingType.Carpark, Rect = new Rectangle(innerBounds.Right - 6, (innerBounds.Top + doory), 4, 4) };
                                        newCompound.Buildings.Add(carpark);
                                        carparkPlaced = true;
                                    }
                                }

                                int lightSpacing = 5;
                                for (int xx = innerBounds.Left + 4; xx <= innerBounds.Right - 4; xx++)
                                {
                                    lightSpacing++;
                                    if (lightSpacing == 6)
                                    {
                                        lightSpacing = 0;

                                        if (GetTileIndex(map, wallLayer, xx, innerBounds.Top) == WALL_EDGE_UP &&
                                            GetTileIndex(map, wallLayer, xx - 2, innerBounds.Top) == WALL_EDGE_UP &&
                                            GetTileIndex(map, wallLayer, xx + 2, innerBounds.Top) == WALL_EDGE_UP)
                                        {
                                            LightSource ls = new LightSource(gd, 300, LightAreaQuality.Low, Color.White, BeamStencilType.None, SpotStencilType.Half);
                                            ls.Rotation = MathHelper.PiOver2;
                                            ls.Position = new Vector2((xx * map.TileWidth) + (map.TileWidth / 2), ((innerBounds.Top + 1) * map.TileHeight));
                                            lightingEngine.LightSources.Add(ls);
                                        }

                                        if (GetTileIndex(map, wallLayer, xx, innerBounds.Bottom) == WALL_EDGE_DOWN &&
                                            GetTileIndex(map, wallLayer, xx - 2, innerBounds.Bottom) == WALL_EDGE_DOWN &&
                                            GetTileIndex(map, wallLayer, xx + 2, innerBounds.Bottom) == WALL_EDGE_DOWN)
                                        {
                                            LightSource ls = new LightSource(gd, 300, LightAreaQuality.Low, Color.White, BeamStencilType.None, SpotStencilType.Half);
                                            ls.Rotation = MathHelper.PiOver2 + MathHelper.Pi;
                                            ls.Position = new Vector2((xx * map.TileWidth) + (map.TileWidth / 2), ((innerBounds.Bottom) * map.TileHeight));
                                            lightingEngine.LightSources.Add(ls);
                                        }
                                    }
                                }
                                lightSpacing = 5;
                                for (int yy = innerBounds.Top + 4; yy <= innerBounds.Bottom - 4; yy++)
                                {
                                    lightSpacing++;
                                    if (lightSpacing == 6)
                                    {
                                        lightSpacing = 0;

                                        if (GetTileIndex(map, wallLayer, innerBounds.Left, yy) == WALL_EDGE_LEFT &&
                                            GetTileIndex(map, wallLayer, innerBounds.Left, yy - 2) == WALL_EDGE_LEFT &&
                                            GetTileIndex(map, wallLayer, innerBounds.Left, yy + 2) == WALL_EDGE_LEFT)
                                        {
                                            LightSource ls = new LightSource(gd, 300, LightAreaQuality.Low, Color.White, BeamStencilType.None, SpotStencilType.Half);
                                            //ls.Rotation = MathHelper.PiOver2;
                                            ls.Position = new Vector2(((innerBounds.Left+1) * map.TileWidth), (yy * map.TileHeight)+(map.TileHeight/2));
                                            lightingEngine.LightSources.Add(ls);
                                        }

                                        if (GetTileIndex(map, wallLayer, innerBounds.Right, yy) == WALL_EDGE_RIGHT &&
                                           GetTileIndex(map, wallLayer, innerBounds.Right, yy - 2) == WALL_EDGE_RIGHT &&
                                           GetTileIndex(map, wallLayer, innerBounds.Right, yy + 2) == WALL_EDGE_RIGHT)
                                        {
                                            LightSource ls = new LightSource(gd, 300, LightAreaQuality.Low, Color.White, BeamStencilType.None, SpotStencilType.Half);
                                            ls.Rotation = MathHelper.Pi;
                                            ls.Position = new Vector2(((innerBounds.Right) * map.TileWidth), (yy * map.TileHeight) + (map.TileHeight / 2));
                                            lightingEngine.LightSources.Add(ls);
                                        }
                                    }
                                }

                                //if (carpark!=null)
                                //    for (int xx = carpark.Rect.Left; xx < carpark.Rect.Right; xx++)
                                //        for (int yy = carpark.Rect.Top; yy < carpark.Rect.Bottom; yy++)
                                //             terrainLayer.Tiles[xx, yy] = map.Tiles[CARPARK];

                                MakeBuildings(map, wallLayer, terrainLayer, roofLayer, newCompound);

                                compounds.Add(newCompound);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 36
0
        private Point FindSharpTearsSpot(Vector2 origin, Vector2 targetSpot)
        {
            targetSpot.ToTileCoordinates();
            Vector2 center        = origin;
            Vector2 endPoint      = targetSpot;
            int     samplesToTake = 3;
            float   samplingWidth = 4f;
            Vector2 vectorTowardsTarget;

            float[] samples;
            Collision.AimingLaserScan(center, endPoint, samplingWidth, samplesToTake, out vectorTowardsTarget, out samples);
            float num = float.PositiveInfinity;

            for (int index = 0; index < samples.Length; ++index)
            {
                if ((double)samples[index] < (double)num)
                {
                    num = samples[index];
                }
            }
            targetSpot = center + vectorTowardsTarget.SafeNormalize(Vector2.Zero) * num;
            Point tileCoordinates = targetSpot.ToTileCoordinates();

            Microsoft.Xna.Framework.Rectangle rectangle1 = new Microsoft.Xna.Framework.Rectangle(tileCoordinates.X, tileCoordinates.Y, 1, 1);
            rectangle1.Inflate(6, 16);
            Microsoft.Xna.Framework.Rectangle rectangle2 = new Microsoft.Xna.Framework.Rectangle(0, 0, Main.maxTilesX, Main.maxTilesY);
            rectangle2.Inflate(-40, -40);
            rectangle1 = Microsoft.Xna.Framework.Rectangle.Intersect(rectangle1, rectangle2);
            List <Point> pointList1 = new List <Point>();
            List <Point> pointList2 = new List <Point>();

            for (int left = rectangle1.Left; left <= rectangle1.Right; ++left)
            {
                for (int top = rectangle1.Top; top <= rectangle1.Bottom; ++top)
                {
                    if (WorldGen.SolidTile(left, top))
                    {
                        Vector2 vector2 = new Vector2((float)(left * 16 + 8), (float)(top * 16 + 8));
                        if ((double)Vector2.Distance(targetSpot, vector2) <= 200.0)
                        {
                            if (FindSharpTearsOpening(left, top, left > tileCoordinates.X, left <tileCoordinates.X, top> tileCoordinates.Y, top < tileCoordinates.Y))
                            {
                                pointList1.Add(new Point(left, top));
                            }
                            else
                            {
                                pointList2.Add(new Point(left, top));
                            }
                        }
                    }
                }
            }
            if (pointList1.Count == 0 && pointList2.Count == 0)
            {
                pointList1.Add((origin.ToTileCoordinates().ToVector2() + Main.rand.NextVector2Square(-2f, 2f)).ToPoint());
            }
            List <Point> pointList3 = pointList1;

            if (pointList3.Count == 0)
            {
                pointList3 = pointList2;
            }
            int index1 = Main.rand.Next(pointList3.Count);

            return(pointList3[index1]);
        }
Esempio n. 37
0
 public virtual void Update(GameTime time)
 {
     if (squawkTime > 0f)
     {
         squawkTime -= (float)time.ElapsedGameTime.TotalSeconds;
     }
     if (shakeTime > 0f)
     {
         shakeTime -= (float)time.ElapsedGameTime.TotalSeconds;
     }
     if (costShakeTime > 0f)
     {
         costShakeTime -= (float)time.ElapsedGameTime.TotalSeconds;
     }
     if (timeUntilChomp > 0f)
     {
         timeUntilChomp -= (float)time.ElapsedGameTime.TotalSeconds;
         if (timeUntilChomp <= 0f)
         {
             if (locationRef.Value == Game1.currentLocation)
             {
                 Game1.playSound("eat");
             }
             timeUntilChomp = 0f;
             shakeTime      = 0.25f;
             if (locationRef.Value.getTemporarySpriteByID(98765) != null)
             {
                 for (int j = 0; j < 6; j++)
                 {
                     locationRef.Value.temporarySprites.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors2", new Microsoft.Xna.Framework.Rectangle(9, 252, 3, 3), locationRef.Value.getTemporarySpriteByID(98765).position + new Vector2(8f, 8f) * 4f, Game1.random.NextDouble() < 0.5, 0f, Color.White)
                     {
                         motion               = new Vector2(Game1.random.Next(-1, 2), -6f),
                         acceleration         = new Vector2(0f, 0.25f),
                         rotationChange       = (float)Game1.random.Next(-4, 5) * 0.05f,
                         scale                = 4f,
                         animationLength      = 1,
                         totalNumberOfLoops   = 1,
                         interval             = 500 + Game1.random.Next(500),
                         layerDepth           = 1f,
                         drawAboveAlwaysFront = true
                     });
                 }
             }
             locationRef.Value.removeTemporarySpritesWithID(98765f);
             timeUntilSqwawk = 1f;
         }
     }
     if (timeUntilSqwawk > 0f)
     {
         timeUntilSqwawk -= (float)time.ElapsedGameTime.TotalSeconds;
         if (timeUntilSqwawk <= 0f)
         {
             timeUntilSqwawk = 0f;
             if (locationRef.Value == Game1.currentLocation)
             {
                 Game1.playSound("parrot_squawk");
             }
             squawkTime = 0.5f;
             shakeTime  = 0.5f;
         }
     }
     if (parrotPresent && currentState.Value > UpgradeState.StartBuilding)
     {
         if (currentState.Value == UpgradeState.Building)
         {
             Parrot flying_parrot = new Parrot(this, Utility.PointToVector2(tilePosition));
             flying_parrot.isPerchedParrot = true;
             parrots.Add(flying_parrot);
         }
         parrotPresent = false;
     }
     if (IsAvailable(use_cached_value: true))
     {
         bool player_nearby = false;
         if (currentState.Value == UpgradeState.Idle && !upgradeMutex.IsLocked() && Math.Abs(Game1.player.getTileLocationPoint().X - tilePosition.X) <= 1 && Math.Abs(Game1.player.getTileLocationPoint().Y - tilePosition.Y) <= 1)
         {
             player_nearby = true;
         }
         if (player_nearby != isPlayerNearby)
         {
             isPlayerNearby = player_nearby;
             if (isPlayerNearby)
             {
                 if (locationRef.Value == Game1.currentLocation)
                 {
                     Game1.playSound("parrot_squawk");
                 }
                 squawkTime    = 0.5f;
                 shakeTime     = 0.5f;
                 costShakeTime = 0.5f;
                 Game1.specialCurrencyDisplay.ShowCurrency("walnuts");
             }
             else
             {
                 Game1.specialCurrencyDisplay.ShowCurrency(null);
             }
         }
     }
     if ((UpgradeState)currentState == UpgradeState.Building && parrots.Count < 24)
     {
         if (nextParrotSpawn > 0f)
         {
             nextParrotSpawn -= (float)time.ElapsedGameTime.TotalSeconds;
         }
         if (nextParrotSpawn <= 0f)
         {
             nextParrotSpawn = 0.05f;
             Microsoft.Xna.Framework.Rectangle spawn_rectangle = upgradeRect.Value;
             spawn_rectangle.Inflate(5, 0);
             parrots.Add(new Parrot(this, Utility.getRandomPositionInThisRectangle(spawn_rectangle, Game1.random), parrots.Count % 10 == 0));
         }
     }
     for (int i = 0; i < parrots.Count; i++)
     {
         if (parrots[i].Update(time))
         {
             parrots.RemoveAt(i);
             i--;
         }
     }
 }