Esempio n. 1
0
        /// <summary>
        /// Auteure : Joëlle Boyer
        /// Description : Validate the opening of the selected world.
        /// Date : 2019/11/02
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (cboChoose.SelectedIndex == 0)
            {
                monde = _gMonde.CréerMonde(monde);
            }

            this.DialogResult = DialogResult.OK;
        }
Esempio n. 2
0
        /// <summary>
        /// Auteur : ???
        /// Description : Close this window if the informations are valid.
        /// Date : ???
        /// /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, System.EventArgs e)
        {
            int    width = 0, height = 0;
            bool   validHW = false, valid = false;
            string pathCsv     = txtPathCsv.Text;
            string pathBmp     = txtPathBmp.Text;
            int    defaultTile = m_DefaultTile;
            string desc        = txtDescription.Text;
            int    size        = -1;

            int.TryParse(txtSizeTile.Text, out size);

            // Validate input of fields Height and Width
            if (ValidateInputHW(ref width, ref height))
            {
                m_Width  = width;
                m_Height = height;
                validHW  = true;
            }

            // Validate input of fields other than Height and Width
            if (ValidateInput(desc, size, pathCsv, pathBmp, defaultTile))
            {
                valid = true;
            }

            // If both are valid, create a world with the parameters entered.
            if (validHW && valid)
            {
                HugoLand.Monde m = new HugoLand.Monde()
                {
                    Description = desc,
                    DefaultTile = defaultTile,
                    LimiteX     = m_Width,
                    LimiteY     = m_Height,
                    PathCsv     = pathCsv,
                    PathTile    = pathBmp,
                    SizeTile    = size
                };

                m                 = gMonde.CréerMonde(m);
                MyWorld           = m;
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Auteure : Joëlle Boyer
        /// Description : This event allows the informations to change according to the selected world
        /// Date : 2019/11/02
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cboChoose_SelectedIndexChanged(object sender, EventArgs e)
        {
            string sDescription = cboChoose.Text;

            if (sDescription != "Browse from my maps...")
            {
                monde             = _gMonde.LstMondes.FirstOrDefault(x => x.Description == sDescription);
                chkNoFile.Enabled = true;
            }
            else
            {
                chkNoFile.Enabled = false;
            }

            txtHeight.Text = monde.LimiteY.ToString();
            txtWidth.Text  = monde.LimiteX.ToString();
            btnOk.Enabled  = true;
        }
Esempio n. 4
0
        /* -------------------------------------------------------------- *\
        *   m_NewMap()
        *
        *   - Creates a new map of the selected size.
        \* -------------------------------------------------------------- */
        private void NewMap()
        {
            frmNew       f;
            DialogResult result;
            bool         bResult;

            f             = new frmNew();
            f.MapWidth    = m_Map.Width;
            f.MapHeight   = m_Map.Height;
            f.DefaultTile = m_Map.DefaultTileID;


            result = f.ShowDialog(this);
            if (result == DialogResult.OK)
            {
                m_bOpen        = false;
                picMap.Visible = false;
                this.Cursor    = Cursors.WaitCursor;
                try
                {
                    bResult = m_Map.CreateNew(f.MapWidth, f.MapHeight, f.DefaultTile);

                    if (bResult)
                    {
                        m_bOpen        = true;
                        m_bRefresh     = true;
                        m_bResize      = true;
                        picMap.Visible = true;
                    }
                }
                catch
                {
                    Console.WriteLine("Error Creating...");
                }
                m_MenuLogic();
                world       = f.MyWorld;
                this.Cursor = Cursors.Default;
            }
            else
            {
                MessageBox.Show("You have cancelled the creation of a new world.", "Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Esempio n. 5
0
        public void MapExistingWorld(int worldId)
        {
            List <HugoLand.Item> lstItems = new List <HugoLand.Item>();

            lstItems = m_GestionItem.LstItems.Where(x => x.MondeId == worldId).ToList();
            List <HugoLand.Monstre> lstMonstres = new List <HugoLand.Monstre>();

            lstMonstres = m_GestionMonstre.LstMonstres.Where(x => x.MondeId == worldId).ToList();
            List <HugoLand.ObjetMonde> lstObjMonde = new List <HugoLand.ObjetMonde>();

            lstObjMonde = m_GestionObjetMonde.LstObjetMondes.Where(x => x.MondeId == worldId).ToList();

            HugoLand.Monde m = m_GestionMonde.LstMondes.FirstOrDefault(x => x.Id == worldId);
            int            i, j;

            if (m.LimiteX > csteApplication.MAP_MAX_WIDTH)
            {
                return;
            }
            if (m.LimiteY > csteApplication.MAP_MAX_HEIGHT)
            {
                return;
            }

            // Build Backbuffer
            m_Width  = m.LimiteX;
            m_Height = m.LimiteY;
            int defaultTile = 32; // Grass

            try
            {
                m_Tiles = new int[m_Height, m_Width];

                for (i = 0; i < m_Height; i++)
                {
                    for (j = 0; j < m_Width; j++)
                    {
                        if (j == 0 && i == 0)
                        {
                            foreach (HugoLand.ObjetMonde obj in lstObjMonde)
                            {
                                m_Tiles[obj.x, obj.y] = m_TileLibrary.TileToTileID(obj.x, obj.y);
                            }
                            foreach (HugoLand.Monstre monster in lstMonstres)
                            {
                                m_Tiles[monster.x, monster.y] = m_TileLibrary.TileToTileID(monster.x, monster.y);
                            }
                            foreach (HugoLand.Item item in lstItems)
                            {
                                if (item.IdHero != null)
                                {
                                    m_Tiles[(int)item.x, (int)item.y] = m_TileLibrary.TileToTileID((int)item.x, (int)item.y);
                                }
                            }
                        }
                        if (m.DefaultTile != null && m_Tiles[i, j] == 0)
                        {
                            m_Tiles[i, j] = defaultTile;
                        }
                    }
                }

                m_BackBuffer   = new Bitmap(m_Width * csteApplication.TILE_WIDTH_IN_MAP, m_Height * csteApplication.TILE_HEIGHT_IN_MAP);
                m_BackBufferDC = Graphics.FromImage(m_BackBuffer);

                Refresh();
            }
            catch
            {
                return;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Auteur : ???
        /// Description : Open a window allowing the user to select a *.map file to load.
        /// Update : Joëlle Boyer -> Added "m_ResizeMap()" so that the map immediately shows the changes made. 2019/11/03
        /// Date : ???
        /// </summary>
        private void LoadMap()
        {
            frmOpen f = new frmOpen();

            f.ShowDialog(this);

            if (f.DialogResult == DialogResult.OK)
            {
                DialogResult   result;
                HugoLand.Monde monde   = f.MyWorld;
                string         myWorld = monde.Id.ToString() + ".map";

                if (File.Exists(myWorld) && f.MyWorld.Id != -1)
                {
                    try
                    {
                        m_Map.Load(myWorld);
                        m_bOpen        = true;
                        m_bRefresh     = true;
                        picMap.Visible = true;
                    }
                    catch
                    {
                        Console.WriteLine("Error Loading Existing File ...");
                    }
                }

                else if (!f.NoFile)
                {
                    dlgLoadMap.Title  = "Load Map";
                    dlgLoadMap.Filter = "Map Files (*.map)|*.map|All Files (*.*)|*.*";

                    result = dlgLoadMap.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        m_bOpen        = false;
                        picMap.Visible = false;
                        this.Cursor    = Cursors.WaitCursor;
                        try
                        {
                            m_Map.Load(dlgLoadMap.FileName);
                            m_bOpen        = true;
                            m_bRefresh     = true;
                            picMap.Visible = true;
                        }
                        catch
                        {
                            Console.WriteLine("Error Loading Chosen File ...");
                        }
                    }
                }
                else if (f.NoFile && f.MyWorld.Id != -1)
                {
                    m_bOpen        = false;
                    picMap.Visible = false;
                    this.Cursor    = Cursors.WaitCursor;
                    try
                    {
                        m_Map.MapExistingWorld(f.MyWorld.Id);
                        m_bOpen        = true;
                        m_bRefresh     = true;
                        picMap.Visible = true;
                    }
                    catch
                    {
                        Console.WriteLine("Error Loading Chosen File ...");
                    }
                }

                m_ResizeMap();
                m_MenuLogic();
                world       = f.MyWorld;
                this.Cursor = Cursors.Default;
            }
            else
            {
                MessageBox.Show("You have cancelled the opening of a new world.", "Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }