Example #1
0
        public void UpdateItemStatus(float cameraX, float cameraZ)
        {
            int x = Math.Abs((int)Math.Floor(((cameraX / _sizeX) / 2)));
            int y = Math.Abs((int)Math.Floor(((cameraZ / _sizeY) / 2)));

            this[x + y * _mapWidth].Texture = YnGraphics.CreateTexture(_groundColor, _ceilSize, _ceilSize);
        }
        /// <summary>
        /// Generates a Windows 8 like skin based on a start color.
        /// </summary>
        /// <param name="baseColor">The base color</param>
        /// <param name="fontName">Font name</param>
        /// <param name="animated">set to true to generate "Hover" and "Clicked" skins</param>
        /// <returns>The skin</returns>
        public static YnSkin Generate(Color baseColor, string fontName, bool animated)
        {
            Color  tempColor;
            YnSkin skin = new YnSkin();

            // Default state
            skin.FontNameDefault   = fontName;
            skin.FontDefault       = YnG.Game.Content.Load <SpriteFont>(fontName);
            skin.TextColorDefault  = Color.White;
            skin.BackgroundDefault = YnGraphics.CreateTexture(baseColor, 1, 1);
            skin.BorderDefault     = null; // Borders are left blank

            // If the skin is "animated", generate data for "Hover" and "Clicked" states
            if (animated)
            {
                // Hover state : change only background color
                tempColor            = Add(baseColor, 50, 50, 50);
                skin.BackgroundHover = YnGraphics.CreateTexture(tempColor, 1, 1);

                // Clicked state : invert background & text color
                skin.TextColorClicked  = baseColor;
                skin.BackgroundClicked = YnGraphics.CreateTexture(Color.White, 1, 1);
            }

            return(skin);
        }
Example #3
0
        public override void LoadContent()
        {
            base.LoadContent();

            // To hacked for now
            if (!_environmentTextureLoaded && _environmentTextureNames != null)
            {
                // Detect the texture size if it doesn't specified
                if (_environmentTextureSize == 0)
                {
                    Texture2D firstTexture = YnG.Content.Load <Texture2D>(_environmentTextureNames[0]);
                    _environmentTextureSize = Math.Min(firstTexture.Width, firstTexture.Height);
                }

                // Create the environment texture
                _environmentTexture = new TextureCube(YnG.GraphicsDevice, _environmentTextureSize, _enableTextureMipmap, SurfaceFormat.Color);

                Texture2D texture = null;   // Temp texture
                Color[]   textureData;      // Temp textureData array
                string[]  tempTextureNames = new string[6];

                // If the texture array has not a size of 6, we replace empty texture by the latest
                int nbTextures = _environmentTextureNames.Length;

                for (int i = 0; i < 6; i++)
                {
                    if (i < nbTextures) // Texture
                    {
                        tempTextureNames[i] = _environmentTextureNames[i];
                    }
                    else // Copied texture
                    {
                        tempTextureNames[i] = _environmentTextureNames[nbTextures - 1];
                    }

                    // Load the texture and add it to the TextureCube
                    texture     = YnG.Content.Load <Texture2D>(tempTextureNames[i]);
                    textureData = new Color[texture.Width * texture.Height];
                    texture.GetData <Color>(textureData);
                    _environmentTexture.SetData <Color>((CubeMapFace)i, textureData);
                }

                // Update the texture names array
                _environmentTextureNames  = tempTextureNames;
                _environmentTextureLoaded = true;

                // If the first texture is null we create a dummy texture with the same size of environment texture
                if (_texture == null)
                {
                    _texture       = YnGraphics.CreateTexture(Color.White, _environmentTextureSize, _environmentTextureSize);
                    _textureLoaded = true;
                }
            }

            if (!_effectLoaded)
            {
                _effect       = new EnvironmentMapEffect(YnG.GraphicsDevice);
                _effectLoaded = true;
            }
        }
Example #4
0
        private void DrawRectangle(SpriteBatch spriteBatch, Rectangle rect)
        {
            Texture2D tex = YnGraphics.CreateTexture(Color.Red, 1, 1);

            Vector2 a;
            Vector2 b;

            // Top
            a = new Vector2(rect.X, rect.Y);
            b = new Vector2(rect.X + rect.Width, rect.Y);
            YnGraphics.DrawLine(spriteBatch, tex, 1F, Color.White, a, b);

            // Right
            a = new Vector2(rect.X + rect.Width, rect.Y);
            b = new Vector2(rect.X + rect.Width, rect.Y + rect.Height);
            YnGraphics.DrawLine(spriteBatch, tex, 1F, Color.White, a, b);

            // Bottom
            a = new Vector2(rect.X + rect.Width, rect.Y + rect.Height);
            b = new Vector2(rect.X, rect.Y + rect.Height);
            YnGraphics.DrawLine(spriteBatch, tex, 1F, Color.White, a, b);

            // Left
            a = new Vector2(rect.X, rect.Y + rect.Height);
            b = new Vector2(rect.X, rect.Y);
            YnGraphics.DrawLine(spriteBatch, tex, 1F, Color.White, a, b);
        }
Example #5
0
        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
            spriteBatch.Begin();

            // Interface
            _menuBackground.Draw(gameTime, spriteBatch);
            _notesIcon.Draw(gameTime, spriteBatch);
            _menuIcon.Draw(gameTime, spriteBatch);

            foreach (InventoryItem item in _inventory)
            {
                _itemImages [item.Code].Draw(gameTime, spriteBatch);
            }

            if (ImlostGame.Debug)
            {
                DrawRectangle(spriteBatch, _menuHitbox);
                DrawRectangle(spriteBatch, _leftSceneHitbox);
                DrawRectangle(spriteBatch, _topSceneHitbox);
                DrawRectangle(spriteBatch, _rightSceneHitbox);
                DrawRectangle(spriteBatch, _bottomSceneHitbox);
            }

            if (_deadlySceenOfDeath)
            {
                Texture2D tex  = YnGraphics.CreateTexture(new Color(0, 0, 0, _deathAlpha), 1, 1);
                Rectangle rect = new Rectangle(0, 0, YnG.Width, YnG.Height);
                spriteBatch.Draw(tex, rect, Color.White);
            }

            // Images sur la scène
            List <YnEntity> safeList = new List <YnEntity>(_itemsOnScreen);

            foreach (YnEntity img in safeList)
            {
                img.Draw(gameTime, spriteBatch);
            }

            if (_dragging)
            {
                _draggedImage.Draw(gameTime, spriteBatch);
            }

            _narationText.Draw(gameTime, spriteBatch);

            // Par dessus tout, on dessine le splash
            if (_showSplash)
            {
                _splash.Draw(gameTime, spriteBatch);
            }
            spriteBatch.End();
        }
        private void DrawLines(SpriteBatch spriteBatch, int y = 50, int offset = 30)
        {
            Texture2D blank = YnGraphics.CreateTexture(Color.White, 1, 1);

            float percent   = (((100.0f * (float)(y - (offset * 4))) / ((float)YnG.Height / 2))) / 100.0f;
            float direction = -1.0f;

            offset = (int)(offset * percent * direction);

            YnGraphics.DrawLine(spriteBatch, blank, 2, new Color(100, 100, 100), new Vector2(borderLeft.X, YnG.Height - y), new Vector2(borderLeft.X + borderLeft.Width, YnG.Height - y));
            YnGraphics.DrawLine(spriteBatch, blank, 1, new Color(75, 75, 75), new Vector2(borderLeft.X + borderLeft.Width, YnG.Height - y), new Vector2(angularLeft.X + angularLeft.Width, YnG.Height - (y + offset)));
            YnGraphics.DrawLine(spriteBatch, blank, 1, new Color(50, 50, 50), new Vector2(angularLeft.X + angularLeft.Width, YnG.Height - (y + offset)), new Vector2(center.X + center.Width, YnG.Height - (y + offset)));
            YnGraphics.DrawLine(spriteBatch, blank, 1, new Color(75, 75, 75), new Vector2(center.X + center.Width, YnG.Height - (y + offset)), new Vector2(angularRight.X + angularRight.Width, YnG.Height - y));
            YnGraphics.DrawLine(spriteBatch, blank, 2, new Color(100, 100, 100), new Vector2(angularRight.X + angularRight.Width, YnG.Height - y), new Vector2(borderRight.X + borderRight.Width, YnG.Height - y));
        }
Example #7
0
        /// <summary>
        /// Create a flat border definition based on the given color and
        /// border size.
        /// </summary>
        /// <param name="borderColor">The border color</param>
        /// <param name="thickness">The border thickness</param>
        public YnBorder(Color borderColor, int thickness)
        {
            // Corners
            Texture2D cornerTexture = YnGraphics.CreateTexture(borderColor, thickness, thickness);

            TopLeft     = cornerTexture;
            TopRight    = cornerTexture;
            BottomRight = cornerTexture;
            BottomLeft  = cornerTexture;

            // Horizontal
            Texture2D hTexture = YnGraphics.CreateTexture(borderColor, 1, thickness);

            Top    = hTexture;
            Bottom = hTexture;

            // Vertical
            Texture2D vTexture = YnGraphics.CreateTexture(borderColor, thickness, 1);

            Left  = vTexture;
            Right = vTexture;
        }
Example #8
0
        /// <summary>
        /// Initialize the emitter with a default particle collection.
        /// Created particles are a size of 4x4 and a random color.
        /// </summary>
        public override void Initialize()
        {
            Color color = YnRandom.GetColor();

            Initialize(YnGraphics.CreateTexture(color, 4, 4));
        }
Example #9
0
 /// <summary>
 /// Initialize the emitter and setup the particles.
 /// </summary>
 /// <param name="particleColor">Particle color</param>
 /// <param name="particleWidth">Particle width</param>
 /// <param name="particleHeight">Particle height</param>
 public void Initialize(Color particleColor, int particleWidth, int particleHeight)
 {
     Initialize(YnGraphics.CreateTexture(particleColor, particleWidth, particleHeight));
 }