[英]Getting a business layer to communicate with presentation
So I'm working on a small TicTacToe application over the holidays to improve some of my skills. 因此,我会在假期期间开发一个小型TicTacToe应用程序,以提高我的一些技能。 I have a two layered approach right now where there is a project for the presnetation and a project for the business end of the game.
我现在有一个两层的方法,其中有一个用于假装的项目和一个用于游戏业务目的的项目。
My question is what is the best way for the State.cs class to tell the WinUI that we have had nine turns and there is no winner or to tell that yes there is a winner after each move? 我的问题是,State.cs类告诉WinUI我们已经进行了9轮并且没有赢家,或者告诉是的,每一步之后都有赢家的最佳方法是什么?
The easiest thing I can think of would be to raise a custom event and have the WinUI listen for it? 我能想到的最简单的事情是引发一个自定义事件并让WinUI监听它?
My source is on Google Code. 我的来源在Google Code上。 I've just checked it in so you can take a quick browse.
我刚刚检查了一下,以便您快速浏览。
Classes of interest for this question would probably be state.cs and Form1.cs. 此问题感兴趣的类可能是state.cs和Form1.cs。
If you have any other suggestions for my code/design I'm all ears!! 如果您对我的代码/设计还有其他建议,我会很高兴!
Cheers, 干杯,
Mike 麦克风
You are trying to remove the UI logic from the Game logic , Yes? 您正在尝试从游戏逻辑中删除UI 逻辑 ,是吗?
Typically this would either be bound to the game iterface, or you could try using callbacks. 通常,这要么绑定到游戏Iterface,要么尝试使用回调。
I would not recomend this for a single player game. 对于单人游戏,我不建议这样做。 If you wish to create an interactive gaming interface, that would make the feedbacks a little more complex, but you are thinking in th correct direction.
如果您希望创建一个交互式游戏界面,这会使反馈变得更加复杂,但您的想法是正确的。 Let the engine indicate when the UI needs to update events .
让引擎指示UI需要何时更新事件 。
I would also recomend having a look at some of the old dogs ( As the old saying goes, if you think you are the first to ask the QUESTION, think again ) 我也建议您看一些老狗( 俗话说,如果您认为自己是第一个提出问题的人,请再考虑一遍 )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.