コード例 #1
0
        public void GatherRenderables(EntityManager manager, Camera camera)
        {
            for (int i = 0; i < width * height; i++)
            {
                renderData[i].layer = Layer.None;
            }

            // @GACK: its a pain to do this for every type...
            for (int i = 0; i < manager.grass.Count; i++)
            {
                Grass g = manager.grass[i];

                TryAddToRenderables(camera, g.position, g.renderable, Layer.Floor);
            }

            for (int i = 0; i < manager.snow.Count; i++)
            {
                Snow g = manager.snow[i];

                TryAddToRenderables(camera, g.position, g.renderable, Layer.Floor);
            }

            for (int i = 0; i < manager.rats.Count; i++)
            {
                Rat r = manager.rats[i];

                TryAddToRenderables(camera, r.position, r.renderable, Layer.Ground);
            }

            TryAddToRenderables(camera, manager.player.position, manager.player.renderable, Layer.Ground);

            // Set all the layers to None so it's easy to automatically override
        }
コード例 #2
0
        public EntityHandle AddGrass(Grass g)
        {
            EntityHandle handle = AddEntity(EntityType.Grass, grass.Count);

            grass.Add(g);
            return(handle);
        }
コード例 #3
0
        void GenerateBiomes()
        {
            int biomeCount = 4;

            Rect[] biomeRegions = new Rect[biomeCount];

            Vector2 biomeDimensions = new Vector2(worldDimensions.x / biomeCount,
                                                  worldDimensions.y / biomeCount);

            biomeRegions[0].dimensions = biomeDimensions;

            biomeRegions[1].position   = new Vector2(biomeDimensions.x, 0);
            biomeRegions[1].dimensions = biomeDimensions;

            biomeRegions[2].position   = new Vector2(0, biomeDimensions.y);
            biomeRegions[2].dimensions = biomeDimensions;

            biomeRegions[3].position   = new Vector2(biomeDimensions.x, biomeDimensions.y);
            biomeRegions[3].dimensions = biomeDimensions;

            Vector2 cursorPosition = new Vector2(0, 0);
            Grass   g = new Grass(cursorPosition);
            Snow    s = new Snow(cursorPosition);

            for (int y = 0; y < worldDimensions.y; y++)
            {
                for (int x = 0; x < worldDimensions.x; x++)
                {
                    cursorPosition.x = x;
                    cursorPosition.y = y;

                    if (GameMath.PointInRect(biomeRegions[0], cursorPosition))
                    {
                        g = new Grass(cursorPosition);
                        entityManager.AddGrass(g);
                    }
                    else if (GameMath.PointInRect(biomeRegions[1], cursorPosition))
                    {
                        s = new Snow(cursorPosition);
                        entityManager.AddSnow(s);
                    }
                    else
                    {
                        g = new Grass(cursorPosition);
                        entityManager.AddGrass(g);
                    }
                }
            }
        }
コード例 #4
0
        void GenerateGrass()
        {
            Vector2 cursorPosition = new Vector2(0, 0);
            Grass   grass          = new Grass(cursorPosition);

            for (int y = 0; y < worldDimensions.y; y++)
            {
                for (int x = 0; x < worldDimensions.x; x++)
                {
                    cursorPosition.x = x;
                    cursorPosition.y = y;

                    grass.position = new Vector2(cursorPosition);
                    entityManager.AddGrass(grass);
                }
            }
        }