Exemple #1
0
        private void drawMap(environment e)
        {
            int N_SQM = e.map.GetLength(0);

            pnl_world.Controls.Clear();

            for (int i = 0; i < N_SQM; i++)
            {
                for (int j = 0; j < N_SQM; j++)
                {
                    PictureBox p = (new PictureBox()
                    {
                        Name = "P" + i.ToString() + "|" + j.ToString(),
                        Size = new Size(SQM_SIZE, SQM_SIZE),
                        Location = new Point((j * SQM_SIZE), (i * SQM_SIZE)),
                        SizeMode = PictureBoxSizeMode.StretchImage,
                        Image = e.map[i, j].image
                    });
                    pnl_world.Controls.Add(p);

                    if (e.map[i, j].tag != "")
                    {
                        Image img = null;

                        switch (e.map[i, j].tag.Substring(0, 1))
                        {
                        case "D":
                            img = Zelda.Properties.Resources.dg;
                            break;

                        case "L":
                            img = Zelda.Properties.Resources.dg;
                            break;

                        case "M":
                            img = Zelda.Properties.Resources.ms;
                            break;
                        }

                        if (img != null)
                        {
                            PictureBox p1 = (new PictureBox
                            {
                                Parent = p,
                                Name = "P" + i.ToString() + "|" + j.ToString() + "Object",
                                Size = new Size(SQM_SIZE, SQM_SIZE),
                                BackColor = Color.Transparent,
                                SizeMode = PictureBoxSizeMode.StretchImage,
                                Image = img
                            });

                            p.Controls.Add(p1);
                            p1.BringToFront();
                        }
                    }
                }
            }

            putLinkMap(this.link);
        }
Exemple #2
0
        private void redrawMap(link link)
        {
            environment e = link.environment;

            int N_SQM = e.map.GetLength(0);

            for (int i = 0; i < 42; i++)
            {
                for (int j = 0; j < 42; j++)
                {
                    PictureBox p = (PictureBox)pnl_world.Controls["P" + i.ToString() + "|" + j.ToString()];
                    p.Controls.Clear();

                    if (i >= N_SQM || j >= N_SQM)
                    {
                        p.Image = null;
                        continue;
                    }

                    p.Image = e.map[i, j].image;

                    if (e.map[i, j].tag != "")
                    {
                        Image img = null;

                        switch (e.map[i, j].tag)
                        {
                        case "D":
                        case "D1":
                        case "D2":
                        case "D3":
                            img = Zelda.Properties.Resources.dg;
                            break;

                        case "PP":
                            img = Zelda.Properties.Resources.pendant_of_power;
                            break;

                        case "PC":
                            img = Zelda.Properties.Resources.pendant_of_courage;
                            break;

                        case "PW":
                            img = Zelda.Properties.Resources.pendant_of_wisdom;
                            break;

                        case "LW":
                            img = Zelda.Properties.Resources.lw;
                            break;

                        case "MS":
                            img = Zelda.Properties.Resources.ms;
                            break;
                        }

                        if (img != null)
                        {
                            PictureBox p1 = (new PictureBox
                            {
                                Parent = p,
                                Name = "P" + i.ToString() + "|" + j.ToString() + "Object",
                                Size = new Size(SQM_SIZE, SQM_SIZE),
                                BackColor = Color.Transparent,
                                SizeMode = PictureBoxSizeMode.StretchImage,
                                Image = img
                            });

                            p.Controls.Add(p1);
                            p1.BringToFront();
                        }
                    }
                }
            }

            putLinkMap(link);
            Application.DoEvents();
        }