private HexSide instantiateSide(Vector3 loc, Quaternion rot, int sideNum) { GameObject side = new GameObject("Side " + sideNum); side.transform.SetParent(this.gameObject.transform); HexSide current = new HexSide(columns, rows, loc, rot, squareSize, glowyMaterial, side, depthScale); return(current); }
public RoutePlaces(BoardVisual board, HexSide side) { foreach (HexSide s in side.GetNeighbours()) { Point2D newPoint = board.CalculatePosition(s); HexSideVisual newHexSide = new HexSideVisual(newPoint, s); Children.Add(newHexSide); } }
public override BehaviourResult Clicked(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board) { Ship ship = rayMeshResult.VisualHit as Ship; if (ship != null) { _Location = ship.Location; return BehaviourResult.Success; } return BehaviourResult.NoSuccess; }
public override BehaviourResult Clicked(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board) { HexSideVisual hexSideVisual = rayMeshResult.VisualHit as HexSideVisual; if (hexSideVisual != null) { _Location = hexSideVisual.Location; board.SetNeutral(); ((BuildShipAction)_OriginatingAction).Intersection = hexSideVisual.Location; return BehaviourResult.Success; } return BehaviourResult.NoSuccess; }
public override BehaviourResult Clicked(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board) { HexSideVisual hexSide = rayMeshResult.VisualHit as HexSideVisual; if (hexSide != null) { if (_ShipToMove == null) { // player has not yet selected a ship to move. Show moveable ships //board.SetMoveShip(); _ShipToMove = hexSide.Location; board.SetMoveToShip(_ShipToMove); return BehaviourResult.NoSuccess; } else { MoveShipAction moveShip = _OriginatingAction as MoveShipAction; moveShip.OldLocation = _ShipToMove; moveShip.NewLocation = hexSide.Location; board.SetNeutral(); return BehaviourResult.Success; } } return BehaviourResult.NoSuccess; }
public Road(Point2D point, Color color, HexSide location) : base(point, color) { _Location = location; Init(); }
/// <summary> /// Returns a list of places a player may build a ship on, excluding a specified ship /// </summary> /// <param name="game"></param> /// <param name="board"></param> /// <param name="shipToMove">Ship to exclude</param> /// <returns></returns> public List<HexSide> GetShipBuildPlaces(XmlGame game, XmlBoard board, HexSide shipToMove) { // Keep track of which sides have been added on the list List<HexSide> result = new List<HexSide>(); //create a list of all possible (nonunique) sides a ship may be built List<HexSide> allSides = new List<HexSide>(); // add sides starting from town/city foreach (HexPoint point in game.PlayerOnTurn.Towns.Union(game.PlayerOnTurn.Cities)) allSides.AddRange(point.GetNeighbourSides); List<HexSide> shipsWithoutMoveable = game.PlayerOnTurn.Ships.ToList(); shipsWithoutMoveable.Remove(shipToMove); //add neighbouring sides from ships foreach (HexSide side in shipsWithoutMoveable) allSides.AddRange(side.GetNeighbours()); // remove all used sides by ships & roads from the list //allSides.Except(game.AllRoadsShips()); List<HexSide> emptySpots = new List<HexSide>(); // used spot from any player List<HexSide> forbiddenSides = game.AllRoadsShips(); forbiddenSides.Add(shipToMove); // pirate places forbiddenSides.AddRange(game.Pirate.GetPoints()); foreach (HexSide s in allSides) { if (!forbiddenSides.Contains(s)) emptySpots.Add(s); } foreach (HexSide side in emptySpots) { // we need at least one seahex if (board.Hexes[side.Hex1] is SeaHex || board.Hexes[side.Hex2] is SeaHex) result.Add(side); } return result; }
public BuildPlaces(BoardVisual board, HexSide side) { foreach (HexPoint p in side.GetNeighbourPoints()) { Children.Add( new BuildPointVisual(board.CalculatePosition(p), p)); } //Children.Add(new BuildPointVisual(board.CalculatePosition(side.GetNeighbourPoints()[0]), side.GetNeighbourPoints()[0])); //Children.Add(new BuildPointVisual(board.CalculatePosition(side.GetNeighbourPoints()[1]), side.GetNeighbourPoints()[1])); }
public RouteNode(HexSide side) : base(side.Hex1, side.Hex2) { }
public HexSideVisual(Point2D point, HexSide location) : base(point) { _Location = location; Init(); }
public bool IsRoadShipPresent(HexSide location) { foreach (GamePlayer player in _Players) { if (player.Roads.Contains(location)) return true; if (player.Ships.Contains(location)) return true; } return false; }
private Color GetColorFromPlayer(HexSide side) { GamePlayer player = (from p in _Game.Players where p.GetRoadsShips().Contains(side) select p).First(); return ColorFromString(player.Color); }
internal void ShowSideNeighbours(HexSide hexSide) { if (Children.Contains(_RoadPlaces)) Children.Remove(_RoadPlaces); _RoadPlaces = new RoutePlaces(this, hexSide); Children.Add(_RoadPlaces); }
public void ShowNeighbours(HexSide side) { if (Children.Contains(_BuildPlaces)) Children.Remove(_BuildPlaces); _BuildPlaces = new BuildPlaces(this, side); Children.Add(_BuildPlaces); }
public void SetMoveToShip(HexSide movedShip) { if (Children.Contains(_ShipPlaces)) Children.Remove(_ShipPlaces); _ShipPlaces = new RoutePlaces(Game.PlayerOnTurn.GetShipBuildPlaces(Game, Board, movedShip), this); Children.Add(_ShipPlaces); }
public Point2D CalculatePosition(HexSide location) { Point2D result = CalculatePosition(location.HighestOrLeftestHex); switch (location.Direction) { case ESideDirection.SlopeDown: result.X += Hex.Width * 0.25; result.Y += (Hex.BottomHeight * 0.5) + Hex.PartialHeight; break; case ESideDirection.SlopeUp: result.X += Hex.Width * 0.75; result.Y += (Hex.BottomHeight * 0.5) + Hex.PartialHeight; break; case ESideDirection.UpDown: result.X += Hex.Width; result.Y += Hex.Height * 0.5; break; } return result; }