private bool TreatSwitch(KulaLevel.MapTile t, string SpecType, string Prop1, string Prop2, string Prop3, string Prop4, uint Prop5, uint Prop6, uint SProp1, uint SProp2) { if (t == null) { return(false); } t.Type = TileConverter.FromStringSpecificType(t.TileType, SpecType); switch (t.TileType) { case (KulaLevel.TileType.Block): { return(TreatBlock((KulaLevel.Block)t, Prop1, Prop2, Prop3, Prop4, Prop5, Prop6, SProp1, SProp2)); } case (KulaLevel.TileType.Placeable): { return(TreatPlaceable((KulaLevel.Placeable)t, Prop1, Prop2)); } case (KulaLevel.TileType.Enemy): { return(TreatEnemy((KulaLevel.Enemy)t, Prop1, SProp1, SProp2)); } default: return(false); } }
public ChangedTilePropertiesEventArgs(Editor ed) { if (ed == null) { return; } if (ed.Mode == EditorMode.SelectMode) { KulaLevel.MapTile t = ed.PointedTile; if (t != null) { curTileType = t.TileType; curSpecificTileType = TileConverter.FromByteSpecificType(curTileType, t.Type); curMode = ed.Mode; curSurface = ed.ChosenFaceDirection; } } else if (ed.Mode == EditorMode.InsertMode) { KulaLevel.MapTile t = ed.TileToBeAdded; if (t != null) { curTileType = t.TileType; curSpecificTileType = TileConverter.FromByteSpecificType(curTileType, t.Type); curMode = ed.Mode; curSurface = ed.ChosenFaceDirection; } } }
public ChangedPointerEventArgs(Editor ed) { if (ed == null) { return; } mt = ed.PointedTile; }
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); } }
/// <summary> /// Questo metodo rimuove una tile dal livello, cancellando a cascata tutte le tile collegate ad esso. /// </summary> /// <param name="mt">Tile da eliminare.</param> private void RemoveTile(KulaLevel.MapTile mt) { if (mt != null) { if (mt.TileType == KulaLevel.TileType.Block) { KulaLevel.MapTile nearTile; Pair <byte> neigh; if (lvlGrid.TryGetValue(neigh = new Pair <byte>(mt.X, (byte)(mt.Y - 1)), out nearTile)) { if ((nearTile.TileType != KulaLevel.TileType.Block) && (nearTile.Orientation == KulaLevel.Orientation.Down)) { RemoveTile(nearTile); } } if (lvlGrid.TryGetValue(neigh = new Pair <byte>(mt.X, (byte)(mt.Y + 1)), out nearTile)) { if ((nearTile.TileType != KulaLevel.TileType.Block) && (nearTile.Orientation == KulaLevel.Orientation.Up)) { RemoveTile(nearTile); } } if (lvlGrid.TryGetValue(neigh = new Pair <byte>((byte)(mt.X - 1), mt.Y), out nearTile)) { if ((nearTile.TileType != KulaLevel.TileType.Block) && (nearTile.Orientation == KulaLevel.Orientation.Right)) { RemoveTile(nearTile); } } if (lvlGrid.TryGetValue(neigh = new Pair <byte>((byte)(mt.X + 1), mt.Y), out nearTile)) { if ((nearTile.TileType != KulaLevel.TileType.Block) && (nearTile.Orientation == KulaLevel.Orientation.Left)) { RemoveTile(nearTile); } } foreach (KulaLevel.Surface s in ((KulaLevel.Block)mt).Surfaces) { if (s.Type == KulaLevel.SurfaceType.Teleport) { s.FlushIncomingTeleport(); s.NextTeleport = null; } } } lvlGrid.Remove(new Pair <byte>(mt.X, mt.Y)); this.Invalidate(); GC.Collect(); } }
private void rdoProperty4_CheckedChanged(object sender, EventArgs e) { if (!isManipulatingOptions && rdoProperty4.Checked) { editLvlEditor.ChosenFaceDirection = a[3]; KulaLevel.MapTile mt = null; if (editLvlEditor.Mode == EditorMode.InsertMode) { mt = editLvlEditor.TileToBeAdded; } else if (editLvlEditor.Mode == EditorMode.SelectMode) { mt = editLvlEditor.PointedTile; } if (mt != null && (mt.TileType == KulaLevel.TileType.Block)) { SetupSurfaceInterface((KulaLevel.Block)mt); } } }
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 } }