Exemplo n.º 1
0
 public RoutePlaces(List<HexSide> list, BoardVisual board)
 {
     foreach (HexSide side in list)
     {
         Children.Add(new HexSideVisual(board.CalculatePosition(side), side));
     }
 }
Exemplo n.º 2
0
        public override BehaviourResult Clicked(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
        {
            PortVisual port = rayMeshResult.VisualHit as PortVisual;
            if (port !=null)
            {
                board.ShowSideNeighbours(port.XmlPort.SideLocation);
                return BehaviourResult.NoSuccess;
            }

            HexVisual hex = rayMeshResult.VisualHit as HexVisual;
            if (hex != null)
            {
                List<HexPoint> temp = new List<HexPoint>();
                List<HexPoint> temp2 = hex.Hex.Location.GetNeighbourPoints();
                temp.Add(temp2[0]);
                temp.Add(temp2[1]);
                temp.Add(temp2[4]);
                board.ShowPoints(temp);
            }

            Road road = rayMeshResult.VisualHit as Road;
            if (road != null)
            {
                //board.Game.PlayerOnTurn.Towns.Add(buildPoint.Location);
                //board.ShowNeighbours(road.Location);
                board.ShowSideNeighbours(road.Location);
                return BehaviourResult.NoSuccess;
            }

            return BehaviourResult.NoSuccess;
        }
        public override void SetStartState(BoardVisual board)
        {
            RollDiceAction rollDice = OriginatingAction as RollDiceAction;
            if (rollDice != null)
            {
                // darken each hex which didnt produce resource(s)
                if (rollDice.PlayersResources.Count > 0)
                {
                    List<HexLocation> rolledHexes = new List<HexLocation>();
                    foreach (ResourceHex hex in rollDice.HexesAffected)
                        rolledHexes.Add(hex.Location);

                    foreach (HexVisual hv in board.Children.OfType<HexVisual>())
                    {
                        if (rolledHexes.Contains(hv.Hex.Location))
                        {
                            hv.IsDarkened = false;
                        }
                        else
                        {
                            hv.IsDarkened = true;
                        }
                    }
                }
            }
        }
 public override void RemoveStartState(BoardVisual board)
 {
     foreach (HexVisual hv in board.Children.OfType<HexVisual>())
     {
         hv.IsDarkened = false;
     }
 }
Exemplo n.º 5
0
        public override BehaviourResult Clicked(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
        {
            //find an appropriate visual user clicked,
            // can be hex or simply the chitnumber
            ResourceHex resourceHex = null;
            HexVisual hexVisual = rayMeshResult.VisualHit as HexVisual;
            if (hexVisual != null)
            {
                resourceHex = hexVisual.Hex as ResourceHex;
            }
            ChitVisual chitVisual = rayMeshResult.VisualHit as ChitVisual;
            if (chitVisual != null)
            {
                resourceHex = (ResourceHex)((HexVisual)chitVisual.Parent).Hex;
            }

            //when we found a suitable visual, update the chit number.
            if (resourceHex != null)
            {
                resourceHex.XmlChit = new Chit() { ChitNumber = _Number };
                return BehaviourResult.Success;
            }
            else
            {
                return BehaviourResult.NoSuccess;
            }
        }
Exemplo n.º 6
0
 public override void Moved(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
 {
     if (rayMeshResult != null)
     {
         GeometryModel3D hitgeo = rayMeshResult.ModelHit as GeometryModel3D;
         HexVisual hex = rayMeshResult.VisualHit as HexVisual;
         if (hex != null)
         {
             // only show mouseover when we have a resourcehex
             if (hex.Hex is ResourceHex)
             {
                 // when we are removing chits, show mouseover when there is
                 // something to remove
                 if (_Number == EChitNumber.None)
                 {
                     ResourceHex resourceHex = hex.Hex as ResourceHex;
                     if (resourceHex.XmlChit.ChitNumber != EChitNumber.None)
                     {
                         SetSelectionState(hex);
                     }
                 }
                 else
                 {
                     //default on showing a mouseover
                     SetSelectionState(hex);
                 }
             }
         }
     }
 }
Exemplo n.º 7
0
 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);
     }
 }
