Пример #1
0
 public static void RemoveInstance()
 {
     if (instance != null)
     {
         instance = null;
     }
 }
Пример #2
0
        private void Difficulties()
        {
            int X = ((Width - 150) / 3) - 25;

            for (int i = 0; i < btnDifficulties.Length; i++)
            {
                btnDifficulties[i] = new MyButton(
                    $"btnDifficulties{i}", MyStrings.Difficulties[i],
                    MyColors.ORANGE, Color.GhostWhite,
                    new Point(X, ((Height - 50) / 2) + 175), new Size(100, 50),
                    MyColors.ORANGE, 2, 10
                    )
                {
                    Visible = false
                };

                int r = i;
                btnDifficulties[i].Click += (o, e) =>
                {
                    string userAnswer = Interaction.InputBox("Escreva um nome", "");

                    if (userAnswer != string.Empty)
                    {
                        Game.Instance().NamePlayer   = userAnswer;
                        Game.Instance().Difficulties = r;
                        FormJogoMemoria.Instance().Controls.Add(GamePanel.Instance());
                        FormJogoMemoria.Instance().Controls.Remove(this);
                        RemoveInstance();
                    }
                };

                X += 125;
                Controls.Add(btnDifficulties[i]);
            }
        }
Пример #3
0
        private void Popup(string msg, string title)
        {
            var result = MessageBox.Show(msg, title, MessageBoxButtons.YesNoCancel);

            switch (result)
            {
            case DialogResult.Yes:
                FormJogoMemoria.Instance().Controls.Remove(GamePanel.Instance());
                GamePanel.RemoveInstance();

                int    d = Difficulties;
                string n = NamePlayer;

                RemoveInstance();
                Instance().Difficulties = d;
                Instance().NamePlayer   = n;
                FormJogoMemoria.Instance().Controls.Add(GamePanel.Instance());
                break;

            case DialogResult.No:
                FormJogoMemoria.Instance().Controls.Remove(GamePanel.Instance());
                GamePanel.RemoveInstance();
                RemoveInstance();
                FormJogoMemoria.Instance().Controls.Add(MainPanel.Instance());
                break;

            case DialogResult.Cancel:
                Application.Exit();
                break;
            }
        }
Пример #4
0
        private async Task SwitchScreen()
        {
            await Task.Delay(3000);

            FormJogoMemoria.Instance().Controls.Add(MainPanel.Instance());
            FormJogoMemoria.Instance().Controls.Remove(this);
            RemoveInstance();
        }
Пример #5
0
        private StartPanel()
        {
            Size      = new Size(FormJogoMemoria.Instance().Width, FormJogoMemoria.Instance().Height);
            Anchor    = AnchorStyles.None;
            Name      = "startPanel";
            Location  = new Point(0, 0);
            BackColor = MyColors.GRAY;
            Font      = fntPixel;
            TabIndex  = 0;

            Animaton();
            _ = SwitchScreen();
        }
Пример #6
0
        /* Singleton */
        public static FormJogoMemoria Instance()
        {
            if (instance == null)
            {
                lock (typeof(FormJogoMemoria)) {
                    if (instance == null)
                    {
                        instance = new FormJogoMemoria();
                    }
                }
            }

            return(instance);
        }
Пример #7
0
        private MainPanel()
        {
            Size      = new Size(FormJogoMemoria.Instance().Width, FormJogoMemoria.Instance().Height);
            Anchor    = AnchorStyles.None;
            Name      = "mainPanel";
            Location  = new Point(0, 0);
            BackColor = MyColors.GRAY;
            Font      = fntPixel;
            TabIndex  = 0;

            Song();
            Controllers();
            PixelMemory();
            Weapons();
            Difficulties();
            Play();
            HighScore();
        }
Пример #8
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(FormJogoMemoria.Instance());
 }