public static List<BackgroundObject> CreateBackgroundObjects(int amountToCreate, Transform transform, Vector2 generationBounds, Vector2 spacing, StyleManager.LevelStyle style, int depth)
        {
            List<BackgroundObject> result = new List<BackgroundObject>();
            int maxAmountOfObjectsHorizontal = (int)(generationBounds.X / spacing.X);
            if (spacing.X == 0) maxAmountOfObjectsHorizontal = 1;
            int maxAmountOfObjectsVertical = (int)(generationBounds.Y / spacing.Y);
            if (spacing.Y == 0) maxAmountOfObjectsVertical = 1;
            int maxAmountOfObjects = maxAmountOfObjectsHorizontal * maxAmountOfObjectsVertical;

            List<int> indexes = new List<int>();
            for (int i = 0; i < maxAmountOfObjects; ++i)
                indexes.Add(i);

            for (int i = 0; i < amountToCreate; ++i)
            {
                int selectionIndex = Globals.Random.Next(0, indexes.Count);
                int placementX = indexes[selectionIndex] % maxAmountOfObjectsHorizontal;
                int placementY = indexes[selectionIndex] / maxAmountOfObjectsVertical;
                indexes.RemoveAt(selectionIndex);

                BackgroundObject objectToGenerateFrom = Globals.Backgrounds.GetObject(style, depth);
                BackgroundObject newObject = new BackgroundObject(objectToGenerateFrom);
                if(transform != null)
                    newObject.Transform.ParentTransform = transform;
                newObject.Transform.PosX = spacing.X * placementX;
                newObject.Transform.PosY = spacing.Y * placementY;
                newObject.ApplyJitter();
                result.Add(newObject);
            }
            return result;
        }
Пример #2
0
        public BackgroundObject(BackgroundObject objectToGenerateFrom) : base(objectToGenerateFrom)
        {
            Transform.ScaleUniform = objectToGenerateFrom.Transform.SclX + 6;

            m_placementJitter = objectToGenerateFrom.m_placementJitter;
            m_depth           = objectToGenerateFrom.m_depth;

            m_drawingList = World.DL_BgLayers[m_depth];
            m_drawingList.Add(this, 0);
        }
        public BackgroundObject(BackgroundObject objectToGenerateFrom)
            : base(objectToGenerateFrom)
        {
            Transform.ScaleUniform = objectToGenerateFrom.Transform.SclX + 6;

            m_placementJitter = objectToGenerateFrom.m_placementJitter;
            m_depth = objectToGenerateFrom.m_depth;

            m_drawingList = World.DL_BgLayers[m_depth];
            m_drawingList.Add(this, 0);
        }
Пример #4
0
 private void InitialiseCloudStyle()
 {
     BackgroundObject[] layer0Objects = new BackgroundObject[] {
         new Bg_Cloud_Long(0),
     };
     BackgroundObject[] layer1Objects = new BackgroundObject[] {
         new Bg_Cloud_Long(1),
     };
     BackgroundObject[] layer2Objects = new BackgroundObject[] {
         new Bg_Cloud_Long(2),
     };
     _backgroundObjects[StyleManager.LevelStyle.Clouds][0] = layer0Objects;
     _backgroundObjects[StyleManager.LevelStyle.Clouds][1] = layer1Objects;
     _backgroundObjects[StyleManager.LevelStyle.Clouds][2] = layer2Objects;
 }
Пример #5
0
        private void GenerateLandscape()
        {
            List <GameObject> spawnedObjects = new List <GameObject>();

            m_house = new Hs_Building();

            ///
            ///	Backgrounds
            ///
            List <BackgroundObject> backgrounds;

            backgrounds = BackgroundObject.CreateBackgroundObjects((int)(ActiveTileCount * 1.25f), null, new Vector2(TotalLevelWidth, 1), new Vector2(50, 0), StyleManager.LevelStyle.Country, 0);
            for (int i = 0; i < backgrounds.Count; ++i)
            {
                backgrounds[i].Transform.PosY -= 20;
            }
            spawnedObjects.AddRange(backgrounds);

            backgrounds = BackgroundObject.CreateBackgroundObjects((int)(ActiveTileCount * 1.5f), null, new Vector2(TotalLevelWidth, 1), new Vector2(50, 0), StyleManager.LevelStyle.Country, 1);
            for (int i = 0; i < backgrounds.Count; ++i)
            {
                backgrounds[i].Transform.PosY -= 100;
            }
            spawnedObjects.AddRange(backgrounds);

            backgrounds = BackgroundObject.CreateBackgroundObjects(ActiveTileCount * 2, null, new Vector2(TotalLevelWidth, 1), new Vector2(50, 0), StyleManager.LevelStyle.Country, 2);
            for (int i = 0; i < backgrounds.Count; ++i)
            {
                backgrounds[i].Transform.PosY -= 200;
            }
            spawnedObjects.AddRange(backgrounds);

            m_levelObjects[(int)LevelObjectType.Backgrounds] = spawnedObjects;

            ///
            /// Earth Tiles
            ///
            spawnedObjects = new List <GameObject>();
            for (int i = 0; i < m_earthTiles.Length; ++i)
            {
                m_earthTiles[i] = new EarthTile(i);
                spawnedObjects.Add(m_earthTiles[i]);
            }
            m_levelObjects[(int)LevelObjectType.EarthTile] = spawnedObjects;
        }
