使用SuperSocket开发联网斗地主(四):出牌

发布时间:2022-06-22 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了使用SuperSocket开发联网斗地主(四):出牌脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

本节内容:

出牌和大牌逻辑。(昨天新发现了还有一个专门做游戏开发的框架cocos,后面学习下这个吧,这个就不更新了)

出牌逻辑:

1. 如果当前没人出牌,我是第一个,只需符合出牌条件就行;

2. 如果之前有人出牌,就要既符合出牌条件也要大住上家;

/// <summary>
/// 是否符合出牌规则
/// </summary>
/// <param name="userShowedList"></param>
/// <returns></returns>
private static bool WithRules(List<DouDiZhuGameCard> userShowedList)
{
     int userShowedCount = userShowedList.Count();
     bool can = true;
     //单牌,对子,三不带(连字需要5张及以上)
     if (userShowedCount <= 3)
     {
         DouDiZhuGameCard last = null;
         foreach (var item in userShowedList)
         {
             if (last == null || last.CardName == item.CardName)
             {
                 last = item;
             }
             else
             {
                 can = false;
                 break;
             }
         }
         return can;
     }
     //...其他的规则
     return can;
}

大牌

/// <summary>
/// 能否大过上家
/// </summary>
/// <param name="userShowedList"></param>
/// <param name="LastShowedList"></param>
/// <returns></returns>
private static bool IsBigger(List<DouDiZhuGameCard> userShowedList, List<DouDiZhuGameCard> LastShowedList)
{
     int userShowedCount = userShowedList.Count();
     int lastShowedCount = LastShowedList.Count();
     bool can = true;
     //单牌,对子,三不带(连字需要5张及以上)
     if (userShowedCount <= 3)
     {
         return userShowedList[0].CardValue > LastShowedList[0].CardValue;
     }
     //...其他的规则
     return can;
}

然后客户端需要通知其他人当前出的牌,思路是把出的牌放在底牌区域,用以展示

然后就是控制按钮的显示与隐藏等

//出牌成功

else if (result.Action == "show_ok") {

diPai = result.Data.CommonCards;

player_me = result.Data.MyCards;

shuaXinTangZi();

shuaXinShouPai();

if (result.Data.IsMyTurn)

        {

btnBox.children[0].style.display = 'none';

btnBox.children[1].style.display = 'none';

btnBox.children[2].style.display = 'none';

btnBox.children[3].style.display = 'inline-block';

btnBox.children[4].style.display = 'inline-block';

        }

else

        {

btnBox.children[0].style.display = 'none';

btnBox.children[1].style.display = 'none';

btnBox.children[2].style.display = 'none';

btnBox.children[3].style.display = 'none';

btnBox.children[4].style.display = 'none';

        }

    }

//出牌错误

else if (result.Action == "show_err") {

//startQiangDiZhu(result.Data);

    }

//公开广播信息

else if (result.Action == "pubInfo") {

pubUserInfo(PlayerMeInfo,result.Data);

    }

 

效果图:

使用SuperSocket开发联网斗地主(四):出牌

使用SuperSocket开发联网斗地主(四):出牌

使用SuperSocket开发联网斗地主(四):出牌

使用SuperSocket开发联网斗地主(四):出牌

使用SuperSocket开发联网斗地主(四):出牌

代码下载

脚本宝典总结

以上是脚本宝典为你收集整理的使用SuperSocket开发联网斗地主(四):出牌全部内容,希望文章能够帮你解决使用SuperSocket开发联网斗地主(四):出牌所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: