Exemplo n.º 1
0
        public static TipIgre NapraviTipIgre(XElement x)
        {
            TipIgre t = new TipIgre();

            t.FromXML(x);
            return(t);
        }
Exemplo n.º 2
0
 public Tetris(TipIgre _tip_igre)
 {
     tip_igre        = _tip_igre;
     trenutni_nivo   = 0;
     rezultat        = 0;
     nagradni_bodovi = 0;
     gotovaIgra      = false;
     novaPloca();
 }
Exemplo n.º 3
0
 public Tetris(TipIgre _tip_igre)
 {
     tip_igre = _tip_igre;
     trenutni_nivo = 0;
     rezultat = 0;
     nagradni_bodovi = 0;
     gotovaIgra = false;
     novaPloca();
 }
Exemplo n.º 4
0
        void pohrani()
        {
            if (prikazivanje_u_tijeku)
            {
                return;
            }

            TipIgre t = Postavke.TipoviIgara[aktivni_tipigre];

            t.Redaka  = (int)this.numericUpDown1.Value;
            t.Stupaca = (int)this.numericUpDown2.Value;
            t.Nivoi[0].NagradniKvadratici = checkBox1.Checked;
            t.Nivoi[0].Prepreke           = checkBox2.Checked;
            t.Nivoi[0].ViseLikova         = checkBox3.Checked;
            t.Nivoi[1].NagradniKvadratici = checkBox6.Checked;
            t.Nivoi[1].Prepreke           = checkBox5.Checked;
            t.Nivoi[1].ViseLikova         = checkBox4.Checked;
            t.Nivoi[2].NagradniKvadratici = checkBox9.Checked;
            t.Nivoi[2].Prepreke           = checkBox8.Checked;
            t.Nivoi[2].ViseLikova         = checkBox7.Checked;
            t.Nivoi[0].Brzina             = trackBar1.Value;
            t.Nivoi[1].Brzina             = trackBar2.Value;
            t.Nivoi[2].Brzina             = trackBar3.Value;
            t.Nivoi[0].Smjer = (Smjerovi)Enum.Parse(typeof(Smjerovi), comboBox1.SelectedItem.ToString());
            t.Nivoi[1].Smjer = (Smjerovi)Enum.Parse(typeof(Smjerovi), comboBox2.SelectedItem.ToString());
            t.Nivoi[2].Smjer = (Smjerovi)Enum.Parse(typeof(Smjerovi), comboBox3.SelectedItem.ToString());

            t.Nivoi[0].Oblici.Clear();
            t.Nivoi[1].Oblici.Clear();
            t.Nivoi[2].Oblici.Clear();
            int i = 0;

            foreach (Oblik o in Postavke.Oblici)
            {
                if (checkedListBox1.GetItemChecked(i))
                {
                    t.Nivoi[0].Oblici.Add(o);
                }
                if (checkedListBox2.GetItemChecked(i))
                {
                    t.Nivoi[1].Oblici.Add(o);
                }
                if (checkedListBox3.GetItemChecked(i))
                {
                    t.Nivoi[2].Oblici.Add(o);
                }

                ++i;
            }


            Postavke.Pohrani();
        }
Exemplo n.º 5
0
        public static void FromXML(XElement x)
        {
            foreach (var o in x.Elements("oblik"))
            {
                Oblici.Add(Oblik.NapraviOblik(o));
            }

            foreach (var o in x.Elements("igra"))
            {
                TipoviIgara.Add(TipIgre.NapraviTipIgre(o));
            }

            foreach (var o in x.Elements("rezultat"))
            {
                DodajRezultat(o.Attribute("tipigre").Value,
                              o.Attribute("igrac").Value,
                              int.Parse(o.Attribute("nivo").Value),
                              int.Parse(o.Attribute("bodovi").Value));
            }
        }
Exemplo n.º 6
0
        void prikazi()
        {
            prikazivanje_u_tijeku = true;
            panel1.Show();

            TipIgre t = Postavke.TipoviIgara[aktivni_tipigre];

            this.numericUpDown1.Value = t.Redaka;
            this.numericUpDown2.Value = t.Stupaca;
            checkBox1.Checked         = t.Nivoi[0].NagradniKvadratici;
            checkBox2.Checked         = t.Nivoi[0].Prepreke;
            checkBox3.Checked         = t.Nivoi[0].ViseLikova;
            checkBox6.Checked         = t.Nivoi[1].NagradniKvadratici;
            checkBox5.Checked         = t.Nivoi[1].Prepreke;
            checkBox4.Checked         = t.Nivoi[1].ViseLikova;
            checkBox9.Checked         = t.Nivoi[2].NagradniKvadratici;
            checkBox8.Checked         = t.Nivoi[2].Prepreke;
            checkBox7.Checked         = t.Nivoi[2].ViseLikova;
            trackBar1.Value           = t.Nivoi[0].Brzina;
            trackBar2.Value           = t.Nivoi[1].Brzina;
            trackBar3.Value           = t.Nivoi[2].Brzina;
            comboBox1.SelectedItem    = t.Nivoi[0].Smjer.ToString();
            comboBox2.SelectedItem    = t.Nivoi[1].Smjer.ToString();
            comboBox3.SelectedItem    = t.Nivoi[2].Smjer.ToString();


            checkedListBox1.Items.Clear();
            checkedListBox2.Items.Clear();
            checkedListBox3.Items.Clear();
            foreach (Oblik o in Postavke.Oblici)
            {
                checkedListBox1.Items.Add(o.Ime,
                                          t.Nivoi[0].Oblici.Count(obl => obl.Ime == o.Ime) == 1);
                checkedListBox2.Items.Add(o.Ime,
                                          t.Nivoi[1].Oblici.Count(obl => obl.Ime == o.Ime) == 1);
                checkedListBox3.Items.Add(o.Ime,
                                          t.Nivoi[2].Oblici.Count(obl => obl.Ime == o.Ime) == 1);
            }

            prikazivanje_u_tijeku = false;
        }
Exemplo n.º 7
0
        public PrikazIgre(TipIgre tig)
        {
            igra = new Tetris(tig);
            this.tig = tig;

            //ucitavanje
            img = new Bitmap(Properties.Resources.tile_mask);
            img1 = new Bitmap(Properties.Resources.tile_mask);
            img2 = new Bitmap(Properties.Resources.pattern);

            InitializeComponent();

            //velicina kockice
            int velicina = 24;
            //resize kockice s obzirom na formu max(1000px, 800px)
            while((((tig.Stupaca + 2) * velicina) +300)>1000 && (((tig.Redaka + 2) * 24) + 20)> 800){
                velicina -= 2;
            }
            //resize forme
            this.ClientSize = new Size(((tig.Stupaca + 2) * velicina) + 300, ((tig.Redaka + 2) * velicina) + 20);
            this.panel1.Width = (tig.Stupaca + 2) * velicina;
            this.panel1.Height = (tig.Redaka + 2) * velicina;

            //resize bitmapa
            img1 = (Image)new Bitmap(img1, new Size(panelSljedeciPrvi.Width / 4, panelSljedeciPrvi.Height / 4));
            img = (Image)new Bitmap(img, new Size(panel1.Width / (tig.Stupaca + 2), panel1.Height / (tig.Redaka + 2)));
            img2 = (Image)new Bitmap(img2, new Size(panel1.Width / (tig.Stupaca + 2), panel1.Height / (tig.Redaka + 2)));

            //bitmap
            bit = new Bitmap(panel1.Size.Width, panel1.Size.Height);
            Graphics g = Graphics.FromImage(bit);

            g.Clear(Color.White);

            int w = panel1.Width / (tig.Stupaca + 2);
            int h = panel1.Height / (tig.Redaka + 2);

            for (int r = 0; r < tig.Redaka + 2; ++r)
            {
                for (int s = 0; s < tig.Stupaca + 2; ++s)
                {
                    if (r == 0 || s == 0 || r == (tig.Redaka + 1) || s == (tig.Stupaca + 1))
                    {
                        g.FillRectangle(Brushes.DarkGray, new Rectangle(new Point((s * w) + 1, (r * h) + 1), new Size(w - 3, h - 3)));
                        g.DrawImage(img, new Point(s * w, r * h));
                    }
                    else
                    {
                        g.DrawImage(img2, new Point(s * w, r * h));
                    }
                }
            }
            panel1.BackgroundImage = bit;
            
            //Bitmap sljedeci
            bit_sljedeci = new Bitmap(panelSljedeciPrvi.Size.Width, panelSljedeciPrvi.Size.Height);

            //label color
            this.label1.ForeColor = System.Drawing.ColorTranslator.FromHtml("#282d34");
            this.lbl_nivo.ForeColor = System.Drawing.ColorTranslator.FromHtml("#282d34");
            this.label4.ForeColor = System.Drawing.ColorTranslator.FromHtml("#282d34");
            this.label5.ForeColor = System.Drawing.ColorTranslator.FromHtml("#282d34");
            this.lbl_brzina.ForeColor = System.Drawing.ColorTranslator.FromHtml("#282d34");

            this.SetStyle(
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.UserPaint |
                ControlStyles.DoubleBuffer,
                true);
            typeof(Panel).InvokeMember("DoubleBuffered",
                BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                null, panel1, new object[] { true });
            typeof(Panel).InvokeMember("DoubleBuffered",
                BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                null, panelSljedeciPrvi, new object[] { true });
            typeof(Panel).InvokeMember("DoubleBuffered",
                  BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                  null, panelSljedeciDrugi, new object[] { true });

            tableLayoutPanel1.BackgroundImage = null;
            tableLayoutPanel1.BackColor = Color.DarkSeaGreen;
        }
Exemplo n.º 8
0
 public static TipIgre NapraviTipIgre(XElement x)
 {
     TipIgre t = new TipIgre();
     t.FromXML(x);
     return t;
 }
Exemplo n.º 9
0
        public PrikazIgre(TipIgre tig)
        {
            igra     = new Tetris(tig);
            this.tig = tig;

            //ucitavanje
            img  = new Bitmap(Properties.Resources.tile_mask);
            img1 = new Bitmap(Properties.Resources.tile_mask);
            img2 = new Bitmap(Properties.Resources.pattern);

            InitializeComponent();

            //velicina kockice
            int velicina = 24;

            //resize kockice s obzirom na formu max(1000px, 800px)
            while ((((tig.Stupaca + 2) * velicina) + 300) > 1000 && (((tig.Redaka + 2) * 24) + 20) > 800)
            {
                velicina -= 2;
            }
            //resize forme
            this.ClientSize    = new Size(((tig.Stupaca + 2) * velicina) + 300, ((tig.Redaka + 2) * velicina) + 20);
            this.panel1.Width  = (tig.Stupaca + 2) * velicina;
            this.panel1.Height = (tig.Redaka + 2) * velicina;

            //resize bitmapa
            img1 = (Image) new Bitmap(img1, new Size(panelSljedeciPrvi.Width / 4, panelSljedeciPrvi.Height / 4));
            img  = (Image) new Bitmap(img, new Size(panel1.Width / (tig.Stupaca + 2), panel1.Height / (tig.Redaka + 2)));
            img2 = (Image) new Bitmap(img2, new Size(panel1.Width / (tig.Stupaca + 2), panel1.Height / (tig.Redaka + 2)));

            //bitmap
            bit = new Bitmap(panel1.Size.Width, panel1.Size.Height);
            Graphics g = Graphics.FromImage(bit);

            g.Clear(Color.White);

            int w = panel1.Width / (tig.Stupaca + 2);
            int h = panel1.Height / (tig.Redaka + 2);

            for (int r = 0; r < tig.Redaka + 2; ++r)
            {
                for (int s = 0; s < tig.Stupaca + 2; ++s)
                {
                    if (r == 0 || s == 0 || r == (tig.Redaka + 1) || s == (tig.Stupaca + 1))
                    {
                        g.FillRectangle(Brushes.DarkGray, new Rectangle(new Point((s * w) + 1, (r * h) + 1), new Size(w - 3, h - 3)));
                        g.DrawImage(img, new Point(s * w, r * h));
                    }
                    else
                    {
                        g.DrawImage(img2, new Point(s * w, r * h));
                    }
                }
            }
            panel1.BackgroundImage = bit;

            //Bitmap sljedeci
            bit_sljedeci = new Bitmap(panelSljedeciPrvi.Size.Width, panelSljedeciPrvi.Size.Height);

            //label color
            this.label1.ForeColor     = System.Drawing.ColorTranslator.FromHtml("#282d34");
            this.lbl_nivo.ForeColor   = System.Drawing.ColorTranslator.FromHtml("#282d34");
            this.label4.ForeColor     = System.Drawing.ColorTranslator.FromHtml("#282d34");
            this.label5.ForeColor     = System.Drawing.ColorTranslator.FromHtml("#282d34");
            this.lbl_brzina.ForeColor = System.Drawing.ColorTranslator.FromHtml("#282d34");

            this.SetStyle(
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.UserPaint |
                ControlStyles.DoubleBuffer,
                true);
            typeof(Panel).InvokeMember("DoubleBuffered",
                                       BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                       null, panel1, new object[] { true });
            typeof(Panel).InvokeMember("DoubleBuffered",
                                       BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                       null, panelSljedeciPrvi, new object[] { true });
            typeof(Panel).InvokeMember("DoubleBuffered",
                                       BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
                                       null, panelSljedeciDrugi, new object[] { true });

            tableLayoutPanel1.BackgroundImage = null;
            tableLayoutPanel1.BackColor       = Color.DarkSeaGreen;
        }