Exemplo n.º 8
0
 public override void cancelMove()
 {
     if (_currentChessVidMode == SHOW_PLACE || _currentChessVidMode == STAY_HOME)
     {
         return;
     }
     base.cancelMove();
     BoardVisual.reset();
     _currentChessVidMode = SHOW_PLACE;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Calculate three possible locations for the road to be placed at placement gamephase
 /// </summary>
 /// <param name="game"></param>
 /// <param name="board"></param>
 /// <param name="townOrCity"></param>
 public RoutePlaces(XmlGame game, BoardVisual board, HexPoint townOrCity)
 {
     // Add each side to children
     foreach (HexSide side in townOrCity.GetNeighbourSides)
     {
         Point2D newPoint = board.CalculatePosition(side);
         HexSideVisual newHexSide = new HexSideVisual(newPoint, side);
         Children.Add(newHexSide);
     }
 }
Exemplo n.º 10
0
 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;
 }
Exemplo n.º 11
0
 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;
 }
Exemplo n.º 12
0
 public override BehaviourResult Clicked(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
 {
     BuildPointVisual buildPoint = rayMeshResult.VisualHit as BuildPointVisual;
     if (buildPoint != null)
     {
         //board.Game.PlayerOnTurn.Towns.Add(buildPoint.Location);
         board.SetNeutral();
         ((BuildTownAction)_OriginatingAction).Location = buildPoint.Location;
         return BehaviourResult.Success;
     }
     return BehaviourResult.NoSuccess;
 }
Exemplo n.º 13
0
 public override BehaviourResult Clicked(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
 {
     HexVisual hexVisual = rayMeshResult.VisualHit as HexVisual;
     if (hexVisual != null)
     {
         Hex newHex = _SelectedHexType.Copy();
         newHex.Location = hexVisual.Hex.Location;
         board.Board.Hexes[newHex.Location] = newHex;
         return BehaviourResult.Success;
     }
     return BehaviourResult.NoSuccess;
 }
Exemplo n.º 14
0
 public override BehaviourResult Clicked(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
 {
     HexVisual hexVisual = rayMeshResult.VisualHit as HexVisual;
     if (hexVisual != null)
     {
         ResourceHex resourceHex = hexVisual.Hex as ResourceHex;
         if (resourceHex != null)
         {
             _Location = resourceHex.Location;
             return BehaviourResult.Success;
         }
     }
     return BehaviourResult.NoSuccess;
 }
Exemplo n.º 15
0
        public override void Moved(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
        {
            HexVisual hex = rayMeshResult.VisualHit as HexVisual;
            if (hex != null)
            {
                if (hex.Hex is ITerritoryHex)
                {
                    if (_OldMouseOverHex != null)
                        _OldMouseOverHex.Selected = false;
                    hex.Selected = true;

                    _OldMouseOverHex = hex;
                }
            }
        }
Exemplo n.º 16
0
 public override void SetStartState(BoardVisual board)
 {
     foreach (HexVisual hv in from h in board.Children.OfType<HexVisual>()
                              select h)
     {
         ITerritoryHex terrHex = hv.Hex as ITerritoryHex;
         if (terrHex != null)
             if (terrHex.TerritoryID == _TerritoryID)
                 hv.IsDarkened = false;
             else
                 hv.IsDarkened = true;
         else
             hv.IsDarkened= true;
     }
 }
Exemplo n.º 17
0
 /// <summary>
 /// Calculate all possible positions to build a ship or a road
 /// </summary>
 /// <param name="game"></param>
 /// <param name="board"></param>
 /// <param name="ships"></param>
 public RoutePlaces(
     XmlGame game,
     BoardVisual board,
     bool ships)
 {
     if (ships)
     {
         foreach (HexSide side in game.PlayerOnTurn.GetShipBuildPlaces(game, board.Board))
             Children.Add(new HexSideVisual(board.CalculatePosition(side), side));
     }
     else
     {
         foreach (HexSide side in game.PlayerOnTurn.GetRoadBuildPlaces(game, board.Board))
             Children.Add(new HexSideVisual(board.CalculatePosition(side), side));
     }
 }
Exemplo n.º 18
0
 public override BehaviourResult Clicked(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
 {
     //Check if clicked hex is a LandHex, if so, put current territory
     //on the hex.
     HexVisual hexVisual = rayMeshResult.VisualHit as HexVisual;
     if (hexVisual != null)
     {
         ITerritoryHex terrHex = hexVisual.Hex as ITerritoryHex;
         if (terrHex != null)
         {
             terrHex.TerritoryID = _SelectedTerritory.ID;
             return BehaviourResult.Success;
         }
     }
     return BehaviourResult.NoSuccess;
 }
Exemplo n.º 19
0
        public override void Moved(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
        {
            HexVisual hv = rayMeshResult.VisualHit as HexVisual;
            if (hv != null)
            {
                if (!_ForbiddenHexes.Contains(hv) ||
                    hv.Hex.Location.Equals(board.Game.Robber) ||
                    hv.Hex.Location.Equals(board.Game.Pirate))
                {
                    if (_OldMouseOverHex != null)
                        _OldMouseOverHex.Selected = false;
                    hv.Selected = true;

                    _OldMouseOverHex = hv;
                }
            }
        }
Exemplo n.º 20
0
 public override BehaviourResult Clicked(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
 {
     Road hsv = rayMeshResult.VisualHit as Road;
     if (hsv != null)
     {
         hsv.IsRoadSelected = true;
     }
     BuildPointVisual buildPoint = rayMeshResult.VisualHit as BuildPointVisual;
     if (buildPoint != null)
     {
         //board.Game.PlayerOnTurn.Cities.Add(buildPoint.Location);
         _Location = buildPoint.Location;
         board.SetNeutral();
         ((BuildCityAction)_OriginatingAction).Location = buildPoint.Location;
         return BehaviourResult.Success;
     }
     return BehaviourResult.NoSuccess;
 }
Exemplo n.º 21
0
        public override BehaviourResult Clicked(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
        {
            HexVisual hexVisual = rayMeshResult.VisualHit as HexVisual;
            if (hexVisual != null)
            {
                PlaceRobberPirateAction placeRobberPirate = _OriginatingAction as PlaceRobberPirateAction;
                if (placeRobberPirate != null)
                {
                    if (hexVisual.Hex is SeaHex)
                        _IsRobber = false;

                    placeRobberPirate.Location = hexVisual.Hex.Location;
                    RemoveStartState(board);
                    return BehaviourResult.Success;
                }
            }
            return BehaviourResult.NoSuccess;
        }
Exemplo n.º 22
0
        public override BehaviourResult Clicked(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
        {
            Road side = rayMeshResult.VisualHit as Road;
            if (side != null)
            {
                List<BuildPointVisual> x = new List<BuildPointVisual>();
                foreach (BuildPointVisual bpv in board.Children.OfType<BuildPointVisual>())
                    x.Add(bpv);
                foreach (BuildPointVisual bp in x)
                    board.Children.Remove(bp);

                BuildPointVisual bpv1 = new BuildPointVisual(board.CalculatePosition(side.Location.HexPoint1), side.Location.HexPoint1);
                BuildPointVisual bpv2 = new BuildPointVisual(board.CalculatePosition(side.Location.HexPoint2), side.Location.HexPoint2);
                board.Children.Add(bpv1);
                board.Children.Add(bpv2);
            }
            return BehaviourResult.NoSuccess;
        }
Exemplo n.º 23
0
        public override void Moved(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
        {
            HexSideVisual hexSideVisual = rayMeshResult.VisualHit as HexSideVisual;
            if (_OldMouseOver != null)
            {
                _OldMouseOver.Scale.ScaleX = 1;
                _OldMouseOver.Scale.ScaleY = 1;
                _OldMouseOver.Scale.ScaleZ = 1;
                _OldMouseOver = null;
            }
            if (hexSideVisual != null)
            {

                hexSideVisual.Scale.ScaleX = 2;
                hexSideVisual.Scale.ScaleY = 2;
                hexSideVisual.Scale.ScaleZ = 2;
                _OldMouseOver = hexSideVisual;
            }
        }
Exemplo n.º 24
0
 public override void Moved(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
 {
     BuildPointVisual buildPoint = rayMeshResult.VisualHit as BuildPointVisual;
     if (buildPoint != null)
     {
         buildPoint.Scale.ScaleX = 2;
         buildPoint.Scale.ScaleY = 2;
         buildPoint.Scale.ScaleZ = 2;
         _OldBuildPoint = buildPoint;
     }
     else
     {
         if (_OldBuildPoint != null)
         {
             _OldBuildPoint.Scale.ScaleX = 1;
             _OldBuildPoint.Scale.ScaleY = 1;
             _OldBuildPoint.Scale.ScaleZ = 1;
         }
     }
 }
Exemplo n.º 25
0
        public override BehaviourResult Clicked(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
        {
            HexVisual hexVisual = rayMeshResult.VisualHit as HexVisual;
            if (hexVisual != null)
            {
                SeaHex seaHex = hexVisual.Hex as SeaHex;
                if (seaHex != null)
                {
                    if (((SeaHex)seaHex).XmlPort != null)
                    {
                        // we confirmed the port here, make a small animation
                        hexVisual.AnimatePortSetted();
                        return BehaviourResult.Success;
                    }
                }
            }

            // we need a seahex to move on
            return BehaviourResult.Success;
        }
Exemplo n.º 26
0
 public override BehaviourResult Clicked(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
 {
     HexVisual hexVisual = rayMeshResult.VisualHit as HexVisual;
     if (hexVisual != null)
     {
         SeaHex seaHex = hexVisual.Hex as SeaHex;
         if (seaHex != null)
         {
             if (_SelectedPortType == EPortType.None)
             {
                 seaHex.XmlPort = null;
                 return BehaviourResult.Success;
             }
             else
             {
                 if (seaHex.XmlPort == null)
                     seaHex.XmlPort = new Port()
                     {
                         Location = seaHex.Location,
                     };
                 seaHex.XmlPort.PortType = _SelectedPortType;
                 switch (rayMeshResult.VertexIndex3)
                 {
                     case 0: seaHex.XmlPort.PortPosition = ERotationPosition.Deg240; break;
                     case 1: seaHex.XmlPort.PortPosition = ERotationPosition.Deg180; break;
                     case 2: seaHex.XmlPort.PortPosition = ERotationPosition.Deg120; break;
                     case 3: seaHex.XmlPort.PortPosition = ERotationPosition.Deg60; break;
                     case 4: seaHex.XmlPort.PortPosition = ERotationPosition.Deg0; break;
                     case 5: seaHex.XmlPort.PortPosition = ERotationPosition.Deg300; break;
                 }
                 hexVisual.AnimatePortSetted();
                 if (_SelectedHex == null)
                     _SelectedHex = seaHex;
                 else
                     _SelectedHex = null;
                 return BehaviourResult.Success;
             }
         }
     }
     return BehaviourResult.NoSuccess;
 }
Exemplo n.º 27
0
        public override void SetStartState(BoardVisual board)
        {
            if (_ForbiddenHexes.Count != 0)
                _ForbiddenHexes.Clear();

            foreach (HexVisual hv in board.Children.OfType<HexVisual>())
            {
                // TODO: check for edges, not allowe dto put robber or pirate there
                // Edges should be created at board design so we can iterate over them easily
                // Hex.IsEdge?

                if (hv.Hex.Location.W == 0 ||
                    hv.Hex.Location.H == 0 ||
                    hv.Hex.Location.W == board.Board.Width - 1 ||
                    hv.Hex.Location.H == board.Board.Height - 1)
                {
                    _ForbiddenHexes.Add(hv);
                    hv.IsDarkened = true;
                }
            }
        }
Exemplo n.º 28
0
 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;
 }
Exemplo n.º 29
0
 public virtual void SetStartState(BoardVisual board)
 {
 }
Exemplo n.º 30
0
 public virtual void RemoveStartState(BoardVisual board)
 {
 }
Exemplo n.º 31
0
 public virtual BehaviourResult Clicked(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
 {
     return BehaviourResult.NoSuccess;
 }