Пример #1
0
        private void MenuOpen_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(Environment.CurrentDirectory + @"\Project\"))
            {
                Directory.CreateDirectory(Environment.CurrentDirectory + @"\Project\");
            }

            var dialog = new OpenFileDialog()
            {
                InitialDirectory = Environment.CurrentDirectory + @"\Project\",
                Filter           = "Engine Maps (*.mps) | *.mps",
                CheckFileExists  = true,
                CheckPathExists  = true,
                Multiselect      = false,
                FilterIndex      = 0
            };

            var result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                var db = new Database();
                Map = (Map)db.Open(dialog.FileName);

                ProjectPath  = dialog.FileName;
                SafeFileName = dialog.SafeFileName;

                UpdateTitle();
                UpdateSize();
            }

            PictureMap.Invalidate();
        }
Пример #2
0
 private void RadioDirection_CheckedChanged(object sender, EventArgs e)
 {
     GroupAttributes.Enabled      = false;
     ButtonClearDirection.Enabled = true;
     MenuCreateMap.Enabled        = false;
     PictureMap.Invalidate();
 }
Пример #3
0
        public static Paint Initialize <Paint>(PictureMap ppcm_Map) where Paint : IPaint, new()
        {
            Paint paint = new Paint();

            paint.Map = ppcm_Map;
            return(paint);
        }
 internal GameForm(int i_Width, int i_Height, int i_TypeOfGame, string i_FirstPlayerName, string i_SecondPlayerName)
 {
     r_FlipTimer = new Timer()
     {
         Interval = 10
     };
     r_FlipTimer.Tick += flipTimer_Tick;
     r_ComputerTimer   = new Timer()
     {
         Interval = 1000
     };
     r_ComputerTimer.Tick += computerTimer_Tick;
     m_FirstChosen         = string.Empty;
     m_SecondChosen        = string.Empty;
     Text = k_WindowName;
     r_PlayersNames[0]          = i_FirstPlayerName;
     r_PlayersNames[1]          = i_SecondPlayerName;
     m_CurrentGame              = new SingleGame(i_Width, i_Height, i_TypeOfGame, i_FirstPlayerName, i_SecondPlayerName);
     r_TypeOfGame               = i_TypeOfGame;
     AutoSize                   = true;
     r_Height                   = i_Height;
     r_Width                    = i_Width;
     r_ButtonMap                = new Dictionary <string, GameButton>(i_Height * i_Width);
     r_PicturesMap              = new PictureMap(i_Height * i_Width / 2);
     r_CurrentPlayerLabel       = new Label();
     r_PlayerLabel[0]           = new Label();
     r_PlayerLabel[1]           = new Label();
     r_EndOfGameForm            = new EndOfGameForm();
     m_CurrentGame.EndGame     += endTheGame;
     m_CurrentGame.GoodMatch   += updateLabel_GoodMatch;
     m_CurrentGame.WrongChoice += flip_WrongChoice;
     m_CurrentGame.AIChoice    += buttonClick_AIChoice;
     initializeBoardComponent();
     this.Shown += gameForm_Shown;
 }
Пример #5
0
        private void PictureMap_MouseDown(object sender, MouseEventArgs e)
        {
            var clicked_x    = ((StartX * PicSize) + e.X) / TileSize;
            var clicked_y    = ((StartY * PicSize) + e.Y) / TileSize;
            var clicked_tile = GetClickedAreaIndex(clicked_x, clicked_y);
            var x            = (e.X / PicSize) + StartX;
            var y            = (e.Y / PicSize) + StartY;

            if (RadioGround.Checked)
            {
                if (e.Button == MouseButtons.Left)
                {
                    OpenParallaxImage(Map.Ground, clicked_tile);
                }
                else if (e.Button == MouseButtons.Right)
                {
                    Map.Ground[clicked_tile].Bitmap = null;
                    Map.Ground[clicked_tile].Name   = "Empty";
                }
            }
            else if (RadioFringe.Checked)
            {
                if (e.Button == MouseButtons.Left)
                {
                    OpenParallaxImage(Map.Fringe, clicked_tile);
                }
                else if (e.Button == MouseButtons.Right)
                {
                    Map.Fringe[clicked_tile].Bitmap = null;
                    Map.Fringe[clicked_tile].Name   = "Empty";
                }
            }
            else if (RadioAttributes.Checked)
            {
                if (e.Button == MouseButtons.Left)
                {
                    SelectAttribute(x, y);
                }
                else if (e.Button == MouseButtons.Right)
                {
                    DiselectAttribute(x, y);
                }
            }

            if (RadioDirection.Checked)
            {
                if (e.Button == MouseButtons.Left)
                {
                    SetDirection(x, y, e.X, e.Y);
                }
            }

            PictureMap.Invalidate();
        }
Пример #6
0
        private void ScrollParallaxOpacity_Scroll(object sender, ScrollEventArgs e)
        {
            var value = ScrollParallaxOpacity.Value;

            LabelParallaxOpacity.Text = "Grid Parallax: " + value;

            var coral_brush = new SolidBrush(Color.FromArgb(value, Color.Coral));

            coral_pen = new Pen(coral_brush, 3);

            PictureMap.Invalidate();
        }
Пример #7
0
        private void ClearAttributes()
        {
            for (var x = 0; x < Map.Property.Width; x++)
            {
                for (var y = 0; y < Map.Property.Height; y++)
                {
                    ClearAttribute(x, y);
                }
            }

            PictureMap.Invalidate();
        }
Пример #8
0
        private void ClearDirections()
        {
            for (var x = 0; x < Map.Property.Width; x++)
            {
                for (var y = 0; y < Map.Property.Height; y++)
                {
                    ClearDirection(x, y);
                }
            }

            PictureMap.Invalidate();
        }
Пример #9
0
        private void ScrollGridOpacity_Scroll(object sender, ScrollEventArgs e)
        {
            var value = ScrollGridOpacity.Value;

            LabelGridOpacity.Text = "Grid Map: " + value;

            var white_brush = new SolidBrush(Color.FromArgb(value, Color.LightGray));

            white_pen = new Pen(white_brush, 1);

            PictureMap.Invalidate();
        }
Пример #10
0
 public static bool IsValidPoint(PictureMap ppcm_Map, int x, int y)
 {
     if (x < 0)
     {
         return(false);
     }
     if (y < 0)
     {
         return(false);
     }
     if (x >= ppcm_Map.QtdColumns)
     {
         return(false);
     }
     if (y >= ppcm_Map.QtdRows)
     {
         return(false);
     }
     return(true);
 }
Пример #11
0
 /// <summary>
 /// When it receives data from the Dispatcher, if checks if there is a '_' in front of the data
 /// If so, it knows that is the assigned ID that it got from the system and assigns itself that ID
 /// If not, it knows that it has gotten destination info, so it access the Bing API to retrieve a route
 /// </summary>
 /// <param name="ipAddr"></param>
 /// <param name="data"></param>
 void NetObserver.DataRecieved(string ipAddr, byte[] data)
 {
     if (connectedIP == ipAddr)
     {
         //Converts data received into a string
         string    receivedData = Encoding.ASCII.GetString(data);
         string [] splitString  = receivedData.Split(';');
         receivedData = splitString[0];
         Console.WriteLine(receivedData);
         if (receivedData[0] == '_')
         {
             string[] splitted = receivedData.Split('_');
             receivedData = splitted[1];
             myID         = Convert.ToInt32(receivedData);
             signedin     = true;
         }
         else
         {
             PictureMap.Load(bingMapAdapter.getImage(inputLocation, receivedData));
         }
     }
 }
Пример #12
0
        private void OpenParallaxImage(List <Parallax> list, int index)
        {
            var dialog = new OpenFileDialog()
            {
                InitialDirectory = Environment.CurrentDirectory,
                Filter           = "Image Files (*.png) | *.png",
                CheckFileExists  = true,
                CheckPathExists  = true,
                Multiselect      = false,
                FilterIndex      = 0
            };

            var result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                var bitmap = new Bitmap(dialog.FileName);

                list[index].Bitmap = bitmap;
                list[index].Name   = dialog.SafeFileName;

                PictureMap.Invalidate();
            }
        }
