コード例 #1
0
ファイル: Hex.cs プロジェクト: Rupini/HexEditor
        public Hex(Index2D inx, Point center,  HexType type, int height)
        {
            r = GlobalConst.DEFAULT_r;
            a = 2d / Math.Sqrt(3) * r;
            index = inx;
            this.type = type;
            this.height = height;

            if (type != HexType.Empty)
                render = new HexRender(DisplayType.GAME_SimpleGround, height, center);
        }
コード例 #2
0
ファイル: HexGrid.cs プロジェクト: Rupini/HexEditor
        public HexGrid(UIElementCollection ui, Action<List<Point>> onSelected)
        {
            _i = this;

            this.real_r = GlobalConst.DEFAULT_r;
            this.real_a = 2.0 / Math.Sqrt(3) * real_r;
            this.worldOrigin = new Point(0, 0);
            this.ui = ui;

            selectableHex = new HexRender(DisplayType.FUNC_Selectable);

            ui.Add(selectableHex);

            this.onSelected = onSelected;

            hexPen = new Pen
            {
                Brush = Brushes.BlueViolet,
                Thickness = 2,
                StartLineCap = PenLineCap.Round,
                EndLineCap = PenLineCap.Round
            };
        }
コード例 #3
0
ファイル: HexGrid.cs プロジェクト: Rupini/HexEditor
        private void DuringSelect(Point point)
        {
            selectCurrent = point;
            int[] size;
            var points = GetHexInWorldAreaFromScreen(selectStart, selectCurrent.X - selectStart.X, selectCurrent.Y - selectStart.Y, out size, true);

            selectableArea.RemoveAll((hex) => { ui.Remove(hex); return true; });
            points.ForEach((p) => { var hex = new HexRender(DisplayType.FUNC_Selectable); hex.WorldCenter = p; selectableArea.Add(hex); });
            selectableArea.ForEach((hex) => { hex.Refresh(); ui.Add(hex); });
        }
コード例 #4
0
ファイル: HexGrid.cs プロジェクト: Rupini/HexEditor
        public void OnSelect()
        {
            selectedArea.RemoveAll((hex) => { ui.Remove(hex); return true; });

            if (selectableArea.Count == 0)
            {
                var selectedHex = new HexRender(DisplayType.FUNC_Selected);
                selectedHex.Refresh(selectableHex.WorldCenter);
                ui.Add(selectedHex);
                selectedArea.Add(selectedHex);
            }
            else
                selectedArea = new List<HexRender>(selectableArea);

            selectedArea.ForEach((hex) => { hex.DisplayType = DisplayType.FUNC_Selected; });
            onSelected(selectedArea.ConvertAll((hex) => hex.WorldCenter));
        }