Esempio n. 1
0
 /// <summary>
 /// Method that creates an AssetTexture from a texture project file and registers it on the AssetManager.
 /// </summary>
 /// <param name="label">The label the asset is to be given.</param>
 /// <param name="fileName">The filename to get the content associated with the asset.</param>
 /// <returns>A pointer to the created asset.</returns>
 public static AssetTexture CreateAssetTexture(String label, String fileName)
 {
     Texture2D texture = content.Load<Texture2D>(fileName);
     AssetTexture asset = new AssetTexture(texture, label);
     textures.Add(asset);
     return asset;
 }
Esempio n. 2
0
        /// <summary>
        /// Method that creates an AssetTexture from a Texture2D type and registers it on the AssetManager.
        /// </summary>
        /// <param name="label">The label the asset is to be given.</param>
        /// <param name="texture">The texture content of the asset.</param>
        /// <returns>A pointer to the created asset.</returns>
        public static AssetTexture CreateAssetTexture(String label, Texture2D texture)
        {
            AssetTexture asset = new AssetTexture(texture, label);

            textures.Add(asset);
            return(asset);
        }
Esempio n. 3
0
 public DrawableTexture(String textureLabel, GameObject parent)
 {
     this.texture = AssetManager.getAssetTexture(textureLabel);
     this.parent  = parent;
     this.size    = new Vector2(texture.width, texture.height);
     this.filter  = Color.White;
     this.layer   = 0f;
 }
Esempio n. 4
0
 public DrawableTexture(AssetTexture texture, GameObject parent)
 {
     this.texture = texture;
     this.parent  = parent;
     this.size    = new Vector2(texture.width, texture.height);
     this.filter  = Color.White;
     this.layer   = 0f;
 }
Esempio n. 5
0
 public DrawableTexture(AssetTexture texture, GameObject parent)
 {
     this.texture = texture;
     this.parent = parent;
     this.size = new Vector2(texture.width, texture.height);
     this.filter = Color.White;
     this.layer = 0f;
 }
Esempio n. 6
0
 public DrawableTexture(String textureLabel, GameObject parent)
 {
     this.texture = AssetManager.getAssetTexture(textureLabel);
     this.parent = parent;
     this.size = new Vector2(texture.width, texture.height);
     this.filter = Color.White;
     this.layer = 0f;
 }
Esempio n. 7
0
        /// <summary>
        /// Method that creates an AssetTexture from a texture project file and registers it on the AssetManager.
        /// </summary>
        /// <param name="label">The label the asset is to be given.</param>
        /// <param name="fileName">The filename to get the content associated with the asset.</param>
        /// <returns>A pointer to the created asset.</returns>
        public static AssetTexture CreateAssetTexture(String label, String fileName)
        {
            Texture2D    texture = content.Load <Texture2D>(fileName);
            AssetTexture asset   = new AssetTexture(texture, label);

            textures.Add(asset);
            return(asset);
        }
Esempio n. 8
0
        public static AssetTextureStrip createFromAssetTexture(AssetTexture texture, String name)
        {
            Texture2D content = texture.createAssetCopy("volatile" + texture.name).texture;

            AssetTextureStrip strip = new AssetTextureStrip(name, content, StripOrientation.LeftToRight, texture.size);

            return(strip);
        }
Esempio n. 9
0
 public DrawCallTexture(AssetTexture texture, Vector2 position, float rotation, Color filter, Vector2 scale, float layer)
 {
     this.texture  = texture;
     this.position = position;
     this.rotation = rotation;
     this.filter   = filter;
     this.scale    = scale;
     this.layer    = layer;
 }
Esempio n. 10
0
        public MapPreviewer(World world, Land land, Vector2 size)
            : base(world)
        {
            Texture2D textureBase = land.getMinimap(new Point((int)size.X, (int)size.Y));

            AssetTexture text = new AssetTexture(textureBase, "minimapTexture");

            minimap      = new DrawableTexture(text, this);
            minimap.size = size;
        }
Esempio n. 11
0
        public MapPreviewer(World world, Land land, Vector2 size)
            : base(world)
        {
            Texture2D textureBase = land.getMinimap(new Point((int)size.X,(int)size.Y));

            AssetTexture text = new AssetTexture(textureBase, "minimapTexture");

            minimap = new DrawableTexture(text, this);
            minimap.size = size;
        }
