WPF“十六进制网格"成分 [英] WPF "hex grid" component

查看:198
本文介绍了WPF“十六进制网格"成分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

跳到WPF自定义控件的世界,想知道设计HexGrid控件的最佳方法是什么?想一想您最喜欢的桌面战争游戏;或者,同样可能是您最喜欢的视频游戏,它从台式战争游戏的悠久历史中窃取了设计.

Jumping into the world of WPF custom controls, and was wondering what the best way to design a HexGrid control would be? Think your favorite table-top war game; or, equally likely, your favorite video game that steals the design from a proud history of table-top war games.

基础模型公开了一种重要的方法,作为Map类的一部分:

The underlying model exposes one significant method, as a part of a Map class:

Hex GetHex(int x, int y, int z)*;

十六进制包含所有相关数据(目前,地形枚举将1:1映射到背景颜色;从小开始...).

Hex contains all relevant data (at the moment, a Terrain enumeration that maps 1:1 to a background color; starting small...).

可能相关的约束:
地图的大小不变十六进制数据在非常可预测的时间发生变化(总是直接响应用户的操作).

Possibly relevant constrains:
Map doesn't change in size & Hex data changes at very predictable times (always in direct response to user action).

理想情况下,该组件将扩展以干净地填充其容器,并可以直接在XAML中声明.

Ideally the component will expand to fill its container cleanly, and be declarable directly in XAML.

我要寻找的是构建该框架所需的粗略概述,而不是现成的组件.

What I'm looking for is a sketchy outline of what I need to do to build this, not a ready made component.

*我虽然对这种寻址方案非常聪明,但是显然我参加聚会.

*I though I was being pretty clever with this addressing scheme, but apparently I'm late to the party.

推荐答案

以下是指向Pete项目页面的链接,该页面具有十六进制网格示例. http://blois.us/Projects.html 有一个寻路示例显示了一个名为pathfinding的项目,该项目具有一个十六进制网格,并且可能使用与minesweeper相同的基本代码.我还没有看过.它是Silverlight 3,因此可能需要升级.扫雷车非常优雅.

Here's a link to Pete's project page which has a hex grid sample. http://blois.us/Projects.html There is a pathfinding sample that shows a project called pathfinding which has a Hex Grid, and probably uses the same basic code that minesweeper does. I haven't looked at it yet. It is Silverlight 3 so may need to be upgraded. Minesweeper was pretty elegant.

拉尔夫

原始: 彼得·布洛伊斯(Peter blois)拍摄了一个六角形扫雷器的Silverlight 2样品.

ORIGINAL: There was a sample for silverlight 2 by peter blois of a hexagonal version of minesweeper.

它包括源代码.他有一个非常优雅的方法,可以通过覆盖网格上的measureoverride和arrangeoverride来做到这一点.鼠标悬停等工作正常.代码很少.

It included source code. He had a very elegant method of doing it by overriding the measureoverride and arrangeoverride on the grid. Mouseovers, etc. worked fine. There was remarkably little code.

尽管谷歌通过搜索六角扫雷车Silverlight源代码blois已有旧链接,但我再也无法在网上找到该项目

I can't find the project on the web any more, although google has a stale link to it by searching for hexagon minesweeper silverlight source code blois

Peter Blois在下面的地址有一个当前博客,因此您可以在这里尝试与他联系... http://blois.us/Projects.html

Peter Blois has a current blog at the below address, so you might try contacting him here... http://blois.us/Projects.html

祝你好运,告诉我怎么回事,我要去找类似的东西.

Good luck and tell me how it goes, I'm going to be dong something similar.

这篇关于WPF“十六进制网格"成分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