public void RotateVec(TileDirection dir) { for (int i = 0; i < Vectors.Count; i++) { var v = Vectors[i]; int x = (v.X * cos((int)dir)) - (v.Y * sin((int)dir)), y = (v.X * sin((int)dir)) + (v.Y * cos((int)dir)); Vectors[i] = new Point(x, y); } }
public Tile(TileType type, int x = 0, int y = 0, bool opened = false, TileDirection direction = TileDirection.up, short gold = 0, Player team = Player.none, bool pirate1 = false, bool pirate2 = false, bool pirate3 = false) { this.Pos = new Point(x, y); this.Type = type; this.Gold = gold; this.Team = team; this.Pirate1 = pirate1; this.Pirate2 = pirate2; this.Pirate3 = pirate3; this.Opened = opened; switch (Type) // setup image paths according to tile types { case (TileType.grass1): ImageUri = new Uri("./tiles/empty-1.png", UriKind.Relative); break; case (TileType.grass2): ImageUri = new Uri("./tiles/empty-2.png", UriKind.Relative); break; case (TileType.grass3): ImageUri = new Uri("./tiles/empty-3.png", UriKind.Relative); break; case (TileType.grass4): ImageUri = new Uri("./tiles/empty-4.png", UriKind.Relative); break; case (TileType.rum): ImageUri = new Uri("./tiles/keg-of-rum.png", UriKind.Relative); break; case (TileType.ice): ImageUri = new Uri("./tiles/ice.png", UriKind.Relative); break; case (TileType.hole): ImageUri = new Uri("./tiles/pitfall.png", UriKind.Relative); break; case (TileType.croc): ImageUri = new Uri("./tiles/crocodile.png", UriKind.Relative); break; case (TileType.cannibal): ImageUri = new Uri("./tiles/cannibal.png", UriKind.Relative); break; case (TileType.fort): ImageUri = new Uri("./tiles/fort.png", UriKind.Relative); break; case (TileType.gfort): ImageUri = new Uri("./tiles/fort-w-aborigine.png", UriKind.Relative); break; case (TileType.coins1): ImageUri = new Uri("./tiles/coins-1.png", UriKind.Relative); break; case (TileType.coins2): ImageUri = new Uri("./tiles/coins-2.png", UriKind.Relative); break; case (TileType.coins3): ImageUri = new Uri("./tiles/coins-3.png", UriKind.Relative); break; case (TileType.coins4): ImageUri = new Uri("./tiles/coins-4.png", UriKind.Relative); break; case (TileType.coins5): ImageUri = new Uri("./tiles/coins-5.png", UriKind.Relative); break; case (TileType.balloon): ImageUri = new Uri("./tiles/balloon.png", UriKind.Relative); break; case (TileType.cannon): ImageUri = new Uri("./tiles/gun.png", UriKind.Relative); Direction = (TileDirection)((Board.rand.Next() % 4) * 90); break; case (TileType.water): ImageUri = new Uri("./tiles/water.png", UriKind.Relative); break; case (TileType.astr1): ImageUri = new Uri("./tiles/arrow-1.png", UriKind.Relative); Direction = (TileDirection)((Board.rand.Next() % 4) * 90); Vectors.Add(new Point(0, -1)); break; case (TileType.adiag1): ImageUri = new Uri("./tiles/arrow-2.png", UriKind.Relative); Direction = (TileDirection)((Board.rand.Next() % 4) * 90); Vectors.Add(new Point(1, -1)); break; case (TileType.adiag2): ImageUri = new Uri("./tiles/arrow-4.png", UriKind.Relative); Direction = (TileDirection)((Board.rand.Next() % 4) * 90); Vectors.Add(new Point(1, -1)); Vectors.Add(new Point(-1, 1)); break; case (TileType.astr2): ImageUri = new Uri("./tiles/arrow-3.png", UriKind.Relative); Direction = (TileDirection)((Board.rand.Next() % 4) * 90); Vectors.Add(new Point(0, -1)); Vectors.Add(new Point(0, 1)); break; case (TileType.a3): ImageUri = new Uri("./tiles/arrow-5.png", UriKind.Relative); Direction = (TileDirection)((Board.rand.Next() % 4) * 90); Vectors.Add(new Point(0, 1)); Vectors.Add(new Point(-1, 0)); Vectors.Add(new Point(1, -1)); break; case (TileType.astr4): ImageUri = new Uri("./tiles/arrow-6.png", UriKind.Relative); Direction = (TileDirection)((Board.rand.Next() % 4) * 90); Vectors.Add(new Point(1, 0)); Vectors.Add(new Point(0, 1)); Vectors.Add(new Point(0, -1)); Vectors.Add(new Point(-1, 0)); break; case (TileType.adiag4): ImageUri = new Uri("./tiles/arrow-7.png", UriKind.Relative); Direction = (TileDirection)((Board.rand.Next() % 4) * 90); Vectors.Add(new Point(1, -1)); Vectors.Add(new Point(1, 1)); Vectors.Add(new Point(-1, 1)); Vectors.Add(new Point(-1, -1)); break; case (TileType.lab2): ImageUri = new Uri("./tiles/rotate-2.png", UriKind.Relative); break; case (TileType.lab3): ImageUri = new Uri("./tiles/rotate-3.png", UriKind.Relative); break; case (TileType.lab4): ImageUri = new Uri("./tiles/rotate-4.png", UriKind.Relative); break; case (TileType.lab5): ImageUri = new Uri("./tiles/rotate-5.png", UriKind.Relative); break; case (TileType.horse): ImageUri = new Uri("./tiles/horse.png", UriKind.Relative); break; case (TileType.plane): ImageUri = new Uri("./tiles/airplane.png", UriKind.Relative); break; case (TileType.graveyard): ImageUri = new Uri("./tiles/graveyard.png", UriKind.Relative); break; default: // TODO: remove this when proper image arranging is done ImageUri = new Uri("./tiles/empty!.png", UriKind.Relative); break; } RotateVec(Direction); }
public bool Equals(TileDirection other) { return(Equals(From, other.From) && Equals(To, other.To)); }