Skip to content

Commit

Permalink
update 2108081541
Browse files Browse the repository at this point in the history
  • Loading branch information
ErLinErYi committed Aug 8, 2021
1 parent fec357b commit 242461f
Show file tree
Hide file tree
Showing 75 changed files with 1,093 additions and 511 deletions.
2 changes: 1 addition & 1 deletion PlantsVsZombies/Classes/Based/LZAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "cocos2d.h"

#define LZPVZNAME "PlantsVsZombies_1.3.3.0 beta(2021.07.10)"
#define LZPVZNAME "PlantsVsZombies_1.3.3.5 (2021.08.10)"

extern GUID scheme_default;
/**
Expand Down
5 changes: 2 additions & 3 deletions PlantsVsZombies/Classes/Based/LZCar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Car::Car(Node* node) :
_tag(-1),
_row(-1),
_carState(1),
_scale(0),
_scale(1),
_node(node),
_carType(CarType::null),
_global(Global::getInstance())
Expand Down Expand Up @@ -179,8 +179,7 @@ void Car::deleteCar(list<Car*>::iterator& car)
void Car::createCarShadow()
{
auto shadow = Sprite::createWithSpriteFrameName("plantshadow.png");
shadow->setScaleX(4.0f);
shadow->setScaleY(3.0f);
shadow->setScale(_carImage->getScale() * 3);
shadow->setPosition(Vec2(120, 30));
_carImage->addChild(shadow, -1);
}
Expand Down
94 changes: 93 additions & 1 deletion PlantsVsZombies/Classes/Based/LZDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
*/

#include "Based/LZDialog.h"
#include "Based/LZPlayMusic.h"

Dialog::Dialog():
_shieldListener(nullptr),
_mouseListener(nullptr),
_dialog(nullptr),
_phasePosition(Vec2::ZERO),
_global(Global::getInstance())
{
Expand All @@ -18,14 +20,99 @@ Dialog::~Dialog()
{
}

bool Dialog::init()
{
if (!LayerColor::initWithColor(Color4B(0, 0, 0, 180)))return false;

createShieldLayer(this);
createDialog();

return true;
}

void Dialog::createDialog()
{
_dialog = Sprite::createWithSpriteFrameName("LevelObjiectives.png");
_dialog->setPosition(Director::getInstance()->getWinSize() / 2);
_dialog->setScale(1.5f);
this->addChild(_dialog);

/* 创建触摸监听 */
createTouchtListener(_dialog);
}

void Dialog::createButtons(string name, float position, int id)
{
auto button = Button::create("ButtonNew.png", "ButtonNew2.png", "", cocos2d::ui::Widget::TextureResType::PLIST);
auto label = Label::createWithTTF(_global->userInformation->getGameText().find(name)->second->text,
GAME_FONT_NAME_1, _global->userInformation->getGameText().find(name)->second->fontsize);
label->enableShadow(Color4B(0, 0, 0, 200));//设置阴影
label->setScale(3.5f);
button->setTitleLabel(label);
button->setPosition(Vec2(position, 10));
button->setScale(0.25f);
_dialog->addChild(button);

button->addTouchEventListener([=](Ref* sender, Widget::TouchEventType type)
{
switch (type)
{
case Widget::TouchEventType::ENDED:
PlayMusic::playMusic("gravebutton");
if (id == 0)
{
selectButtonCallBack(true);
}
else
{
selectButtonCallBack(false);
deleteDialog();
}
break;
}
});
}

void Dialog::getData(const std::function<void(bool flag)>& pSelector)
{
selectButtonCallBack = pSelector;
}

void Dialog::createText()
{
auto str = _global->userInformation->getGameText().find("确认操作")->second;
auto information = Text::create(str->text, GAME_FONT_NAME_1, str->fontsize);
information->setColor(Color3B::RED);
information->setTextVerticalAlignment(TextVAlignment::CENTER);
information->setTextHorizontalAlignment(TextHAlignment::CENTER);
information->setTextAreaSize(Size(_dialog->getContentSize().width - 90, 70));
information->setPosition(Vec2(_dialog->getContentSize().width / 2.0f, _dialog->getContentSize().height / 2.0f + 80));
_dialog->addChild(information);

auto information1 = Text::create(_strText, GAME_FONT_NAME_1, 30);
information1->setColor(Color3B::RED);
information1->setPosition(Vec2(_dialog->getContentSize().width / 2.0f, _dialog->getContentSize().height / 2.0f));
_dialog->addChild(information1);
}

void Dialog::setString(string str)
{
_strText = str;

createText();
}

void Dialog::setMouseListener(EventListenerMouse* listener)
{
_mouseListener = listener;
}

void Dialog::setMouseListenerEnable(bool isEnable)
{
_mouseListener->setEnabled(isEnable);
if (_mouseListener)
{
_mouseListener->setEnabled(isEnable);
}
}

EventListenerTouchOneByOne* Dialog::createTouchtListener(Sprite* sprite)
Expand Down Expand Up @@ -119,3 +206,8 @@ void Dialog::createShieldLayer(Node* node)
_shieldListener->setSwallowTouches(true);
_eventDispatcher->addEventListenerWithSceneGraphPriority(_shieldListener, node);
}

