コード例 #1
0
        /****************************************
        *  Fonctions contrôle / maintenance
        ****************************************/

        public bool Charger_niveau()
        {
            bool   Ok = true;
            string line;

            string[] split;
            string   FichierNiveau = "";
            int      x             = 0;
            int      y             = 0;
            int      splitc;

            if (_natif)
            {
                if (_niveau > 0)
                {
                    FichierNiveau = param.ObtenirPosition() + "\\niveaux\\niveaux\\" + _niveau.ToString() + ".txt";
                }
            }
            else
            {
                FichierNiveau = param.ObtenirPosition() + "\\niveaux\\niveaux utilisateur\\" + _nomNiveau + ".txt";
            }

            if (File.Exists(FichierNiveau))
            {
                System.IO.StreamReader file = new System.IO.StreamReader(FichierNiveau);

                for (y = 0; y < 24; y++)
                {
                    line  = file.ReadLine().ToString();
                    split = line.Split(new Char[] { ';' });

                    for (x = 0; x < 15; x++)
                    {
                        splitc = Convert.ToInt32(split[x]);

                        tableauBrique[x, y] = new Brique();
                        tableauBrique[x, y].ChargerLabel8(label8);
                        tableauBrique[x, y].Charger_Brique(splitc, x, y, this);
                    }
                }
            }
            else
            {
                Ok = false;
            }
            loaded      = true;
            label8.Text = CompterBriquesRestantes().ToString();

            return(Ok);
        }
コード例 #2
0
ファイル: Form4.cs プロジェクト: Adri-Donn/Maltus-Arkanoid
        private void Form4_MouseUp(object sender, MouseEventArgs e)
        {
            int x, y;

            if (e.Button == MouseButtons.Left)
            {
                if (ItemSelectionne >= 0 && ItemSelectionne <= 4)
                {
                    if (Control.MousePosition.X > 0 && Control.MousePosition.X < Convert.ToInt32(param.ObtenirTEJX() * param.ObtenirRAPPORTX()))
                    {
                        if (Control.MousePosition.Y > 0 && Control.MousePosition.Y < Convert.ToInt32(param.ObtenirTailleZoneBriqueY() * param.ObtenirRAPPORTY()))
                        {
                            x = Convert.ToInt32(Math.Floor((Control.MousePosition.X / param.ObtenirRAPPORTX()) / (param.ObtenirTailleBriqueX())));
                            y = Convert.ToInt32(Math.Floor((Control.MousePosition.Y / param.ObtenirRAPPORTY()) / (param.ObtenirTailleBriqueY())));

                            if (ItemSelectionne != 0 && ItemSelectionne < 5)
                            {
                                if (carte[x, y] == 0)
                                {
                                    try
                                    {
                                        tableauBrique[x, y] = new Brique();
                                        tableauBrique[x, y].setUnlock();
                                        tableauBrique[x, y].Charger_Brique(ItemSelectionne, x, y, this);
                                        carte[x, y] = ItemSelectionne;
                                    }
                                    catch (Exception err)
                                    {
                                        Console.WriteLine(err);
                                        try
                                        {
                                            tableauBrique[x, y].Changer_Brique(ItemSelectionne);
                                            carte[x, y] = ItemSelectionne;
                                        }
                                        catch (Exception er) { Console.WriteLine(er); }
                                    }
                                }
                                else
                                {
                                    tableauBrique[x, y].Changer_Brique(ItemSelectionne);
                                }
                            }
                            else
                            {
                                carte[x, y] = 0;
                                try
                                {
                                    tableauBrique[x, y].detruireConstr();
                                }
                                catch (Exception er) { Console.WriteLine(er); }
                            }
                        }
                    }
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                ItemSelectionne += 1;

                switch (ItemSelectionne)
                {
                case 0:
                    placeur.BackColor = Color.White;
                    break;

                case 1:
                    placeur.BackColor = Color.Blue;
                    break;

                case 2:
                    placeur.BackColor = Color.Red;
                    break;

                case 3:
                    placeur.BackColor = Color.Green;
                    break;

                case 4:
                    placeur.BackColor = Color.Yellow;
                    break;

                default:
                    ItemSelectionne   = 0;
                    placeur.BackColor = Color.White;
                    break;
                }
            }
        }