Пример #6
0
        public static List <BackgroundObject> CreateBackgroundObjects(int amountToCreate, Transform transform, Vector2 generationBounds, Vector2 spacing, StyleManager.LevelStyle style, int depth)
        {
            List <BackgroundObject> result   = new List <BackgroundObject>();
            int maxAmountOfObjectsHorizontal = (int)(generationBounds.X / spacing.X);

            if (spacing.X == 0)
            {
                maxAmountOfObjectsHorizontal = 1;
            }
            int maxAmountOfObjectsVertical = (int)(generationBounds.Y / spacing.Y);

            if (spacing.Y == 0)
            {
                maxAmountOfObjectsVertical = 1;
            }
            int maxAmountOfObjects = maxAmountOfObjectsHorizontal * maxAmountOfObjectsVertical;

            List <int> indexes = new List <int>();

            for (int i = 0; i < maxAmountOfObjects; ++i)
            {
                indexes.Add(i);
            }

            for (int i = 0; i < amountToCreate; ++i)
            {
                int selectionIndex = Globals.Random.Next(0, indexes.Count);
                int placementX     = indexes[selectionIndex] % maxAmountOfObjectsHorizontal;
                int placementY     = indexes[selectionIndex] / maxAmountOfObjectsVertical;
                indexes.RemoveAt(selectionIndex);

                BackgroundObject objectToGenerateFrom = Globals.Backgrounds.GetObject(style, depth);
                BackgroundObject newObject            = new BackgroundObject(objectToGenerateFrom);
                if (transform != null)
                {
                    newObject.Transform.ParentTransform = transform;
                }
                newObject.Transform.PosX = spacing.X * placementX;
                newObject.Transform.PosY = spacing.Y * placementY;
                newObject.ApplyJitter();
                result.Add(newObject);
            }
            return(result);
        }
Пример #7
0
        private void InitialiseCountryStyle()
        {
            BackgroundObject[] layer0Objects = new BackgroundObject[] {
                new Bg_Hill_Naked(0),
                new Bg_Hill_Trees(0),

                new Bg_Cliff_Small(0),
            };
            BackgroundObject[] layer1Objects = new BackgroundObject[] {
                new Bg_Hill_Trees(1),
                new Bg_Hill_Naked(1),
                new Bg_Cliff_Small(1),
                new Bg_Hill_Tall(0),
            };
            BackgroundObject[] layer2Objects = new BackgroundObject[] {
                new Bg_Hill_Trees(2),
                new Bg_Hill_Naked(2),
                new Bg_Cliff_Small(2),
            };
            _backgroundObjects[StyleManager.LevelStyle.Country][0] = layer0Objects;
            _backgroundObjects[StyleManager.LevelStyle.Country][1] = layer1Objects;
            _backgroundObjects[StyleManager.LevelStyle.Country][2] = layer2Objects;
        }
        private void InitialiseCountryStyle()
        {
            BackgroundObject[] layer0Objects = new BackgroundObject[]{
                new Bg_Hill_Naked(0),
                new Bg_Hill_Trees(0),

                new Bg_Cliff_Small(0),
            };
            BackgroundObject[] layer1Objects = new BackgroundObject[]{
                new Bg_Hill_Trees(1),
                new Bg_Hill_Naked(1),
                new Bg_Cliff_Small(1),
                new Bg_Hill_Tall(0),
            };
            BackgroundObject[] layer2Objects = new BackgroundObject[]{
                new Bg_Hill_Trees(2),
                new Bg_Hill_Naked(2),
                new Bg_Cliff_Small(2),
            };
            _backgroundObjects[StyleManager.LevelStyle.Country][0] = layer0Objects;
            _backgroundObjects[StyleManager.LevelStyle.Country][1] = layer1Objects;
            _backgroundObjects[StyleManager.LevelStyle.Country][2] = layer2Objects;
        }
 private void InitialiseCloudStyle()
 {
     BackgroundObject[] layer0Objects = new BackgroundObject[]{
         new Bg_Cloud_Long(0),
     };
     BackgroundObject[] layer1Objects = new BackgroundObject[]{
         new Bg_Cloud_Long(1),
     };
     BackgroundObject[] layer2Objects = new BackgroundObject[]{
         new Bg_Cloud_Long(2),
     };
     _backgroundObjects[StyleManager.LevelStyle.Clouds][0] = layer0Objects;
     _backgroundObjects[StyleManager.LevelStyle.Clouds][1] = layer1Objects;
     _backgroundObjects[StyleManager.LevelStyle.Clouds][2] = layer2Objects;
 }