纸牌游戏库(译文)
By robot-v1.0
本文链接 https://www.kyfws.com/games/cards-game-library-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 4 分钟阅读 - 1678 个词 阅读量 0纸牌游戏库(译文)
原文地址:https://www.codeproject.com/Articles/28940/Cards-Game-Library
原文作者:Bishoy Labib
译文由本站 robot-v1.0 翻译
前言
A library for creating a cards games with Silverlight, with two sample Solitaire games.
一个用于使用Silverlight创建纸牌游戏的库,其中包含两个示例纸牌游戏.
介绍(Introduction)
这是一个用于纸牌游戏的C#类库;对于想开发纸牌游戏(特别是使用Silverlight)的人来说,它非常有用,尽管它也可以与其他.NET技术一起使用.对于想学习Silverlight的任何人来说,它也是一个完整的例子.(This is a C# class library for card games; it’s very useful for anyone who is thinking of developing a cards game especially with Silverlight, though it could be used with other .NET technologies as well. It’s also useful as a complete example for anyone who wants to learn Silverlight.) 我已经使用此库构建了两个游戏(单人纸牌和蜘蛛纸牌),从源代码中您可以看到,在单个游戏项目中编写的代码是最少的,仅代表游戏规则.(I’ve built two games (Solitaire and Spider Solitaire) using this library, and you can see from the source code that the code written in the individual game projects is minimal and only represent the game rules.) 您可以在我的博客中看到正在运行的游戏:(You can see the games on action in my blog:)
- http://bishoylabib.blogspot.com/2008/05/solitaire.html(http://bishoylabib.blogspot.com/2008/05/solitaire.html)
- http://bishoylabib.blogspot.com/2008/08/spider-solitaire.html(http://bishoylabib.blogspot.com/2008/08/spider-solitaire.html) 实际的Silverlight应用程序托管在(The actual Silverlight applications are hosted on) http://streaming.live.com(http://streaming.live.com) ,这是Microsoft提供的一项很棒的免费服务.(, which is a great free service from Microsoft.)
总览(Overview)
该解决方案包含以下项目:(The solution contains the following projects:)
-
卡数据(Cards.Data)这是一个纸牌游戏库,仅包含纸牌数据和逻辑,不包含任何特定于Silverlight的内容.(This is a library for card games, only contains card data and logic, and doesn’t contain anything that is specific to Silverlight.) 包含以下类:(Contains the following classes:)
Game
:代表纸牌游戏的类,其中包含甲板和纸牌.从此类中,您可以遍历所有其他数据类.(: a class that represents the card game, which contains decks and cards. From this class, you can traverse all the other data classes.)Deck
:一堆纸牌,可以初始化并将其用作完整的纸牌组(52张纸牌),并从中抽出至其他纸牌,例如玩家的手牌或地牌.(: a stack of cards that could be initialized and used as the full cards deck (52 cards) and drawn from it to other decks like player hands or ground stacks.)Card
:实际的卡对象.(: the actual card object.)
-
卡.银光(Cards.Silverlight)这是一个具有Silverlight控件的库,这些控件代表上述每个类.每个控件都有一个指向其关联数据类的指针,并为其事件提供事件处理程序,并通过图形和动画进行响应.(This is a library that has Silverlight controls that represent each of the above classes. Each control has a pointer to its associated data class, and provides event handlers to its events and responds with graphics and animations.) 包含以下控件:(Contains the following controls:)
GameShape
:这是(: This is the graphical representation of the)Game
类.它没有很多图形逻辑,但是包含相关游戏中存在的副牌和纸牌的其他图形表示形式的列表.它提供了实用程序功能来查找代表卡牌或卡片组数据对象的形状.(class. Doesn’t have a lot of graphics logic, but it contains a list of other graphical representations of the decks and cards that exist in the associated game. It provides utility functions to find a shape that represents a card or deck data object.)DeckShape
:这是(: This is the graphical representation of the)Deck
类.根据一组规则处理其包含的卡的位置.就像垂直绘画一样,纸牌之间有固定的空间,而整个甲板则有最大的空间.(class. Handles the positioning of its contained cards according to a set of rules. Like drawing vertically and with a fixed space between cards and a maximum space for the whole deck.)CardShape
:这是(: This is the graphical representation of the)Card
类.提供卡片事件,鼠标事件以及拖放行为的动画.(class. Provide animations to card events, mouse events, and drag and drop behaviors.)
-
纸牌(Solitaire)这是纸牌游戏.它仅包含主页,并在后面的代码中包含游戏的逻辑.(This is the Solitaire game. It only contains the main page with the logic of the game in the code-behind.)
-
蜘蛛纸牌(SpiderSolitaire)这是蜘蛛纸牌游戏.它仅包含主页,并在后面的代码中包含游戏的逻辑.(This is the Spider Solitaire game. It only contains the main page with the logic of the game in the code-behind.)
未来(Future)
我正在考虑将这些库扩展为包括游戏逻辑,以促进计算机AI播放器和多人网络选项.如果有时间,我会做的,但是如果你们中的任何人都可以实现这些功能,那会让我很高兴知道.(I’m thinking of expanding these libraries to include game logic that facilitates computer AI players and multiplayer network options. I’ll do this if I have time, but if anyone of you can implement these features, that would make me very happy to know.)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C# Silverlight Dev 新闻 翻译