void Dialog::deleteDialog()
{
this->removeFromParent();
}
44 changes: 43 additions & 1 deletion PlantsVsZombies/Classes/Based/LZDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ using namespace cocos2d::experimental;
class Dialog :public LayerColor
{
public:
CREATE_FUNC(Dialog);
/**
*创建触摸监听
*/
Expand All @@ -38,6 +39,21 @@ class Dialog :public LayerColor
*/
virtual void setMouseListener(EventListenerMouse* listener);

/**
* 设置文本
*/
virtual void setString(string str);

/**
* 创建按钮
*/
virtual void createButtons(string name, float position, int id);

/**
* 获取返回值
*/
virtual void getData(const std::function<void(bool flag)>& pSelector);

protected:
/**
*创建标签
Expand All @@ -59,22 +75,48 @@ class Dialog :public LayerColor
/**
*删除层
*/
virtual void deleteDialog(){}
virtual void deleteDialog();

/**
*设置鼠标监听是否可用
*/
virtual void setMouseListenerEnable(bool isEnable = true);

/**
* 创建对话框
*/
virtual void createDialog();


virtual void createText();

CC_CONSTRUCTOR_ACCESS:
Dialog();
~Dialog();
virtual bool init() override;

protected:
Global* _global;
EventListenerMouse* _mouseListener;
Sprite* _dialog;
string _strText;
std::function<void(bool flag)> selectButtonCallBack;

private:
Vec2 _phasePosition; /* 相差位置 */
EventListenerTouchOneByOne* _shieldListener;
};

#define CREATEDIALOG(__DATA__) \
Dialog* dia = Dialog::create(); \
dia->setString(_global->userInformation->getGameText().find("确认说明")->second->text); \
dia->createButtons("确认", 150, 0); \
dia->createButtons("取消", 380, 1); \
dia->getData([this](bool flag) \
{ \
if (flag) \
{ \
__DATA__ \
} \
}); \
this->addChild(dia);
6 changes: 3 additions & 3 deletions PlantsVsZombies/Classes/Based/LZUserData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#endif // !DLLTEST

UserData* UserData::_instance = nullptr;
int UserData::_levelDataVersion = 1315;
int UserData::_levelDataVersion = 1330;

UserData::UserData() :
_global(Global::getInstance())
Expand Down Expand Up @@ -670,7 +670,7 @@ void UserData::caveLevelSelectPlantsData(char* key)

object.AddMember("CardTag", card.cardTag, allocator);
object.AddMember("Percent", buttonLayerInformation->plantsCards[card.cardTag].progressTimer->getPercentage(), allocator);
object.AddMember("LastTime", buttonLayerInformation->plantsCards[card.cardTag].progressTimer->getPercentage() / 100.f * plantsCardInformation[card.cardTag].plantsCoolTime, allocator);
object.AddMember("LastTime", buttonLayerInformation->plantsCards[card.cardTag].progressTimer->getPercentage() / 100.f * buttonLayerInformation->plantsCards[card.cardTag].plantsCoolTime, allocator);

(*_levelDataDocument)[key]["SelectPlants"].AddMember(numberToString(++plantsNumber, allocator), object, _levelDataDocument->GetAllocator());
}
Expand Down Expand Up @@ -778,7 +778,7 @@ void UserData::openLevelPlantsData(char* key)
plants->getPlantAnimation()->getChildByName("BufEffect")->setOpacity(0);

plants->setPlantOtherInformation(_levelDataDocument, key, i);
PlantsGroup.insert(pair<int, Plants*>((*_levelDataDocument)[key]["Plants"][to_string(i).c_str()]["PlantsTag"].GetInt(), plants));
PlantsGroup.insert(pair<int, Plants*>(plants->getPlantAnimation()->getTag(), plants));

if (type != PlantsType::Pumpkin)
{
Expand Down
14 changes: 10 additions & 4 deletions PlantsVsZombies/Classes/Based/LZUserInformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ int UserInformation::getUserCaveFileNumber() const
return _userCaveFileNumber;
}

int& UserInformation::getKillZombiesNumbers()
int UserInformation::getKillZombiesNumbers()
{
return _killZombiesNumbers;
return _killZombiesNumbers ^ _encryptKZKey;
}

int& UserInformation::getUsePlantsNumbers()
Expand All @@ -196,12 +196,12 @@ int& UserInformation::getBreakThroughNumbers()

int UserInformation::getSunNumbers() const
{
return _sunNumbers;
return _sunNumbers ^ _encryptSNKey;
}

int UserInformation::getCoinNumbers() const
{
return _coinNumbers;
return _coinNumbers ^ _encryptCNKey;
}

int UserInformation::getFps() const
Expand Down Expand Up @@ -365,6 +365,8 @@ void UserInformation::setUserCaveFileNumber(const int number)
void UserInformation::setKillZombiesNumbers(const int number)
{
number <= 999999999 ? _killZombiesNumbers = number : _killZombiesNumbers = 999999999;
_encryptKZKey = rand();
_killZombiesNumbers ^= _encryptKZKey;
}

void UserInformation::setUsePlantsNumbers(const int number)
Expand All @@ -380,11 +382,15 @@ void UserInformation::setBreakThroughNumbers(const int number)
void UserInformation::setSunNumbers(const int number)
{
number <= 999999 ? _sunNumbers = number : _sunNumbers = 999999;
_encryptSNKey = rand();
_sunNumbers ^= _encryptSNKey;
}

void UserInformation::setCoinNumbers(const int number)
{
number <= 999999999 ? _coinNumbers = number : _coinNumbers = 999999999;
_encryptCNKey = rand();
_coinNumbers ^= _encryptCNKey;
}

void UserInformation::setFps(const int fps)
Expand Down
6 changes: 5 additions & 1 deletion PlantsVsZombies/Classes/Based/LZUserInformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class UserInformation
float getSoundEffectVolume() const;
float getBackGroundMusicVolume() const;
int getUserCaveFileNumber() const;
int& getKillZombiesNumbers();
int getKillZombiesNumbers();
int& getUsePlantsNumbers();
int& getBreakThroughNumbers();
int getSunNumbers() const;
Expand Down Expand Up @@ -179,6 +179,10 @@ class UserInformation

int _userCaveFileNumber; // 用户游戏存档编号

int _encryptKZKey; // 加密
int _encryptSNKey; // 加密
int _encryptCNKey; // 加密

int _killZombiesNumbers; // 杀死僵尸总数
int _usePlantsNumbers; // 使用植物数量
int _breakThroughNumbers; // 闯关失败次数
Expand Down
Loading

0 comments on commit 242461f

Please sign in to comment.