Exemplo n.º 1
0
 public SetPortCornerBehaviour(SeaHex seaHex, EPortType portType)
 {
     _PortType = portType;
     _SelectedHex = seaHex;
 }
Exemplo n.º 2
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.º 3
0
        /// <summary>
        /// Resizes the board to a new size. 
        /// </summary>
        /// <param name="newWidth">New width of the board</param>
        /// <param name="newHeight">New height of the board</param>
        public void Resize(int newWidth, int newHeight, Hex defaultHex)
        {
            // default on seahexes if we have no default
            if (defaultHex == null) defaultHex = new SeaHex();

            //return if there is nothing to resize
            if (_Width == newWidth && _Height == newHeight)
            {
                return;
            }

            //Instantiate a new board
            ListArrayOfT newboard = new ListArrayOfT(newWidth, newHeight);

            //loop through new sized matrix.
            for (int h = 0; h < newHeight; h++)
            {
                for (int w = 0; w < newWidth; w++)
                {
                    //when width or height is bigger then original, add hexes
                    if (w >= _Width || h >= _Height)
                    {
                        Hex newHex = null;

                        //if outer bounds, put a SeaHex in place, otherwise a defaulthex
                        if (w == newWidth - 1 || w == 0 || h == newHeight - 1 || h == 0)
                            newHex = new SeaHex();
                        else
                            newHex = defaultHex.Copy();

                        newHex.Location = new HexLocation() { W = w, H = h };
                        newboard[w, h] = newHex;
                    }
                    else
                    {
                        //if outer bounds, put a seahex in place,
                        // otherwise the defaulthex
                        if (w == newWidth - 1 || w == 0 || h == newHeight - 1 || h == 0)
                        {
                            newboard[w, h] = new SeaHex();
                        }
                        else
                        {
                            newboard[w, h] = defaultHex.Copy();
                        }

                        newboard[w, h] = Hexes[w, h].Copy();
                    }

                }
            }
            Hexes = newboard;
        }