Пример #13
0
        public void UpdateSize()
        {
            var value_x = Map.Property.Width - MaxGridViewValueX;
            var value_y = Map.Property.Height - MaxGridViewValueY;

            if (value_x < 0)
            {
                value_x = 0;
            }

            if (value_y < 0)
            {
                value_y = 0;
            }

            if (StartX > value_x)
            {
                StartX = value_x;
            }

            if (StartY > value_y)
            {
                StartY = value_y;
            }

            ScrollStartX.Maximum = value_x;
            ScrollStartY.Maximum = value_y;
            ScrollStartX.Value   = StartX;
            ScrollStartY.Value   = StartY;

            LabelX.Text = "X: " + StartX;
            LabelY.Text = "Y: " + StartY;

            Map.UpdatSize();
            PictureMap.Invalidate();
        }
Пример #14
0
        private void PictureMap_MouseMove(object sender, MouseEventArgs e)
        {
            if (GroupAttributes.Enabled)
            {
                //var clicked_x = ((StartX * PicSize) + e.X) / TileSize;
                //var clicked_y = ((StartY * PicSize) + e.Y) / TileSize;
                //var clicked_tile = GetClickedAreaIndex(clicked_x, clicked_y);
                var x = (e.X / PicSize) + StartX;
                var y = (e.Y / PicSize) + StartY;

                if (RadioAttributes.Checked)
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        SelectAttribute(x, y);
                    }
                    else if (e.Button == MouseButtons.Right)
                    {
                        DiselectAttribute(x, y);
                    }

                    PictureMap.Invalidate();
                }
            }

            if (GetAsyncKeyState(Keys.ShiftKey) < 0)
            {
                if (e.X > lastMouseX)
                {
                    if (StartX < ScrollStartX.Maximum)
                    {
                        StartX++;
                    }
                }
                else
                {
                    if (StartX > 1)
                    {
                        StartX--;
                    }
                }

                lastMouseX         = e.X;
                ScrollStartX.Value = StartX;
                LabelX.Text        = "X: " + StartX;

                PictureMap.Invalidate();
            }

            if (GetAsyncKeyState(Keys.ControlKey) < 0)
            {
                if (e.Y > lastMouseY)
                {
                    if (StartY < ScrollStartY.Maximum)
                    {
                        StartY++;
                    }
                }
                else
                {
                    if (StartY > 1)
                    {
                        StartY--;
                    }
                }

                lastMouseY         = e.Y;
                ScrollStartY.Value = StartY;
                LabelY.Text        = "Y: " + StartY;

                PictureMap.Invalidate();
            }
        }
Пример #15
0
 private void ScrollStartX_Scroll(object sender, ScrollEventArgs e)
 {
     StartX      = ScrollStartX.Value;
     LabelX.Text = "X: " + StartX;
     PictureMap.Invalidate();
 }
Пример #16
0
 private void MenuParallaxId_Click(object sender, EventArgs e)
 {
     ViewParallaxId = MenuParallaxId.Checked;
     PictureMap.Invalidate();
 }
Пример #17
0
 private void MenuFringeView_Click(object sender, EventArgs e)
 {
     ViewFringe = MenuFringeView.Checked;
     PictureMap.Invalidate();
 }
Пример #18
0
 private void MenuGroundView_Click(object sender, EventArgs e)
 {
     ViewGround = MenuGroundView.Checked;
     PictureMap.Invalidate();
 }
Пример #19
0
 private void MenuGridViewParallax_Click(object sender, EventArgs e)
 {
     viewGridParallax = MenuGridViewParallax.Checked;
     PictureMap.Invalidate();
 }
Пример #20
0
 private void MenuGridViewTile_Click(object sender, EventArgs e)
 {
     ViewGridTile = MenuGridViewTile.Checked;
     PictureMap.Invalidate();
 }