Esempio n. 12
0
        /// <summary>
        /// A constructor which takes the world the ActiveBox will be displayed in and the Camera which will be displayed.
        /// </summary>
        /// <param name="world">The world the ActiveBox is going to be displayed im.</param>
        /// <param name="camera">The camera the ActiveBox will display the texture of.</param>
        public ActiveBox(World world, Camera camera)
            : base(world)
        {
            currentID++;
            ID             = currentID;
            this.camera    = camera;
            this.reDrawing = true;
            AssetTexture textureAsset = AssetManager.CreateAssetTexture("ActiveBoxText" + ID, camera.backbuffer);

            texture = new DrawableTexture(textureAsset, this);
        }
Esempio n. 13
0
        public AssetTexture createAssetCopy(String name)
        {
            Texture2D contentCopy = new Texture2D(textureContent.GraphicsDevice, textureContent.Width, textureContent.Height);

            Color[] content = new Color[textureContent.Width*textureContent.Height];
            textureContent.GetData<Color>(content);
            contentCopy.SetData<Color>(content);

            AssetTexture copy = new AssetTexture(contentCopy, name);
            return copy;
        }
Esempio n. 14
0
        /// <summary>
        /// A constructor which takes the world the ActiveBox will be displayed in plus Camera specifications.
        /// </summary>
        /// <param name="activeBoxWorld">The world the ActiveBox will be displayed in.</param>
        /// <param name="targetWorld">The world the camera displayed will draw.</param>
        /// <param name="cameraWidth">The width of the backbuffer of the camera.</param>
        /// <param name="cameraHeight">The heifht of the backbuffer of the camera.</param>
        public ActiveBox(World activeBoxWorld, World targetWorld, int cameraWidth, int cameraHeight)
            : base(activeBoxWorld)
        {
            currentID++;
            ID          = currentID;
            reDrawing   = true;
            this.camera = new Camera(cameraWidth, cameraHeight, targetWorld);
            AssetTexture textureAsset = AssetManager.CreateAssetTexture("ActiveBoxText" + ID, camera.backbuffer);

            texture = new DrawableTexture(textureAsset, this);
        }
Esempio n. 15
0
        public AssetTexture createAssetCopy(String name)
        {
            Texture2D contentCopy = new Texture2D(textureContent.GraphicsDevice, textureContent.Width, textureContent.Height);

            Color[] content = new Color[textureContent.Width * textureContent.Height];
            textureContent.GetData <Color>(content);
            contentCopy.SetData <Color>(content);

            AssetTexture copy = new AssetTexture(contentCopy, name);

            return(copy);
        }
        public DrawableTextureArrayAsStrip(AssetTexture[] textures, GameObject parent)
        {
            if (textures.Length == 0)
                throw new Exception("Attempt at creating a DrawableTexstureStripAsArray with an empty AssetTexture array");

            this.textures = textures;
            this.parent = parent;
            this.size = new Vector2(textures[0].width, textures[0].height);
            this.filter = Color.White;
            this.layer = 0f;
            this.period = 1f;
        }
Esempio n. 17
0
        public TerrainTile(TerrainType type, Vector2 position, Vector2 size, Land land, int seed)
            : base(land)
        {
            this.position = position;
            this.land = land;
            this.seed = seed;

            terrainTexture = AssetManager.getAssetTexture("whiteSquare").createAssetCopy("terrain");
            texture = new DrawableTexture(terrainTexture , this);
            texture.size = size;
            texture.layer = 1f;
            this.size = size;

            textureLoaded = false;
            loadingTexture = false;
        }
Esempio n. 18
0
        public TerrainTile(TerrainType type, Vector2 position, Vector2 size, Land land, int seed)
            : base(land)
        {
            this.position = position;
            this.land     = land;
            this.seed     = seed;

            terrainTexture = AssetManager.getAssetTexture("whiteSquare").createAssetCopy("terrain");
            texture        = new DrawableTexture(terrainTexture, this);
            texture.size   = size;
            texture.layer  = 1f;
            this.size      = size;

            textureLoaded  = false;
            loadingTexture = false;
        }
Esempio n. 19
0
        public Mountain(int seed, Land world, float radius)
            : base(world)
        {
            this.seed = seed;
            assetTexture = AssetManager.getAssetTexture("whiteSquare").createAssetCopy("mountainTexture");
            texture = new DrawableTexture(assetTexture, this);

            Random rdm = new Random(seed);
            texture.rotation = (float)rdm.NextDouble() * (float)Math.PI * 2f;
            this.radius = radius;
            //radius = MathHelper.Clamp(MathHelper.getNextNormalDistributedFloat(3f, 1f, rdm) * 50f, 30f, 500f);

            texture.size = new Vector2(radius*2f, radius*2f);
            texture.layer = 0.07f;
            textureLoaded = false;
            loadingTexture = false;
        }
