protected override void OnInputEvent(KeyCode key, ModifierKeys modifiers, int gamepadIndex, bool isRepeat)
        {
            switch (key)
            {
            case KeyCode.Escape:
            case KeyCode.GamepadB:
                UI.ShowPage <PageMainMenu>();
                return;

            case KeyCode.Left:
            case KeyCode.GamepadDPadLeft:
            case KeyCode.GamepadLeftStickLeft:
            case KeyCode.GamepadRightStickLeft:
                CurrentEffect--;
                if ((int)CurrentEffect < 1)
                {
                    CurrentEffect = (TileVFX)(VFX_COUNT - 1);
                }
                UpdateSelectedVFX();
                return;

            case KeyCode.Right:
            case KeyCode.GamepadDPadRight:
            case KeyCode.GamepadLeftStickRight:
            case KeyCode.GamepadRightStickRight:
                CurrentEffect++;
                if (CurrentEffect > (TileVFX)(VFX_COUNT - 1))
                {
                    CurrentEffect = (TileVFX)1;
                }
                UpdateSelectedVFX();
                return;
            }
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="tileIndex">Index of the tile in the tilemap</param>
 /// <param name="color">Color of the tile</param>
 /// <param name="tilemap">Index of the tilemap</param>
 /// <param name="effect">Special shader effect to use when drawing tile</param>
 public UITileBoardTile(int tileIndex, RGBColor color, int tilemap = 0, TileVFX effect = TileVFX.None)
 {
     TileIndex = tileIndex;
     Color     = color;
     Tilemap   = tilemap;
     VFX       = effect;
 }
Exemple #3
0
        public void AddMovingAnimation(string name, Position origin, Position target, float speed, int tile, RGBColor color, TileVFX vfx = TileVFX.None, int tilemap = 0)
        {
            Position[] trajectory = GetPointsBetween(origin, target);

            Sprites.Add(new Sprite(name, SpriteType.Moving, tile, 1, color, tilemap, 1f / Math.Max(1f, speed), trajectory));

            if (Sprites.Count == 1)
            {
                BeginNewSprite();
            }
        }
Exemple #4
0
        /// <summary>
        /// (Internal) Updates the VBO data for a given tile.
        /// </summary>
        /// <param name="x">Tile X INDEX (not position) in the VBO</param>
        /// <param name="y">Tile Y INDEX (not position) in the VBO</param>
        /// <param name="xPos">Tile X POSITION (not index) on the screen</param>
        /// <param name="yPos">Tile Y POSITION (not index) on the screen</param>
        /// <param name="tile">Tile index</param>
        /// <param name="color">Tile color</param>
        /// <param name="tilemap">Tilemap from which to load the tile</param>
        /// <param name="vfx">Special shader VFX to use for this tile</param>
        internal void UpdateTileData(int x, int y, float xPos, float yPos, int tile, RGBColor color, int tilemap = 0, TileVFX vfx = TileVFX.None)
        {
            if ((x < 0) || (y < 0) || (x >= Columns) || (y >= Rows))
            {
                return;                                                      // Tile index is out of bounds
            }
            int index = y * Columns + x;

            int tileY = tile / Renderer.TilemapCount.Width;
            int tileX = tile - tileY * Renderer.TilemapCount.Width;

            float[] vertexData = new float[FLOATS_PER_VERTEX * 4];

            Color4 color4 = color.ToColor4();

            for (int i = 0; i < 4; i++)
            {
                Array.Copy(
                    new float[]
                {
                    xPos + TILE_CORNERS[i].X,
                    yPos + TILE_CORNERS[i].Y,
                    color4.R, color4.G, color4.B,
                    (tileX + TILE_CORNERS[i].X) * Renderer.TileUV.Width,
                    (tileY + TILE_CORNERS[i].Y) * Renderer.TileUV.Height,
                    tilemap, (float)vfx
                },
                    0, vertexData, FLOATS_PER_VERTEX * i, FLOATS_PER_VERTEX);
            }

            GL.BindBuffer(BufferTarget.ArrayBuffer, Handle);
            GL.BufferSubData(BufferTarget.ArrayBuffer, (IntPtr)(index * BYTES_PER_TILE), BYTES_PER_TILE, vertexData);
        }
Exemple #5
0
 /// <summary>
 /// (Internal) Updates the VBO data for a given tile.
 /// </summary>
 /// <param name="x">Tile X index in the VBO *AND* X position on the screen</param>
 /// <param name="y">Tile Y index in the VBO *AND* Y position on the screen</param>
 /// <param name="tile">Tile index</param>
 /// <param name="color">Tile color</param>
 /// <param name="tilemap">Tilemap from which to load the tile</param>
 /// <param name="vfx">Special shader VFX to use for this tile</param>
 internal void UpdateTileData(int x, int y, int tile, RGBColor color, int tilemap = 0, TileVFX vfx = TileVFX.None)
 {
     UpdateTileData(x, y, x, y, tile, color, tilemap, vfx);
 }
        /// <summary>
        /// Draws font tiles on the provided VBO.
        /// </summary>
        /// <param name="vbo">VBO on which to draw</param>
        /// <param name="text">Text to draw</param>
        /// <param name="x">X coordinate</param>
        /// <param name="y">Y coordinate</param>
        /// <param name="tile">Font tile to use</param>
        /// <param name="color">Text color</param>
        /// <param name="effect">Tile shader special effect to use</param>
        internal void DrawTextOnVBO(VBO vbo, string text, int x, int y, int tile, RGBColor color, TileVFX effect)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            byte[] textBytes = Encoding.ASCII.GetBytes(text);

            for (int i = 0; i < textBytes.Length; i++)
            {
                if ((textBytes[i] < 32) || (textBytes[i] > 126))
                {
                    textBytes[i] = 32;
                }

                vbo.UpdateTileData(x + i, y, tile + textBytes[i] - 32, color, Tilemap, effect);
            }
        }