Пример #1
0
        private void borrarToolStripButton_Click(object sender, EventArgs e)
        {
            object seleccionado = this.currentLevelProp.SelectedObject;

            Moneda moneda = seleccionado as Moneda;

            if (moneda != null)
            {
                this.currentLevel.Monedas.Remove(moneda);
            }

            Enemigo enemigo = seleccionado as Enemigo;

            if (enemigo != null)
            {
                this.currentLevel.Enemigos.Remove(enemigo);
            }

            Plataforma plataforma = seleccionado as Plataforma;

            if (plataforma != null)
            {
                this.currentLevel.Plataformas.Remove(plataforma);
            }

            this.currentLevelProp.SelectedObject = null;
            updateView();
        }
Пример #2
0
        private bool updatePlataforma(byte tileX, byte tileY, bool actualizar)
        {
            Plataforma plataforma = seleccionado as Plataforma;

            if (plataforma != null)
            {
                if (plataforma.Direccion == Direccion.Horizontal)
                {
                    if (plataforma.Y != tileY)
                    {
                        plataforma.Y = tileY;
                        actualizar   = true;
                    }
                }
                else
                {
                    if (plataforma.X != tileX)
                    {
                        plataforma.X = tileX;
                        actualizar   = true;
                    }
                }
            }
            return(actualizar);
        }
Пример #3
0
        public int CompareTo(object obj)
        {
            Plataforma objAComparar = obj as Plataforma;

            if (objAComparar == null)
            {
                throw new ArgumentException(string.Format("No se puede comparar con un objeto de tipo {0}", obj.GetType().FullName));
            }
            if (this.y < objAComparar.y ||
                (this.y == objAComparar.y && this.x < objAComparar.x))
            {
                return(-1);
            }
            if (this.y == objAComparar.y && this.x == objAComparar.x)
            {
                return(0);
            }
            return(1);
        }
Пример #4
0
        private void currentLevelView_MouseDown(object sender, MouseEventArgs e)
        {
            byte tileX = (byte)(e.X / 32);
            byte tileY = (byte)(e.Y / 32);

            switch (this.currentStatus)
            {
            case AppState.AddingPlatform:
                this.isDrawing = true;

                plataformaActual = new Plataforma();
                plataformaActual.TipoPlataforma = tipoPlataforma;
                plataformaActual.X         = tileX;
                plataformaActual.Y         = tileY;
                plataformaActual.Longitud  = 1;
                plataformaActual.Direccion = Direccion.Horizontal;

                this.currentLevel.Plataformas.Add(plataformaActual);

                tileXIni = tileX;
                tileYIni = tileY;

                updateView();
                break;

            case AppState.Normal:
                this.seleccionado = getObjectAt(tileX, tileY);
                this.currentLevelProp.SelectedObject = this.seleccionado;

                tileXIni = tileX;
                tileYIni = tileY;
                break;

            default:
                this.isDrawing = false;
                break;
            }
        }
Пример #5
0
        internal string ToString(Version version)
        {
            StringBuilder result = new StringBuilder();
            int           i      = 0;

            // Descriptor.
            result.AppendFormat(";.Pantalla {0}\n", this.numPantalla);

            if (version.CPU == CPUVersion.MSX)
            {
                result.AppendFormat("   {0} {1} ; FONDO\n", version.TokenDef, (byte)this.tileFondo);
            }
            else
            {
                result.Append("        ;TTPPPIII\n");
                result.AppendFormat("   {3} {4}{0}{1}{2}{5}            ; Descriptor\n",
                                    Utils.ToBinary2((byte)this.tileFondo),
                                    Utils.ToBinary3((byte)this.paperColor),
                                    Utils.ToBinary3((byte)this.inkColor),
                                    version.TokenDef,
                                    version.PrefijoDatoBin,
                                    version.EndOfByte);
            }

            // Plataformas.
            result.Append("\n        ;Objetos\n");
            result.Append("        ;datos \"al reves\", por eso del \"endian\"\n");
            result.Append("        ;LLLLTTTD   XXXXYYYY\n");
            for (i = 0; i < this.plataformas.Count; i++)
            {
                result.AppendFormat("   {0}\n", this.plataformas[i].ToString(version));
            }
            if (version.CPU != CPUVersion.MSX)
            {
                Plataforma plataformaVacia = new Plataforma();

                for (; i < version.MaxPlataformas; i++)
                {
                    result.AppendFormat("   {0}\n", plataformaVacia.ToString(version));
                }
            }

            result.AppendLine(version.EndOfSection);

            // Moviles.
            result.Append("\n        ;Moviles\n");
            result.Append("        ;YYYYTTTD   AAAABBBB\n");
            for (i = 0; i < this.enemigos.Count; i++)
            {
                result.AppendFormat("   {0}\n", this.enemigos[i].ToString(version));
            }
            if (version.CPU != CPUVersion.MSX)
            {
                Enemigo enemigoVacio = new Enemigo();

                for (; i < version.MaxEnemigos; i++)
                {
                    result.AppendFormat("   {0}\n", enemigoVacio.ToString(version));
                }
            }
            result.AppendLine(version.EndOfSection);

            // Monedas.
            result.Append("\n        ;Monedas\n");
            result.Append("        ;XXXXYYYY\n");
            for (i = 0; i < this.monedas.Count; i++)
            {
                result.AppendFormat("   {0}\n", this.monedas[i].ToString(version));
            }
            if (version.CPU != CPUVersion.MSX)
            {
                Moneda monedaVacia = new Moneda();

                for (; i < version.MaxMonedas; i++)
                {
                    result.AppendFormat("   {0}\n", monedaVacia.ToString(version));
                }
            }
            result.AppendLine(version.EndOfSection);

            return(result.ToString());
        }