Esempio n. 20
0
        public Mountain(int seed, Land world, float radius)
            : base(world)
        {
            this.seed    = seed;
            assetTexture = AssetManager.getAssetTexture("whiteSquare").createAssetCopy("mountainTexture");
            texture      = new DrawableTexture(assetTexture, this);

            Random rdm = new Random(seed);

            texture.rotation = (float)rdm.NextDouble() * (float)Math.PI * 2f;
            this.radius      = radius;
            //radius = MathHelper.Clamp(MathHelper.getNextNormalDistributedFloat(3f, 1f, rdm) * 50f, 30f, 500f);

            texture.size   = new Vector2(radius * 2f, radius * 2f);
            texture.layer  = 0.07f;
            textureLoaded  = false;
            loadingTexture = false;
        }
Esempio n. 21
0
        public static AssetTextureStrip createFromAssetTexture(AssetTexture texture, String name)
        {
            Texture2D content = texture.createAssetCopy("volatile" + texture.name).texture;

            AssetTextureStrip strip = new AssetTextureStrip(name, content, StripOrientation.LeftToRight, texture.size);
            return strip;
        }
Esempio n. 22
0
 /// <summary>
 /// Method that creates an AssetTexture from a Texture2D type and registers it on the AssetManager.
 /// </summary>
 /// <param name="label">The label the asset is to be given.</param>
 /// <param name="texture">The texture content of the asset.</param>
 /// <returns>A pointer to the created asset.</returns>
 public static AssetTexture CreateAssetTexture(String label, Texture2D texture)
 {
     AssetTexture asset = new AssetTexture(texture, label);
     textures.Add(asset);
     return asset;
 }
