Example #1
0
        public void PassageInput(MouseEventArgs e)
        {
            bool LeftButton   = e.LeftButton;
            bool RightButton  = e.RightButton;
            bool MiddleButton = e.MiddleButton;

            int TileX = (int)Math.Floor(e.X / 33d);
            int TileY = (int)Math.Floor(e.Y / 33d);

            Game.Passability pass = this.Tileset.Passabilities[TileY * 8 + TileX];
            if (pass == Game.Passability.None)
            {
                pass = Game.Passability.All;
            }
            else
            {
                pass = Game.Passability.None;
            }
            this.Tileset.Passabilities[TileY * 8 + TileX] = pass;

            Bitmap bmp4dir = FourDirList.TilesetBox.Sprites["controls"].Bitmap;

            bmp4dir.Unlock();
            bmp4dir.FillRect(TileX * 33, TileY * 33, 32, 32, Color.ALPHA);
            FourDirDrawTile(TileX, TileY);
            bmp4dir.Lock();
            Bitmap bmppass = PassageList.TilesetBox.Sprites["controls"].Bitmap;

            bmppass.Unlock();
            bmppass.FillRect(TileX * 33, TileY * 33, 32, 32, Color.ALPHA);
            PassageDrawTile(TileX, TileY);
            bmppass.Lock();
        }
Example #2
0
        public void PassageDrawTile(int TileX, int TileY)
        {
            Bitmap bmp = PassageList.TilesetBox.Sprites["controls"].Bitmap;

            Game.Passability p = this.Tileset.Passabilities[TileY * 8 + TileX];
            int ix             = TileX * 33;
            int iy             = TileY * 33;

            if (p == Game.Passability.None)
            {
                bmp.Build(ix, iy, impassable);
            }
            else
            {
                bmp.Build(ix, iy, passable);
            }
        }
Example #3
0
        public void FourDirDrawTile(int TileX, int TileY)
        {
            Bitmap bmp = FourDirList.TilesetBox.Sprites["controls"].Bitmap;

            Game.Passability p = this.Tileset.Passabilities[TileY * 8 + TileX];
            int  ix            = TileX * 33;
            int  iy            = TileY * 33;
            bool up            = (p & Game.Passability.Up) == Game.Passability.Up;
            bool left          = (p & Game.Passability.Left) == Game.Passability.Left;
            bool right         = (p & Game.Passability.Right) == Game.Passability.Right;
            bool down          = (p & Game.Passability.Down) == Game.Passability.Down;

            if (up)
            {
                bmp.Build(ix + 8, iy + 1, big_up);
            }
            else
            {
                bmp.Build(ix + 12, iy + 2, small_up);
            }
            if (left)
            {
                bmp.Build(ix + 1, iy + 8, big_left);
            }
            else
            {
                bmp.Build(ix + 2, iy + 12, small_left);
            }
            if (right)
            {
                bmp.Build(ix + 25, iy + 8, big_right);
            }
            else
            {
                bmp.Build(ix + 24, iy + 12, small_right);
            }
            if (down)
            {
                bmp.Build(ix + 8, iy + 25, big_down);
            }
            else
            {
                bmp.Build(ix + 12, iy + 24, small_down);
            }
        }
Example #4
0
        public void FourDirInput(MouseEventArgs e)
        {
            bool LeftButton   = e.LeftButton;
            bool RightButton  = e.RightButton;
            bool MiddleButton = e.MiddleButton;

            int  TileX = (int)Math.Floor(e.X / 33d);
            int  TileY = (int)Math.Floor(e.Y / 33d);
            int  rx    = e.X - TileX * 33;
            int  ry    = e.Y - TileY * 33;
            bool up    = false;
            bool left  = false;
            bool right = false;
            bool down  = false;

            if (ry <= 15 &&
                rx >= 1 + ry && rx <= 31 - ry)
            {
                up = true;
            }
            else if (ry >= 16 &&
                     rx >= 31 - ry && rx <= ry - 1)
            {
                down = true;
            }
            else if (rx <= 15 &&
                     ry >= rx && ry < 31 - rx)
            {
                left = true;
            }
            else
            {
                right = true;
            }
            Game.Passability pass = this.Tileset.Passabilities[TileY * 8 + TileX];
            if (up)
            {
                if ((pass & Game.Passability.Up) == Game.Passability.Up)
                {
                    pass -= Game.Passability.Up;
                }
                else
                {
                    pass |= Game.Passability.Up;
                }
            }
            else if (left)
            {
                if ((pass & Game.Passability.Left) == Game.Passability.Left)
                {
                    pass -= Game.Passability.Left;
                }
                else
                {
                    pass |= Game.Passability.Left;
                }
            }
            else if (right)
            {
                if ((pass & Game.Passability.Right) == Game.Passability.Right)
                {
                    pass -= Game.Passability.Right;
                }
                else
                {
                    pass |= Game.Passability.Right;
                }
            }
            else if (down)
            {
                if ((pass & Game.Passability.Down) == Game.Passability.Down)
                {
                    pass -= Game.Passability.Down;
                }
                else
                {
                    pass |= Game.Passability.Down;
                }
            }
            else
            {
                throw new Exception($"Input management incorrect (rx,ry) = ({rx},{ry})");
            }
            this.Tileset.Passabilities[TileY * 8 + TileX] = pass;
            Bitmap bmp4dir = FourDirList.TilesetBox.Sprites["controls"].Bitmap;

            bmp4dir.Unlock();
            bmp4dir.FillRect(TileX * 33, TileY * 33, 32, 32, Color.ALPHA);
            FourDirDrawTile(TileX, TileY);
            bmp4dir.Lock();
            Bitmap bmppass = PassageList.TilesetBox.Sprites["controls"].Bitmap;

            bmppass.Unlock();
            bmppass.FillRect(TileX * 33, TileY * 33, 32, 32, Color.ALPHA);
            PassageDrawTile(TileX, TileY);
            bmppass.Lock();
        }