Пример #1
0
        public void pintarPuertaSalida()
        {
            int salida = rnd.Next(0, 99);

            Casilla puerta = listCasillas[salida];

            puerta.BackgroundImage       = Properties.Resources.gate;
            puerta.BackgroundImageLayout = ImageLayout.Zoom;
            puerta.Tag = "puerta";
        }
Пример #2
0
        private void GenerateMap()
        {
            int casilla_spawn = rnd.Next(0, 99);
            int j             = 0;

            for (int i = 0; i < 100; i++)
            {
                Casilla csl = new Casilla(i);
                if (i == casilla_spawn)
                {
                    csl.Image                 = j_img;
                    csl.BackgroundImage       = Properties.Resources.movimiento2;
                    csl.BackgroundImageLayout = ImageLayout.Stretch;
                }

                this.Controls.Add(csl);
                this.Controls.Add(label);
            }
        }
Пример #3
0
        void Pelea(Casilla csl)
        {
            this.Enabled = false;
            int r = rnd.Next(1, 100);

            if (r <= 20)
            {
                Combate cmbt = new Combate(ref player, csl);

                //EstadisticasCombate cmbt = new EstadisticasCombate(ref player);
                this.AddOwnedForm(cmbt);
                if (this.OwnedForms != null)
                {
                    cmbt.Show();
                    cantCombates++;
                    if (cantCombates == 5)
                    {
                        pintarPuertaSalida();
                    }
                }
            }
        }
Пример #4
0
        private void Mapa_KeyUp(object sender, KeyEventArgs e)
        {
            Casilla csl_j = new Casilla();

            foreach (Control csl in Controls)
            {
                if (typeof(Casilla) == csl.GetType() && ((Casilla)csl).Image == j_img)
                {
                    csl_j = (Casilla)csl;// Con esto sabemos en que control esta el personaje
                }
            }
            if (e.KeyCode == Keys.Left && csl_j.Location.X != 0)
            {
                foreach (Control csl in Controls)
                {
                    if (csl.Location.X == csl_j.Location.X - anchobtn &&
                        csl.Location.Y == csl_j.Location.Y)
                    {
                        ((Casilla)csl).Image      = csl_j.Image;
                        csl.BackgroundImage       = csl_j.BackgroundImage;
                        csl_j.Image               = null;
                        csl.BackgroundImageLayout = ImageLayout.Stretch;
                    }
                }
                Pelea();
            }
            else if (e.KeyCode == Keys.Right && csl_j.Location.X < anchobtn * 9)
            {
                foreach (Control csl in Controls)
                {
                    if (csl.Location.X == csl_j.Location.X + anchobtn &&
                        csl.Location.Y == csl_j.Location.Y)
                    {
                        ((Casilla)csl).Image      = csl_j.Image;
                        csl.BackgroundImage       = csl_j.BackgroundImage;
                        csl_j.Image               = null;
                        csl.BackgroundImageLayout = ImageLayout.Stretch;
                    }
                }
                Pelea();
            }
            else if (e.KeyCode == Keys.Up && csl_j.Location.Y != 0)
            {
                foreach (Control csl in Controls)
                {
                    if (csl.Location.X == csl_j.Location.X &&
                        csl.Location.Y == csl_j.Location.Y - altobtn)
                    {
                        ((Casilla)csl).Image      = csl_j.Image;
                        csl.BackgroundImage       = csl_j.BackgroundImage;
                        csl_j.Image               = null;
                        csl.BackgroundImageLayout = ImageLayout.Stretch;
                    }
                }
                Pelea();
            }
            else if (e.KeyCode == Keys.Down && csl_j.Location.Y < altobtn * 9)
            {
                foreach (Control csl in Controls)
                {
                    if (csl.Location.X == csl_j.Location.X &&
                        csl.Location.Y == csl_j.Location.Y + altobtn)
                    {
                        ((Casilla)csl).Image      = csl_j.Image;
                        csl.BackgroundImage       = csl_j.BackgroundImage;
                        csl_j.Image               = null;
                        csl.BackgroundImageLayout = ImageLayout.Stretch;
                    }
                }
                Pelea();
            }
        }