Esempio n. 23
0
        private AssetTexture[] createTexture()
        {
            int frameCount = land.waterWavesFrameCount;

            AssetTexture[] textures = new AssetTexture[frameCount];

            int spriteWidth  = (int)size.X / reduceFactor;
            int spriteHeight = (int)size.Y / reduceFactor;


            Random rdm = new Random(seed);

            float[,] waterChanceData = land.waterChanceNoise.getValues(new Point(spriteWidth, spriteHeight), position - size / 2f, size);
            Vector3 noiseWaveOrigin = new Vector3(position.X - size.X / 2f, position.Y - size.Y / 2f, 0f);
            Vector3 noiseWaveArea   = new Vector3(size.X, size.Y, (land.waterWavesLoop.Z + 1) * land.waterWavesDistancePeriod);

            float[, ,] waterWaveData = land.waterWaveValues;//land.waterWavesNoise.getValues(new Point3(texture.Width, texture.Height, frameCount), noiseWaveOrigin, noiseWaveArea);
            Point waterWaveDataLengths = new Point(waterWaveData.GetLength(0), waterWaveData.GetLength(1));

            Point waterWaveDataOffset = new Point();

            waterWaveDataOffset.X = (((int)(position.X - size.X / 2)) % waterWaveDataLengths.X + waterWaveDataLengths.X) % waterWaveDataLengths.X;
            waterWaveDataOffset.Y = (((int)(position.Y - size.Y / 2)) % waterWaveDataLengths.Y + waterWaveDataLengths.Y) % waterWaveDataLengths.Y;



            float waterChance = land.waterChanceTreshold;
            int   x, y;
            Color floorColor;
            Color waveColor;
            float normalizedWaterChance;
            float rootedWaterChance;
            float rootedWaveValue;
            float curvedWaterChance;
            Point waterWaveCoordinates = new Point();
            float shore_ocean          = 0.7f;
            float temp;

            Color[,] sandColor = new Color[spriteWidth, spriteHeight];
            for (int i = 0; i < spriteWidth; i++)
            {
                for (int j = 0; j < spriteHeight; j++)
                {
                    normalizedWaterChance = (waterChanceData[i, j] - waterChance) / (1f - waterChance);
                    rootedWaterChance     = (float)Math.Sqrt(normalizedWaterChance);

                    temp            = (float)rdm.NextDouble();
                    sandColor[i, j] = Color.Lerp(Color.Lerp(Color.LightYellow, Color.SaddleBrown, temp * temp), Color.Transparent, 1f - (rootedWaterChance) * (float)rdm.NextDouble());
                }
            }

            int offsetXPerFrame = waterWaveDataLengths.X / frameCount; // <------------------------------------ WATER DISPLACEMENT FACTOR

            for (int k = 0; k < frameCount; k++)
            {
                Texture2D texture    = new Texture2D(Graphics.device, spriteWidth, spriteHeight);
                Color[]   colorArray = new Color[texture.Width * texture.Height];


                for (int i = 0; i < texture.Width * texture.Height; i++)
                {
                    x = i % texture.Width;
                    y = i / texture.Width;

                    if (waterChanceData[x, y] > waterChance)
                    {
                        waterWaveCoordinates.X = ((waterWaveDataOffset.X + x * reduceFactor) % waterWaveDataLengths.X + waterWaveDataLengths.X) % waterWaveDataLengths.X;
                        waterWaveCoordinates.Y = ((waterWaveDataOffset.Y + y * reduceFactor) % waterWaveDataLengths.Y + waterWaveDataLengths.Y) % waterWaveDataLengths.Y;

                        normalizedWaterChance = (waterChanceData[x, y] - waterChance) / (1f - waterChance);
                        rootedWaterChance     = (float)Math.Sqrt(normalizedWaterChance);
                        rootedWaveValue       = (float)Math.Sqrt(MathHelper.SCurveInterpolation(0, 1, waterWaveData[waterWaveCoordinates.X, waterWaveCoordinates.Y, k]));
                        //curvedWaterChance = MathHelper.SCurveInterpolation(0, 1, rootedWaterChance);

                        //depth meter
                        if (rootedWaterChance < shore_ocean)
                        {
                            floorColor = Color.Lerp(sandColor[x, y], Color.Blue, (rootedWaterChance / shore_ocean) * (1f + 0.5f * waterWaveData[waterWaveCoordinates.X, waterWaveCoordinates.Y, k]));
                        }
                        else
                        {
                            floorColor = Color.Lerp(Color.Blue, Color.Black, (rootedWaterChance - shore_ocean) / (1f - shore_ocean) * (1f + 0.2f * waterWaveData[waterWaveCoordinates.X, waterWaveCoordinates.Y, k] * ((float)rdm.NextDouble() * 0.4f + 0.6f)));
                        }

                        waveColor = Color.Lerp(floorColor, Color.Black, waterWaveData[waterWaveCoordinates.X, waterWaveCoordinates.Y, k] * rootedWaterChance - ((float)rdm.NextDouble() * 0.2f + 0.8f) * (1f - rootedWaterChance) * 0.1f + 0.1f);

                        colorArray[i] = waveColor;//Color.Lerp(floorColor, waveColor, normalizedWaterChance);
                    }
                    else
                    {
                        colorArray[i] = Color.Transparent;
                    }
                }

                texture.SetData <Color>(colorArray);
                textures[k] = new AssetTexture(texture, "waterTileFrame" + k);
            }

            return(textures);
        }
Esempio n. 24
0
 public DrawCallTexture(AssetTexture texture, Vector2 position, float rotation, Color filter, Vector2 scale, float layer)
 {
     this.texture = texture;
     this.position = position;
     this.rotation = rotation;
     this.filter = filter;
     this.scale = scale;
     this.layer = layer;
 }
Esempio n. 25
0
 public Dummy(World world, AssetTexture texture)
     : base(world)
 {
     this.texture = new DrawableTexture(texture, this);
 }