Пример #6
0
        internal string ToString(Version version)
        {
            StringBuilder result = new StringBuilder();
            int i = 0;

            // Descriptor.
            result.AppendFormat(";.Pantalla {0}\n", this.numPantalla);

            if (version.CPU == CPUVersion.MSX)
            {
                result.AppendFormat("   {0} {1} ; FONDO\n", version.TokenDef, (byte)this.tileFondo);
            }
            else
            {
                result.Append("        ;TTPPPIII\n");
                result.AppendFormat("   {3} {4}{0}{1}{2}{5}            ; Descriptor\n",
                   Utils.ToBinary2((byte)this.tileFondo),
                   Utils.ToBinary3((byte)this.paperColor),
                   Utils.ToBinary3((byte)this.inkColor),
                   version.TokenDef,
                   version.PrefijoDatoBin,
                   version.EndOfByte);
            }

            // Plataformas.
            result.Append("\n        ;Objetos\n");
            result.Append("        ;datos \"al reves\", por eso del \"endian\"\n");
            result.Append("        ;LLLLTTTD   XXXXYYYY\n");
            for (i = 0; i < this.plataformas.Count; i++)
            {
                result.AppendFormat("   {0}\n", this.plataformas[i].ToString(version));
            }
            if (version.CPU != CPUVersion.MSX)
            {
                Plataforma plataformaVacia = new Plataforma();

                for (; i < version.MaxPlataformas; i++)
                {
                    result.AppendFormat("   {0}\n", plataformaVacia.ToString(version));
                }
            }

            result.AppendLine(version.EndOfSection);

            // Moviles.
            result.Append("\n        ;Moviles\n");
            result.Append("        ;YYYYTTTD   AAAABBBB\n");
            for (i = 0; i < this.enemigos.Count; i++)
            {
                result.AppendFormat("   {0}\n", this.enemigos[i].ToString(version));
            }
            if (version.CPU != CPUVersion.MSX)
            {
                Enemigo enemigoVacio = new Enemigo();

                for (; i < version.MaxEnemigos; i++)
                {
                    result.AppendFormat("   {0}\n", enemigoVacio.ToString(version));
                }
            }
            result.AppendLine(version.EndOfSection);

            // Monedas.
            result.Append("\n        ;Monedas\n");
            result.Append("        ;XXXXYYYY\n");
            for (i = 0; i < this.monedas.Count; i++)
            {
                result.AppendFormat("   {0}\n", this.monedas[i].ToString(version));
            }
            if (version.CPU != CPUVersion.MSX)
            {
                Moneda monedaVacia = new Moneda();

                for (; i < version.MaxMonedas; i++)
                {
                    result.AppendFormat("   {0}\n", monedaVacia.ToString(version));
                }
            }
            result.AppendLine(version.EndOfSection);

            return result.ToString();
        }
Пример #7
0
        private void currentLevelView_MouseDown(object sender, MouseEventArgs e)
        {
            byte tileX = (byte)(e.X / 32);
            byte tileY = (byte)(e.Y / 32);

            switch (this.currentStatus)
            {
                case AppState.AddingPlatform:
                    this.isDrawing = true;

                    plataformaActual = new Plataforma();
                    plataformaActual.TipoPlataforma = tipoPlataforma;
                    plataformaActual.X = tileX;
                    plataformaActual.Y = tileY;
                    plataformaActual.Longitud = 1;
                    plataformaActual.Direccion = Direccion.Horizontal;

                    this.currentLevel.Plataformas.Add(plataformaActual);

                    tileXIni = tileX;
                    tileYIni = tileY;

                    updateView();
                    break;
                case AppState.Normal:
                    this.seleccionado = getObjectAt(tileX, tileY);
                    this.currentLevelProp.SelectedObject = this.seleccionado;

                    tileXIni = tileX;
                    tileYIni = tileY;
                    break;
                default:
                    this.isDrawing = false;
                    break;
            }
        }