Пример #5
0
        private void Mapa_KeyUp(object sender, KeyEventArgs e)
        {
            foreach (Control csl in Controls)
            {
                Casilla st = null;

                if (typeof(Casilla) == csl.GetType() && player.Img_Mapa.Contains(((Casilla)csl).Image))
                {
                    csl_j = (Casilla)csl;// Con esto sabemos en que control esta el personaje
                }


                if (typeof(Casilla) == csl.GetType())
                {
                    st = (Casilla)csl;
                }



                if (st != null && st.Tag != null && st.Tag.Equals("puerta"))
                {
                    if (st.Location.X == csl_j.Location.X - anchobtn &&
                        st.Location.Y == csl_j.Location.Y)
                    {
                        entroPuerta();
                        //MessageBox.Show("puerta salida");
                    }
                }
            }
            if (e.KeyCode == Keys.Left && csl_j.Location.X != 0)
            {
                foreach (Control csl in Controls)
                {
                    if (csl.Location.X == csl_j.Location.X - anchobtn &&
                        csl.Location.Y == csl_j.Location.Y)
                    {
                        if (((Casilla)csl).Tag != null && ((Casilla)csl).Tag.Equals("puerta"))
                        {
                            entroPuerta();
                            //MessageBox.Show("puerta salida");
                            // Application.Exit();
                        }
                        else
                        {
                            ((Casilla)csl).Image = player.Img_Mapa.ElementAt(2);
                            //csl.BackgroundImage = csl_j.BackgroundImage;
                            if (csl_j.BackgroundImage == null)
                            {
                                csl_j.Image = Properties.Resources.huelasLeft;
                            }
                            else
                            {
                                csl_j.Image = null;
                            }

                            //csl.BackgroundImageLayout = ImageLayout.Stretch;
                            Pelea((Casilla)csl);
                        }
                    }
                }
            }
            else if (e.KeyCode == Keys.Right && csl_j.Location.X < anchobtn * 9)
            {
                foreach (Control csl in Controls)
                {
                    if (csl.Location.X == csl_j.Location.X + anchobtn &&
                        csl.Location.Y == csl_j.Location.Y)
                    {
                        if (((Casilla)csl).Tag != null && ((Casilla)csl).Tag.Equals("puerta"))
                        {
                            entroPuerta();
                        }
                        else
                        {
                            ((Casilla)csl).Image = player.Img_Mapa.ElementAt(1);

                            if (csl_j.BackgroundImage == null)
                            {
                                csl_j.Image = Properties.Resources.huelasRigth;
                            }
                            else
                            {
                                csl_j.Image = null;
                            }

                            Pelea((Casilla)csl);
                        }
                    }
                }
            }
            else if (e.KeyCode == Keys.Up && csl_j.Location.Y != 0)
            {
                foreach (Control csl in Controls)
                {
                    if (csl.Location.X == csl_j.Location.X &&
                        csl.Location.Y == csl_j.Location.Y - altobtn)
                    {
                        if (((Casilla)csl).Tag != null && ((Casilla)csl).Tag.Equals("puerta"))
                        {
                            entroPuerta();
                        }
                        else
                        {
                            ((Casilla)csl).Image = player.Img_Mapa.ElementAt(3);

                            if (csl_j.BackgroundImage == null)
                            {
                                csl_j.Image = Properties.Resources.huelasUp;
                            }
                            else
                            {
                                csl_j.Image = null;
                            }
                            Pelea((Casilla)csl);
                        }
                    }
                }
            }
            else if (e.KeyCode == Keys.Down && csl_j.Location.Y < altobtn * 9)
            {
                foreach (Control csl in Controls)
                {
                    if (csl.Location.X == csl_j.Location.X &&
                        csl.Location.Y == csl_j.Location.Y + altobtn)
                    {
                        if (((Casilla)csl).Tag != null && ((Casilla)csl).Tag.Equals("puerta"))
                        {
                            //MessageBox.Show("puerta salida");
                            //Application.Exit();
                            entroPuerta();
                        }
                        else
                        {
                            ((Casilla)csl).Image = player.Img_Mapa.ElementAt(0);
                            //csl.BackgroundImage = csl_j.BackgroundImage;
                            if (csl_j.BackgroundImage == null)
                            {
                                csl_j.Image = Properties.Resources.huelasDown;
                            }
                            else
                            {
                                csl_j.Image = null;
                            }

                            //csl.BackgroundImageLayout = ImageLayout.Stretch;
                            Pelea((Casilla)csl);
                        }
                    }
                }
                //Pelea();
            }
        }