Esempio n. 26
0
        private AssetTexture[] createTexture()
        {
            int frameCount = land.waterWavesFrameCount;

            AssetTexture[] textures = new AssetTexture[frameCount];

            int spriteWidth = (int)size.X/reduceFactor;
            int spriteHeight = (int)size.Y/reduceFactor;

            Random rdm = new Random(seed);

            float[,] waterChanceData = land.waterChanceNoise.getValues(new Point(spriteWidth, spriteHeight), position - size / 2f, size);
            Vector3 noiseWaveOrigin = new Vector3(position.X - size.X / 2f, position.Y - size.Y / 2f, 0f);
            Vector3 noiseWaveArea = new Vector3(size.X, size.Y, (land.waterWavesLoop.Z + 1) * land.waterWavesDistancePeriod);
            float[, ,] waterWaveData = land.waterWaveValues;//land.waterWavesNoise.getValues(new Point3(texture.Width, texture.Height, frameCount), noiseWaveOrigin, noiseWaveArea);
            Point waterWaveDataLengths = new Point(waterWaveData.GetLength(0) ,waterWaveData.GetLength(1) );

            Point waterWaveDataOffset = new Point();
            waterWaveDataOffset.X = (((int)(position.X - size.X / 2)) % waterWaveDataLengths.X + waterWaveDataLengths.X) % waterWaveDataLengths.X;
            waterWaveDataOffset.Y = (((int)(position.Y - size.Y / 2)) % waterWaveDataLengths.Y + waterWaveDataLengths.Y) % waterWaveDataLengths.Y;

            float waterChance = land.waterChanceTreshold;
            int x, y;
            Color floorColor;
            Color waveColor;
            float normalizedWaterChance;
            float rootedWaterChance;
            float rootedWaveValue;
            float curvedWaterChance;
            Point waterWaveCoordinates = new Point();
            float shore_ocean = 0.7f;
            float temp;
            Color[,] sandColor = new Color[spriteWidth, spriteHeight];
            for(int i=0;i<spriteWidth;i++)
                for (int j = 0; j < spriteHeight; j++)
                {
                    normalizedWaterChance = (waterChanceData[i, j] - waterChance) / (1f - waterChance);
                    rootedWaterChance = (float)Math.Sqrt(normalizedWaterChance);

                    temp = (float)rdm.NextDouble();
                    sandColor[i, j] = Color.Lerp(Color.Lerp(Color.LightYellow, Color.SaddleBrown, temp * temp), Color.Transparent, 1f - (rootedWaterChance) * (float)rdm.NextDouble());
                }

            int offsetXPerFrame = waterWaveDataLengths.X/frameCount; // <------------------------------------ WATER DISPLACEMENT FACTOR
            for (int k = 0; k < frameCount; k++)
            {
                Texture2D texture = new Texture2D(Graphics.device, spriteWidth, spriteHeight);
                Color[] colorArray = new Color[texture.Width * texture.Height];

                for (int i = 0; i < texture.Width * texture.Height; i++)
                {
                    x = i % texture.Width;
                    y = i / texture.Width;

                    if (waterChanceData[x, y] > waterChance)
                    {

                        waterWaveCoordinates.X = ((waterWaveDataOffset.X + x * reduceFactor) % waterWaveDataLengths.X + waterWaveDataLengths.X) % waterWaveDataLengths.X;
                        waterWaveCoordinates.Y = ((waterWaveDataOffset.Y + y * reduceFactor) % waterWaveDataLengths.Y + waterWaveDataLengths.Y) % waterWaveDataLengths.Y;

                        normalizedWaterChance = (waterChanceData[x, y] - waterChance) / (1f - waterChance);
                        rootedWaterChance = (float)Math.Sqrt(normalizedWaterChance);
                        rootedWaveValue = (float)Math.Sqrt(MathHelper.SCurveInterpolation(0, 1, waterWaveData[waterWaveCoordinates.X, waterWaveCoordinates.Y, k]));
                        //curvedWaterChance = MathHelper.SCurveInterpolation(0, 1, rootedWaterChance);

                        //depth meter
                        if (rootedWaterChance < shore_ocean)
                            floorColor = Color.Lerp(sandColor[x, y], Color.Blue, (rootedWaterChance / shore_ocean) * (1f + 0.5f * waterWaveData[waterWaveCoordinates.X, waterWaveCoordinates.Y, k]));
                        else
                            floorColor = Color.Lerp(Color.Blue, Color.Black, (rootedWaterChance - shore_ocean) / (1f - shore_ocean) * (1f + 0.2f * waterWaveData[waterWaveCoordinates.X, waterWaveCoordinates.Y, k] * ((float)rdm.NextDouble() * 0.4f + 0.6f)));

                        waveColor = Color.Lerp(floorColor, Color.Black, waterWaveData[waterWaveCoordinates.X, waterWaveCoordinates.Y, k] * rootedWaterChance - ((float)rdm.NextDouble()*0.2f + 0.8f) * (1f - rootedWaterChance) * 0.1f + 0.1f);

                        colorArray[i] = waveColor;//Color.Lerp(floorColor, waveColor, normalizedWaterChance);
                    }
                    else
                    {
                        colorArray[i] = Color.Transparent;
                    }
                }

                texture.SetData<Color>(colorArray);
                textures[k] = new AssetTexture(texture, "waterTileFrame" + k);
            }

            return textures;
        }
Esempio n. 27
0
 public Dummy(World world, AssetTexture texture)
     : base(world)
 {
     this.texture = new DrawableTexture(texture, this);
 }