Ejemplo n.º 1
0
        /// <summary>
        /// Default behaviour: highlight hex
        /// </summary>
        /// <param name="rayMeshResult"></param>
        public virtual void Moved(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
        {
            if (rayMeshResult != null)
            {
                HexVisual hex = rayMeshResult.VisualHit as HexVisual;
                if (hex != null)
                {
                    if (_OldMouseOverHex != null)
                        _OldMouseOverHex.Selected = false;
                    hex.Selected = true;

                    _OldMouseOverHex = hex;
                }
            }
        }
Ejemplo n.º 2
0
        void Hexes_HexChanged(Hex oldHex, Hex newHex)
        {
            oldHex.PropertyChanged -= xmlHex_PropertyChanged;

            HexVisual hexVisual = GetHexVisualByHex(oldHex);
            // lookup hex in children
            Children.Remove(hexVisual);
            Point2D point = CalculatePosition(oldHex.Location);
            HexVisual newHexVisual = new HexVisual(point, newHex);
            newHexVisual.Parent = this;
            //newHexVisual.Transform = new TranslateTransform3D(-MiddleX, 0, -MiddleY);
            Children.Add(newHexVisual);
            newHex.PropertyChanged += new PropertyChangedEventHandler(xmlHex_PropertyChanged);
        }
Ejemplo n.º 3
0
        private void SetSelectionState(HexVisual hex)
        {
            if (_OldMouseOverHex != null)
                _OldMouseOverHex.Selected = false;
            hex.Selected = true;

            _OldMouseOverHex = hex;
        }
Ejemplo n.º 4
0
        private void CreateUI()
        {
            if (Board != null)
            {
                foreach (Hex xmlHex in Board.Hexes)
                {
                    Point2D point = CalculatePosition(xmlHex.Location);

                    //make a new hex with the parameters
                    HexVisual hexToAdd = new HexVisual(point, xmlHex);
                    hexToAdd.Parent = this;
                    xmlHex.PropertyChanged += new PropertyChangedEventHandler(xmlHex_PropertyChanged);

                    //add hex to data structure and visual structure
                    this.Children.Add(hexToAdd);
                }
            }
        }