Exemple #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            camera = new Camera();
            // Create a new SpriteBatch, which can be used to draw textures.
            ColorslList.Add(Content.Load<Texture2D>("blue"));
            ColorslList.Add(Content.Load<Texture2D>("yellow"));
            ColorslList.Add(Content.Load<Texture2D>("red"));
            ColorslList.Add(Content.Load<Texture2D>("orange"));
            ColorslList.Add(Content.Load<Texture2D>("blued"));
            ColorslList.Add(Content.Load<Texture2D>("fiol"));
            ColorslList.Add(Content.Load<Texture2D>("green"));

            Random x = new Random();
            spriteBatch = new SpriteBatch(GraphicsDevice);
            spriteFont = Content.Load<SpriteFont>("SpriteFont1");
            background = Content.Load<Texture2D>("background");
            BackRectangle = this.Window.ClientBounds;
            player = new Player(Content.Load<Texture2D>("peka"), new Rectangle(BackRectangle.Width / 2 - 25, BackRectangle.Height / 2 - 25, 50, 50), playerName);
            player.spriteFont = spriteFont;
            BackRectangle.X = 0;
            BackRectangle.Y = 0;
            GenerateSomeCircles(list);
            GenerateBots(listBots);
            listBots.ForEach(GenerateNewPoint);

            // TODO: use this.Content to load your game content here
        }
Exemple #2
0
        public bool Collision(List<GameObject> rectangles, List<Bot> bots,Player player)
        {
            GameObject temp = null;
            foreach (GameObject item in rectangles)
            {
                if (this.RectIn.Intersects(item.RectIn))
                {
                    this.Weight += item.Weight;
                    temp = item;

                    this.rectOut.X -= rectOut.Width / 50;
                    this.rectOut.Y -= rectOut.Height / 50;

                    this.rectIn.X -= rectIn.Width / 50;
                    this.rectIn.Y -= rectIn.Height / 50;

                    this.rectOut.Height += rectOut.Height / 50;
                    this.rectOut.Width += rectOut.Width / 50;

                    this.rectIn.Height += rectIn.Height / 50;
                    this.rectIn.Width += rectIn.Width / 50;
                    break;
                }

            }

            rectangles.Remove(temp);
             if (player.IsVisible)
            if (this.RectIn.Intersects(player.RectIn)&&this.Weight>player.Weight+20)
            {
                this.Weight += player.Weight;
                temp = player;

                this.rectOut.X -= rectOut.Width / 50;
                this.rectOut.Y -= rectOut.Height / 50;

                this.rectIn.X -= rectIn.Width / 50;
                this.rectIn.Y -= rectIn.Height / 50;

                this.rectOut.Height += rectOut.Height / 50;
                this.rectOut.Width += rectOut.Width / 50;

                this.rectIn.Height += rectIn.Height / 50;
                this.rectIn.Width += rectIn.Width / 50;
                player.IsVisible = false;
            }
            foreach (Bot item in bots)
            {
                if(item.isVisible)
                    if (item!=this)
                if (this.RectIn.Intersects(item.RectIn))
                {
                    this.Weight += item.Weight;
                    temp = item;

                    this.rectOut.X -= rectOut.Width / 50;
                    this.rectOut.Y -= rectOut.Height / 50;

                    this.rectIn.X -= rectIn.Width / 50;
                    this.rectIn.Y -= rectIn.Height / 50;

                    this.rectOut.Height += rectOut.Height / 50;
                    this.rectOut.Width += rectOut.Width / 50;

                    this.rectIn.Height += rectIn.Height / 50;
                    this.rectIn.Width += rectIn.Width / 50;
                    break;
                }

            }
            if (temp != null&&temp is Bot)
            {
                bots.Remove((Bot)temp);

                return true;
            }
            ResetLocation();
            DestinationPoint = CurrentPoint;
            return false;
        }