Exemplo n.º 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()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            agents = new List<Agent>();
            objects = new List<WObject>();

            Texture2D agentTexture = Content.Load<Texture2D>("EntityTex/agentTex");
            Texture2D playerTexture = Content.Load<Texture2D>("EntityTex/playerTex");
            Texture2D farmTexture = Content.Load<Texture2D>("EntityTex/farmTex");

            background = Content.Load<Texture2D>("Background/background");
            player = new Player(playerTexture, new Vector2(400, 200));

            Agent a = new Agent(agentTexture, new Vector2(200, 200), massLogic);

            objects.Add(new WObject(playerTexture, new Vector2(300,300)));
            objects.Add(new WObject(playerTexture, new Vector2(400, 500)));
            WObject farm = new Farmland(farmTexture, new Vector2(50, 200));
            a.AddKnowledge(farm);

            objects.Add(farm);
            agents.Add(a);

            // TODO: use this.Content to load your game content here
        }
Exemplo n.º 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);
            agents = new List<Agent>();
            objects = new List<WObject>();
            font = Content.Load<SpriteFont>("Font");

            Texture2D agentTexture = Content.Load<Texture2D>("EntityTex/agentTex");
            Texture2D playerTexture = Content.Load<Texture2D>("EntityTex/playerTex");
            Texture2D farmTexture = Content.Load<Texture2D>("EntityTex/farmTex");
            Texture2D emptyTexture = Content.Load<Texture2D>("EntityTex/emptyTexture");
            Texture2D homeTexture = Content.Load<Texture2D>("EntityTex/homeTex");

            background = Content.Load<Texture2D>("Background/background");
            player = new Player(playerTexture, new Vector2(400, 200));

            //Generates all of the agents, gives them a home, and assigns them property
            for (int i = 0; i < numAgents; i++)
            {
                Agent a = new Agent(agentTexture, new Vector2(0, 0), massLogic, i);

                Boolean done = false;
                while (!done)
                {
                    Random rnd = new Random();
                    int r = rnd.Next(2, rows-4);
                    int c = rnd.Next(2, cols-4);
                    if (grid[r, c] == null)
                    {
                        WObject aHome = new Home(homeTexture, new Vector2(r*gridUnitSize, c*gridUnitSize), i);
                        a.home = aHome;
                        objects.Add(aHome);
                        a.AddProperty(aHome);
                        grid[r, c] = aHome;
                        //int wealth = rnd.Next(0, 3);
                        //Assign ownership
                        for (int x = -1; x < 2; x++)
                            for (int y = -1; y < 2; y++)
                            {
                                if (x != 0 || y != 0)
                                {
                                    int farmChance = rnd.Next(0,101);
                                    if (farmChance < 70)
                                    {
                                        WObject farm = new Farmland(farmTexture, new Vector2((r+y)*gridUnitSize, (c+x)*gridUnitSize), i);
                                        a.AddProperty(farm);
                                        objects.Add(farm);
                                        grid[r + y, c + x] = farm;
                                    }
                                    else
                                    {
                                        WObject emptyProperty = new EmptyProperty(emptyTexture, new Vector2((r + y) * gridUnitSize, (c + x) * gridUnitSize), i);
                                        a.AddProperty(emptyProperty);
                                        objects.Add(emptyProperty);
                                        grid[r + y, c + x] = emptyProperty;
                                    }
                                }
                            }
                        done = true;
                        a.position = new Vector2(r * gridUnitSize, c * gridUnitSize);
                        agents.Add(a);
                    }
                }

            }

            int homeless = 45;
            int openField = 0;
            WObject emptySpace = new EmptyProperty(emptyTexture, new Vector2(0, 0), 0);

            for (int i = 0; i < homeless; i++)
            {
                Agent a = new Agent(agentTexture, new Vector2(0, 0), massLogic, i+numAgents);
                Boolean done = false;
                while (!done)
                {
                    Random rnd = new Random(i);
                    int r = rnd.Next(1, rows);
                    int c = rnd.Next(1, cols);
                    if (grid[r, c] == null)
                    {
                        a.position = new Vector2(c * gridUnitSize, r * gridUnitSize);
                        agents.Add(a);
                        done = true;
                    }
                }

            }

            for (int r = 0; r < rows; r++)
            {
                for (int c = 0; c < cols; c++)
                {
                    WObject farm = new Farmland(farmTexture, new Vector2(c * gridUnitSize, r * gridUnitSize), 50);
                    objects.Add(farm);
                    grid[r, c] = farm;
                    foreach (Agent a in agents)
                    {
                        a.AddKnowledge(farm);
                    }
                }
            }

            // TODO: use this.Content to load your game content here
        }