Пример #21
0
 private void ScrollStartY_Scroll(object sender, ScrollEventArgs e)
 {
     StartY      = ScrollStartY.Value;
     LabelY.Text = "Y: " + StartY;
     PictureMap.Invalidate();
 }
Пример #22
0
        private void ButtonChangeColor(object sender, EventArgs e)
        {
            var dialog = new ColorDialog()
            {
                AllowFullOpen  = true,
                AnyColor       = true,
                FullOpen       = true,
                SolidColorOnly = false
            };

            SolidBrush brush;
            var        result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                brush = new SolidBrush(dialog.Color);
                ((Button)sender).BackColor = dialog.Color;
            }
            else
            {
                return;
            }

            var full_name = ((Button)sender).Name;
            var index     = full_name.Substring(full_name.Length - 1, 1);
            var name      = full_name.Replace(index, string.Empty);

            if (name == "ButtonBackColor")
            {
                switch (int.Parse(index))
                {
                case 0:
                    brushBackBlock = brush;
                    break;

                case 1:
                    brushBackAvoid = brush;
                    break;

                case 2:
                    brushBackTrap = brush;
                    break;

                case 3:
                    brushBackChat = brush;
                    break;

                case 4:
                    brushBackWarp = brush;
                    break;
                }
            }
            else if (name == "ButtonForeColor")
            {
                switch (int.Parse(index))
                {
                case 0:
                    brushForeBlock = brush;
                    break;

                case 1:
                    brushForeAvoid = brush;
                    break;

                case 2:
                    brushForeTrap = brush;
                    break;

                case 3:
                    brushForeChat = brush;
                    break;

                case 4:
                    brushForeWarp = brush;
                    break;
                }
            }

            PictureMap.Invalidate();
        }
Пример #23
0
        private void CreateMapFromImage(string fileName, string safeFileName)
        {
            var bitmap = new Bitmap(fileName);

            var count_x = bitmap.Width / PicSize;
            var count_y = bitmap.Height / PicSize;

            var tile_count_x = bitmap.Width / TileSize;
            var tile_count_y = bitmap.Height / TileSize;

            if (count_x <= 0)
            {
                ShowInvalidImage();
                return;
            }

            if (count_y <= 0)
            {
                ShowInvalidImage();
                return;
            }

            if (bitmap.Width % PicSize > 0)
            {
                count_x++;
            }

            if (bitmap.Height % PicSize > 0)
            {
                count_y++;
            }

            if (bitmap.Width % TileSize > 0)
            {
                tile_count_x++;
            }

            if (bitmap.Height % TileSize > 0)
            {
                tile_count_y++;
            }

            if (Map.Property.Width != count_x)
            {
                Map.Property.Width = count_x;
            }

            if (Map.Property.Height != count_y)
            {
                Map.Property.Height = count_y;
            }

            UpdateSize();

            var    count = 0;
            Bitmap new_bitmap;

            CreateMapFolder(GetCompleteFolder(GetFolderName(safeFileName)));
            var new_bitmap_path = GetCompleteFolder(GetFolderName(safeFileName));

            for (var x = 0; x < tile_count_x; x++)
            {
                for (var y = 0; y < tile_count_y; y++)
                {
                    new_bitmap = CreateTileFromImage(ref bitmap, x, y);

                    if (RadioGround.Checked)
                    {
                        Map.Ground[count].Name   = $"{safeFileName}_ground_{count + 1}";
                        Map.Ground[count].Bitmap = new_bitmap;

                        new_bitmap.Save(new_bitmap_path + $@"\{safeFileName}_ground_{count + 1}.png");
                    }
                    else if (RadioFringe.Checked)
                    {
                        Map.Fringe[count].Name   = $"{safeFileName}_fringe_{count + 1}";
                        Map.Fringe[count].Bitmap = new_bitmap;

                        new_bitmap.Save(new_bitmap_path + $@"\{safeFileName}_fringe_{count + 1}.png");
                    }

                    count++;
                }
            }

            PictureMap.Invalidate();
        }