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 void FromSphericalToWgs84Test4() { var result = new TileConverter().TileFromSphericalToWgs84(10, 4, 4); Assert.True(result.NeedTileIndex.Count == 2); Assert.True(result.Shift.X == 0 && result.Shift.Y == 4); }
/// <summary> /// Modifica il blocco nemico indicato. (Mancano i controlli di integrità). /// </summary> /// <param name="p">Blocco nemico indicato</param> /// <param name="Orient">Stringa che riguarda l'orientamento sulla superficie (dov'è il "basso" per tale blocco)</param> /// <param name="enPer">Indica quanti millisecondi ci mette a percorrere il suo ciclo</param> /// <param name="enRan">Indica quanti blocchi è in grado di coprire.</param> /// <returns></returns> private bool TreatEnemy(KulaLevel.Enemy e, string Orient, uint enPer, uint enRan) { e.ChangeOrientation(TileConverter.StringToOrientation(Orient)); e.Period = enPer; e.Range = (byte)(enRan % 256); return(true); }
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 PixelBuffer(int bitsPerPixel) { int bytesRequired = (int)((CANVAS_WIDTH * CANVAS_HEIGHT) * (bitsPerPixel / 8.0f)); pixels = new byte[bytesRequired]; writtenTiles = 0; switch (bitsPerPixel) { case 4: { pixelConverter = new TileConverter(ConvertTile4BPP); canvasWidth = CANVAS_WIDTH / 2; tileWidth = TILE_WIDTH / 2; } break; case 8: { pixelConverter = new TileConverter(ConvertTile8BPP); canvasWidth = CANVAS_WIDTH; tileWidth = TILE_WIDTH; } break; default: { Debug.Assert(false, "PixelBuffer constructed with unknown bits per pixel value"); throw new InvalidOperationException(); } } }
private static void AddColor(KulaLevel.TileType tt, byte st, Color c) { Pair <string> a; if (!colors.ContainsKey(a = new Pair <string>(tt.ToString(), TileConverter.FromByteSpecificType(tt, st)))) { colors.Add(a, c); } }
public void FromWgs84ToSphericalTest19() { var result = new TileConverter().TileFromWgs84ToSpherical(331889, 162069, 19); Assert.True(result.NeedTileIndex.Count == 2); Assert.True(result.Shift.X == 0 && result.Shift.Y == 193); var testNeedTileIndexFirst = result.NeedTileIndex.First(); var testNeedTileIndexLast = result.NeedTileIndex.Last(); Assert.True(testNeedTileIndexFirst.X == 331889 && testNeedTileIndexFirst.Y == 162069); Assert.True(testNeedTileIndexLast.X == 331889 && testNeedTileIndexLast.Y == 162070); }
public void FromSphericalToWgs84Test18() { var result = new TileConverter().TileFromSphericalToWgs84(165944, 81034, 18); Assert.True(result.NeedTileIndex.Count == 2); Assert.True(result.Shift.X == 0 && result.Shift.Y == 37); var testNeedTileIndexFirst = result.NeedTileIndex.First(); var testNeedTileIndexLast = result.NeedTileIndex.Last(); Assert.True(testNeedTileIndexFirst.X == 165944 && testNeedTileIndexFirst.Y == 81034); Assert.True(testNeedTileIndexLast.X == 165944 && testNeedTileIndexLast.Y == 81035); }
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); }
public Tile LoadTile(string file) { if (tiles.TryGetValue(file, out Tile result)) { return(result); } uint id = (uint)tilesByID.Count(); Tile tile = TileConverter.Convert(Loader.LoadTile(file), id); tiles.Add(file, tile); tilesByID.Add(tile); return(tile); }
private TileType GetRandomTypeFromSelection(List <int> tileSelection) { int currentIndex = RNG.Next(0, tileSelection.Count); int currentTileInt = tileSelection[currentIndex]; GameManager.singleton.tileTypes.Remove(currentTileInt); TileType currentTile = TileConverter.FromIntToType(currentTileInt); if (currentTile == TileType.Shop) { hasShop = true; } else if (currentTile == TileType.Fountain) { hasFountain = true; } return(currentTile); }
public void GenerateTileTypes() { foreach (GameObject tile in rowTiles) { List <int> tileSelection = GameManager.singleton.tileTypes; if (hasShop) { tileSelection = tileSelection.Where(x => x != TileConverter.FromTypeToInt(TileType.Shop)).ToList(); } if (hasFountain) { tileSelection = tileSelection.Where(x => x != TileConverter.FromTypeToInt(TileType.Fountain)).ToList(); } TileType currentTile = GetRandomTypeFromSelection(tileSelection); tile.GetComponent <TypeHolder>().ChangeType(currentTile); } }
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; }
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 } }
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(); }
/// <summary> /// Modifica il blocco placeable indicato. (Mancano i controlli di integrità). /// </summary> /// <param name="p">Blocco placeable indicato</param> /// <param name="Orient">Stringa che riguarda l'orientamento sulla superficie (dov'è il "basso" per tale blocco)</param> /// <returns></returns> private bool TreatPlaceable(KulaLevel.Placeable p, string Orient, string GCDirection) { p.ChangeOrientation(TileConverter.StringToOrientation(Orient)); p.GChangerDirection = TileConverter.StringToOrientation(GCDirection); return(true); }