예제 #1
0
 public void update(WallManager walls)
 {
     for (int i = 0; i < players.Count; i++)
     {
         players.ElementAt(i).Update(walls);
     }
 }
예제 #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //Load the player resources
            Vector2 playerPosition = new Vector2(400, 450);

            //Load the wall resources
            Vector2 wallPosition = new Vector2(190.0f, 240.0f);

            scale = new Vector2(1, 1);

            //Load the feeler resources
            Vector2 feelerPosition = new Vector2(playerPosition.X - 55, playerPosition.Y - 50);


            wall.Initialize(Content.Load <Texture2D>("bigwall"), wallPosition);
            feeler.Initialize(Content.Load <Texture2D>("3feelers"), feelerPosition);


            // radar.Initialize(Content.Load<Texture2D>("Radar"), playerPosition);

            //NEW:
            foodManager = new FoodManager(Content.Load <Texture2D>("food"));
            wallManager = new WallManager();
            wallManager.addWall(wall);

            foodLocation = new Vector2(300, 100);

            foodManager.addFood(foodLocation.X, foodLocation.Y);

            //Load the text
            font = Content.Load <SpriteFont>("myFont");

            inputs = new double[6];
            output = new double[2];

            network = new NetworkManager();

            for (int i = 0; i < 20; i++)
            {
                network.addNetwork(6, this.r);
                player.addPlayer();
            }

            player.Initialize(Content.Load <Texture2D>("theplayer"), playerPosition);

            // TODO: use this.Content to load your game content here
        }
예제 #3
0
파일: Player.cs 프로젝트: mickmuzac/ANN.NET
        public void Update(WallManager walls)
        {
            for (int i = 0; i < 3; i++)
            {
                colors[i] = Color.Black;
            }

            startPoints[0].X = CenterPosition.X + (float)Math.Sin(rotationAngle) * PlayerTexture.Width * .5f;
            startPoints[0].Y = CenterPosition.Y - (float)Math.Cos(rotationAngle) * PlayerTexture.Height * .5f;

            startPoints[1].X = CenterPosition.X - (float)(Math.Cos(rotationAngle + Math.PI / 4) * PlayerTexture.Width * .5f * Math.Sqrt(2));
            startPoints[1].Y = CenterPosition.Y - (float)(Math.Sin(rotationAngle + Math.PI / 4) * PlayerTexture.Height * .5f * Math.Sqrt(2));

            startPoints[2].X = CenterPosition.X + (float)(Math.Sin(rotationAngle + Math.PI / 4) * PlayerTexture.Width * .5f * Math.Sqrt(2));
            startPoints[2].Y = CenterPosition.Y - (float)(Math.Cos(rotationAngle + Math.PI / 4) * PlayerTexture.Height * .5f * Math.Sqrt(2));

            topradar.X  = CenterPosition.X + (float)Math.Sin(rotationAngle) * PlayerTexture.Width * .5f;
            topradar.Y  = CenterPosition.Y - (float)Math.Cos(rotationAngle) * PlayerTexture.Height * .5f;
            topradare.X = topradar.X + (75 * (float)Math.Sin(rotationAngle));
            topradare.Y = topradar.Y + (75 * (float)(-Math.Cos(rotationAngle)));

            leftradar.X  = CenterPosition.X - (float)(Math.Cos(rotationAngle) * PlayerTexture.Width * .5f);
            leftradar.Y  = CenterPosition.Y - (float)(Math.Sin(rotationAngle) * PlayerTexture.Height * .5f);
            leftradare.X = leftradar.X - (75 * (float)(Math.Cos(rotationAngle)));
            leftradare.Y = leftradar.Y - (75 * (float)(Math.Sin(rotationAngle)));

            rightradar.X  = CenterPosition.X + (float)(Math.Cos(rotationAngle) * PlayerTexture.Width * .5f);
            rightradar.Y  = CenterPosition.Y + (float)(Math.Sin(rotationAngle) * PlayerTexture.Height * .5f);
            rightradare.X = rightradar.X + (75 * (float)(Math.Cos(rotationAngle)));
            rightradare.Y = rightradar.Y + (75 * (float)(Math.Sin(rotationAngle)));

            bottomradar.X  = CenterPosition.X - (float)Math.Sin(rotationAngle) * PlayerTexture.Width * .5f;;
            bottomradar.Y  = CenterPosition.Y + (float)Math.Cos(rotationAngle) * PlayerTexture.Height * .5f;;
            bottomradare.X = bottomradar.X - (75 * (float)Math.Sin(rotationAngle));
            bottomradare.Y = bottomradar.Y - (75 * (float)(-Math.Cos(rotationAngle)));
            int   tempLength;
            float yMod;
            float xMod;

            for (int feeler = 0; feeler < 3; feeler++)
            {
                tempLength = totalLength;

                if (feeler == 0)
                {
                    xMod = (float)Math.Sin(rotationAngle);
                    yMod = (float)(-Math.Cos(rotationAngle));
                }

                else if (feeler == 1)
                {
                    xMod = (float)(-Math.Cos(rotationAngle + Math.PI / 4));
                    yMod = (float)(-Math.Sin(rotationAngle + Math.PI / 4));
                }

                else
                {
                    xMod = (float)(Math.Sin(rotationAngle + Math.PI / 4));
                    yMod = (float)(-Math.Cos(rotationAngle + Math.PI / 4));
                }

                for (int i = 0; i < walls.walls.Count; i++)
                {
                    for (int j = 0; j < totalLength; j++)
                    {
                        endPoints[feeler].X = startPoints[feeler].X + j * xMod;
                        endPoints[feeler].Y = startPoints[feeler].Y + j * yMod;

                        if (walls.walls.ElementAt(i).BoundingBox.Contains((int)endPoints[feeler].X, (int)endPoints[feeler].Y))
                        {
                            tempLength      = j;
                            colors[feeler]  = Color.Green;
                            lengths[feeler] = j;
                            break;
                        }
                    }
                }

                lengths[feeler]     = tempLength;
                endPoints[feeler].X = startPoints[feeler].X + tempLength * xMod;
                endPoints[feeler].Y = startPoints[feeler].Y + tempLength * yMod;
            }
        }