cocos2dx实现单机版三国杀(二)

接上续,东西还没有做完 所以代码免不了改动

之前的头文件现在又改了不少,因为架构也改变了现在主要类就是GameScene、GameUI、PlayInfo、Poker这四个类  前面想的GameLoop 已经被弃

目前除了身份、武将等相关的高级功能还没添加,基本功能只剩下 出牌策略没做了。

贴一下GameUI新的头文件

#pragma once
/*
主游戏界面UI

*/

#include "cocos2d.h"
#include "ui/CocosGUI.h"


USING_NS_CC;
class PlayInfo;
class Poker;
class GameUI:public cocos2d::Layer
{
//friend class GameScene;
public:
bool init();

virtual void onEnter();
virtual void onExit();

void menuReOpen(Ref*pSender);//重开
void menuExit(Ref*pSender);//退出游戏
void menuaddpoker(Ref*pSender);
void menuusepoker(Ref*pSender);
void menugiveuppoker(Ref*pSender);

void update(float delta);
/* 玩家摸牌 显示 */
void addPoker( int ,int);
/* 玩家使用牌(包括回合内外) 显示 */
void usePoker(int num=1);
/* 玩家弃牌 显示 */
void giveupPoker( );
/* 电脑玩家弃牌 显示*/
void giveupPoke_Robot(int );
void fun1(Ref*);
/*弃牌堆的更新*/
void Updategiveupheap();

扫描二维码关注公众号,回复: 1869891 查看本文章

CREATE_FUNC(GameUI);

//初始化角色信息
void initRoleInfo(PlayInfo* player);
//更新角色信息(显示)
void UpdateRoleInfo(PlayInfo*player);

//初始化对手信息
void initFoeInfo(PlayInfo* player);
//更新对手信息(显示)
void UpdatFoeInfo(PlayInfo*player);

Label*CurrenState;
bool isAddPoker;
void CountDown(float dt=5.0f);//倒计时函数实现延时功能
void setTimeBarwithtime(float );
bool isCountDown;//是否在读条 即调用了CountDown 
bool isEndUsePokeState;//是否结束出牌阶段

void SwapTimeBar();//交换当前回合的时间读条指针,令当前回合进行读条的Loadingbar 指针指向play的时间读条指针

void UpdateShowPokerSlot(PlayInfo*);//更新手牌槽,外部调用
void DrawShowPokerSlot();//绘制手牌槽的牌
void addgiveupheap(Poker*);//添加牌到弃牌堆
private:
std::vector<Poker*>showpokerslot;//玩家需要显示的手牌槽
std::vector<int>showIntslot;
std::vector<Poker*>giveupPokerHeap;//弃牌堆
Sprite*bg;//背景图片
Sprite*equipment;//装备栏图片
Sprite*pokerSlot;//手牌槽背景图片
Sprite*rolePicInfo;//角色ui图片信息
//Vector<Sprite*>roleHealthInfo;

Sprite*foeInfoShow;

ui::LoadingBar* timebar;
ui::LoadingBar* timebarRobot;

Label* timelabel;

Label*_showOurPokerNums;
Label*_showFoePokerNums;


};

 ------------------------------

虽然还有很多坑,但是基本流程是完成了

暂时放下来,有时间再填坑

https://github.com/huzhongyidihao/sanguosha

搬运自:https://www.cnblogs.com/yuedongdeguangzi/p/8668870.html


 

猜你喜欢

转载自blog.csdn.net/qq_25019777/article/details/80908141