예제 #1
0
        public bool ChangeInsertingTile(string TileType, string SpecType, string Prop1, string Prop2, string Prop3, string Prop4, uint Prop5, uint Prop6, uint SProp1, uint SProp2)
        {
            if (isLoaded && Mode == EditorMode.InsertMode)
            {
                #region Caso in cui la tile da inserire sia null o sia di tipo diverso da quello ora selezionato
                if (TileToBeAdded == null || TileToBeAdded.TileType.ToString() != TileType)
                {
                    isReadyToInsert = false;
                    switch (TileType)
                    {
                    case ("Block"):
                    {
                        TileToBeAdded = new KulaLevel.Block();
                        break;
                    }

                    case ("Placeable"):
                    {
                        TileToBeAdded = new KulaLevel.Placeable();
                        break;
                    }

                    case ("Enemy"):
                    {
                        TileToBeAdded = new KulaLevel.Enemy();
                        break;
                    }

                    default:
                    {
                        TileToBeAdded = null;
                        break;
                    }
                    }
                    return(true);
                }
                #endregion
                #region Caso in cui la tile da inserire sia già del tipo selezionato.
                else
                {
                    KulaLevel.MapTile t = TileToBeAdded;
                    TreatSwitch(t, SpecType, Prop1, Prop2, Prop3, Prop4, Prop5, Prop6, SProp1, SProp2);
                    isReadyToInsert = true;
                }
                #endregion
                OnChangedTileProperties(new ChangedTilePropertiesEventArgs(this));
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
 private bool TreatBlock(KulaLevel.Block b, string UpperSurf, string LowerSurf, string LeftSurf, string RightSurf, uint IntPeriod, uint IntBegin, uint SpikePeriod, uint SpikeBegin)
 {
     //NB UpLowLeftRight
     b.GetSurfaceAtFace(KulaLevel.Orientation.Up).Type    = TileConverter.StringToSurfaceType(UpperSurf);
     b.GetSurfaceAtFace(KulaLevel.Orientation.Down).Type  = TileConverter.StringToSurfaceType(LowerSurf);
     b.GetSurfaceAtFace(KulaLevel.Orientation.Left).Type  = TileConverter.StringToSurfaceType(LeftSurf);
     b.GetSurfaceAtFace(KulaLevel.Orientation.Right).Type = TileConverter.StringToSurfaceType(RightSurf);
     b.DisappearPeriod = IntPeriod;
     b.DisappearBegin  = IntBegin;
     b.GetSurfaceAtFace(ChosenFaceDirection).SpikesBegin  = SpikeBegin;
     b.GetSurfaceAtFace(ChosenFaceDirection).SpikesPeriod = SpikePeriod;
     return(true);
 }
예제 #3
0
 private void SetupSurfaceInterface(KulaLevel.Block b)
 {
     isReadyToListen = false;
     KulaLevel.Surface surf    = b.GetSurfaceAtFace(editLvlEditor.ChosenFaceDirection);
     KulaLevel.Surface nxtTele = surf.NextTeleport;
     changeNumericValues(numSpecificProp1, 2000, 6000, 100, (int)surf.SpikesPeriod);
     changeNumericValues(numSpecificProp2, 2000, 6000, 100, (int)surf.SpikesBegin);
     if (surf.Type.ToString() != "TimedSpikes")
     {
         numSpecificProp1.Enabled = false;
         numSpecificProp2.Enabled = false;
         lblSpecificProp1.Enabled = false;
         lblSpecificProp2.Enabled = false;
     }
     if (nxtTele != null)
     {
         txtSpecificProp7.Text =
             (
                 "Block @(X: " +
                 nxtTele.BindingBlock.X +
                 ", Y: " +
                 nxtTele.BindingBlock.Y +
                 ") Face: " +
                 TileConverter.Reverse(nxtTele.Orientation)
             );
     }
     else
     {
         txtSpecificProp7.Text = "";
     }
     if (surf.Type.ToString() != "Teleport")
     {
         btnSpecificProp7.Enabled = false;
         txtSpecificProp7.Enabled = false;
     }
     isReadyToListen = true;
 }
예제 #4
0
        private void ActivateGoodControls(KulaLevel.MapTile mt, bool isSelectionMode)
        {
            TopSplitter.Panel1.Enabled    = true;
            lblTileTyping.Enabled         = true;
            BottomSplitter.Panel2.Enabled = true;
            btnApplyChanges.Enabled       = true;
            if (!isSelectionMode)
            {
                cboTileType.Enabled = true;
                lblTileType.Enabled = true;
            }
            if (mt != null)
            {
                string s;
                #region Imposto i controlli del pannello superiore.
                lblSpecificType.Enabled = true;
                if (!isSelectionMode)
                {
                    cboTileType.Enabled = true;
                    lblTileType.Enabled = true;
                }

                if (cboTileType.Items.Contains(s = mt.TileType.ToString()))
                {
                    cboTileType.SelectedIndex = cboTileType.Items.IndexOf(s);
                }
                else
                {
                    cboTileType.SelectedIndex = 0;
                }

                cboSpecificType.Enabled = true;
                cboSpecificType.Items.Clear();
                cboSpecificType.Items.AddRange(TileConverter.GetSpecificTypesOf(mt.TileType));
                if (cboSpecificType.Items.Contains(s = TileConverter.FromByteSpecificType(mt.TileType, mt.Type)))
                {
                    cboSpecificType.SelectedIndex = cboSpecificType.Items.IndexOf(s);
                }
                else
                {
                    cboSpecificType.SelectedIndex = 0;
                }
                #endregion

                #region Imposto i controlli del pannello in mezzo e inferiore.
                BottomSplitter.Panel1.Enabled = true;
                lblTileProperties.Enabled     = true;
                BottomSplitter.Panel2.Enabled = true;
                btnApplyChanges.Enabled       = true;
                #region Caso di blocco
                if (mt.TileType == KulaLevel.TileType.Block)
                {
                    KulaLevel.Block b = (KulaLevel.Block)mt;
                    #region Abilito i controlli del pannello intermedio
                    EnablingTheseControls(true, BottomSplitter.Panel1.Controls);
                    #endregion
                    #region Sistemo i radiobuttons.
                    isManipulatingOptions = true;
                    foreach (RadioButton o in options)
                    {
                        o.Checked = false;
                    }
                    if (editLvlEditor.ChosenFaceDirection == KulaLevel.Orientation.Up)
                    {
                        options[0].Checked = true;
                    }
                    else if (editLvlEditor.ChosenFaceDirection == KulaLevel.Orientation.Down)
                    {
                        options[1].Checked = true;
                    }
                    else if (editLvlEditor.ChosenFaceDirection == KulaLevel.Orientation.Left)
                    {
                        options[2].Checked = true;
                    }
                    else if (editLvlEditor.ChosenFaceDirection == KulaLevel.Orientation.Right)
                    {
                        options[3].Checked = true;
                    }
                    isManipulatingOptions = false;
                    #endregion
                    #region Sistemo i combobox e la label principale.
                    lblSpecificProperties.Text = "Block Properties";
                    lblProperty1.Text          = "Upper Surface:";
                    lblProperty2.Text          = "Lower Surface:";
                    lblProperty3.Text          = "Left Surface:";
                    lblProperty4.Text          = "Right Surface:";
                    for (int i = 0; i < 4; i++)
                    {
                        ComboBox c = (ComboBox)midControls[i];
                        c.Items.Clear();
                        foreach (KulaLevel.SurfaceType t in TileConverter.surfaces)
                        {
                            c.Items.Add(t.ToString());
                        }
                        if (c.Items.Contains(s = b.GetSurfaceAtFace(a[i]).Type.ToString()))
                        {
                            c.SelectedIndex = c.Items.IndexOf(s);
                        }
                        else
                        {
                            c.SelectedIndex = 0;
                        }
                    }
                    #endregion
                    #region Sistemo i numericupdown
                    changeNumericValues(numProperty5, 2000, 6000, 100, (int)b.DisappearPeriod);
                    changeNumericValues(numProperty6, 0, 2000, 100, (int)b.DisappearBegin);
                    #endregion
                    #region Abilito i controlli del pannello inferiore
                    BottomSplitter.Panel2.Enabled = true;
                    btnSpecificProp7.Enabled      = true;
                    btnSpecificProp7.Text         = "Bind Teleport";
                    txtSpecificProp7.Enabled      = true;
                    lblSpecificProp1.Enabled      = true;
                    lblSpecificProp1.Text         = "Spikes Period:";
                    lblSpecificProp2.Enabled      = true;
                    lblSpecificProp2.Text         = "Spikes Begin:";
                    numSpecificProp1.Enabled      = true;
                    numSpecificProp2.Enabled      = true;
                    #endregion
                    #region Sistemo le proprietà per la superficie scelta
                    SetupSurfaceInterface(b);
                    #endregion
                }
                #endregion
                #region Caso di oggetto posizionabile
                else if (mt.TileType == KulaLevel.TileType.Placeable)
                {
                    KulaLevel.Placeable p = (KulaLevel.Placeable)mt;
                    #region Abilito i controlli del pannello intermedio
                    lblProperty1.Enabled = true;
                    cboProperty1.Enabled = true;
                    #endregion
                    #region Sistemo i testi delle label e della combobox
                    lblTileProperties.Text = "Placeable Properties";
                    lblProperty1.Text      = "Orientation";
                    #endregion
                    #region Sistemo la/le combobox
                    if (TileConverter.FromByteSpecificType(p.TileType, p.Type) == "Gravity Changer")
                    {
                        cboProperty2.Items.Clear();
                        foreach (KulaLevel.Orientation o in a)
                        {
                            cboProperty2.Items.Add(o.ToString());
                        }
                        cboProperty2.SelectedIndex = cboProperty2.Items.IndexOf(p.GChangerDirection.ToString());
                        cboProperty2.Enabled       = true;
                        lblProperty2.Enabled       = true;
                        lblProperty2.Text          = "G.Changer Direction: ";
                    }
                    cboProperty1.Enabled = true;
                    cboProperty1.Items.Clear();
                    foreach (KulaLevel.Orientation o in a)
                    {
                        cboProperty1.Items.Add(o.ToString());
                    }
                    cboProperty1.SelectedIndex = cboProperty1.Items.IndexOf(p.Orientation.ToString());
                    #endregion
                }
                #endregion
                #region Caso di nemico
                else if (mt.TileType == KulaLevel.TileType.Enemy)
                {
                    KulaLevel.Enemy e = (KulaLevel.Enemy)mt;
                    #region Abilito i controlli del pannello intermedio
                    lblProperty1.Enabled = true;
                    cboProperty1.Enabled = true;
                    #endregion
                    #region Sistemo i testi delle label e della combobox
                    lblTileProperties.Text = "Enemy Properties";
                    lblProperty1.Text      = "Orientation";
                    #endregion
                    #region Mi occupo della combobox intermedia.
                    cboProperty1.Enabled = true;
                    cboProperty1.Items.Clear();
                    foreach (KulaLevel.Orientation o in a)
                    {
                        cboProperty1.Items.Add(o.ToString());
                    }
                    cboProperty1.SelectedIndex = cboProperty1.Items.IndexOf(e.Orientation.ToString());
                    #endregion
                    #region Mi occupo dell'interfaccia inferiore, se il nemico è un sinusoidale
                    if (e.Type == 0)
                    {
                        numSpecificProp2.Enabled = true;
                        numSpecificProp1.Enabled = true;
                        lblSpecificProp1.Enabled = true;
                        lblSpecificProp2.Enabled = true;
                        lblSpecificProp1.Text    = "Enemy period:";
                        lblSpecificProp2.Text    = "Enemy range:";
                        changeNumericValues(numSpecificProp1, 2000, 6000, 100, (int)e.Period);
                        changeNumericValues(numSpecificProp2, 0, 100, 1, (int)e.Range);
                    }
                    #endregion
                }
                #endregion
                #endregion
            }
        }
예제 #5
0
        private void PaintPieces(PaintEventArgs e)
        {
            Graphics   g = e.Graphics;
            SolidBrush m = new SolidBrush(Color.FromArgb(255, 180, 0, 0));
            Pen        p = new Pen(Color.FromArgb(255, 0, 0, 0), lineWidth);

            foreach (KulaLevel.MapTile t in lvlGrid.Values.ToList <KulaLevel.MapTile>())
            {
                m.Color = EditorUtils.AssociateToTile(t.TileType.ToString(), TileConverter.FromByteSpecificType(t.TileType, t.Type));
                int w = cellSize;
                int h = cellSize;
                int x = lineWidth + t.X * (lineWidth + cellSize);
                int y = lineWidth + t.Y * (lineWidth + cellSize);
                g.FillRectangle(m, new Rectangle(x, y, w, h));

                #region Nel caso in cui il tile sia un blocco: disegno le superfici.
                if (t.TileType == KulaLevel.TileType.Block)
                {
                    int               lw = w + lineWidth;
                    int               lh = h + lineWidth;
                    int               lx = x - lineWidth / 2;
                    int               ly = y - lineWidth / 2;
                    KulaLevel.Block   b  = (KulaLevel.Block)t;
                    KulaLevel.Surface s;
                    s       = b.GetSurfaceAtFace(KulaLevel.Orientation.Down);
                    p.Color = EditorUtils.AssociateToSurface(s.Type);
                    g.DrawLine(p, new Point(lx, ly + lh), new Point(lx + lw, ly + lh));

                    s       = b.GetSurfaceAtFace(KulaLevel.Orientation.Up);
                    p.Color = EditorUtils.AssociateToSurface(s.Type);
                    g.DrawLine(p, new Point(lx, ly), new Point(lx + lw, ly));

                    s       = b.GetSurfaceAtFace(KulaLevel.Orientation.Left);
                    p.Color = EditorUtils.AssociateToSurface(s.Type);
                    g.DrawLine(p, new Point(lx, ly), new Point(lx, ly + lh));

                    s       = b.GetSurfaceAtFace(KulaLevel.Orientation.Right);
                    p.Color = EditorUtils.AssociateToSurface(s.Type);
                    g.DrawLine(p, new Point(lx + lw, ly), new Point(lx + lw, ly + lh));
                }
                #endregion
                #region Caso in cui gli oggetti non siano blocchi, ne evidenzio la direzione.
                else
                {
                    #region Sistemo la freccia che mi indica la direzione.
                    float unit = ((float)cellSize) / 4.0f;
                    float lw   = (float)lineWidth;

                    float startX = t.X * (lw + 4.0f * unit);
                    float startY = t.Y * (lw + 4.0f * unit);

                    PointF[] pts =
                    {
                        new PointF(startX + lw + unit,        startY + lw + unit * 2.0f),
                        new PointF(startX + lw + 3.0f * unit, startY + lw + unit * 2.0f),
                        new PointF(startX + lw + 2.0f * unit, startY + lw + unit * 4.0f),
                        new PointF(startX + lw + 2.0f * unit, startY + lw + unit * 2.0f),
                    };

                    Matrix trans = new Matrix();
                    if (t.Orientation == KulaLevel.Orientation.Up)
                    {
                        trans.RotateAt(180.0f, pts[3], MatrixOrder.Append);
                    }
                    else if (t.Orientation == KulaLevel.Orientation.Left)
                    {
                        trans.RotateAt(90.0f, pts[3], MatrixOrder.Append);
                    }
                    else if (t.Orientation == KulaLevel.Orientation.Right)
                    {
                        trans.RotateAt(-90.0f, pts[3], MatrixOrder.Append);
                    }
                    trans.TransformPoints(pts);

                    GraphicsPath gp = new GraphicsPath();
                    gp.AddLine(pts[0], pts[1]);
                    gp.AddLine(pts[1], pts[2]);
                    gp.AddLine(pts[2], pts[0]);
                    gp.CloseAllFigures();

                    g.FillPath(Brushes.White, gp);
                    g.DrawPath(Pens.DarkRed, gp);
                    gp.Dispose();
                    trans.Dispose();
                    #endregion
                }
                #endregion
            }
            m.Dispose();
            p.Dispose();
        }