Skip to content

Commit

Permalink
update 0613
Browse files Browse the repository at this point in the history
  • Loading branch information
ErLinErYi committed Jun 13, 2020
1 parent 546e3ab commit fba9173
Show file tree
Hide file tree
Showing 19 changed files with 181 additions and 55 deletions.
4 changes: 2 additions & 2 deletions PlantsVsZombies/Classes/Based/AppDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ bool AppDelegate::applicationDidFinishLaunching()
if(!glview)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
glview = GLViewImpl::createWithRect("PlantsVsZombies_1.1.9.3 (2020.05.12)", cocos2d::Rect(0, 0, designResolutionSize.width, designResolutionSize.height));
glview = GLViewImpl::createWithRect("PlantsVsZombies_1.1.9.4 (2020.05.15)", cocos2d::Rect(0, 0, designResolutionSize.width, designResolutionSize.height));
#else
glview = GLViewImpl::create("PlantsVsZombies_1.1.9.3 (2020.05.12)");
glview = GLViewImpl::create("PlantsVsZombies_1.1.9.4 (2020.05.15)");
#endif
director->setOpenGLView(glview);
}
Expand Down
40 changes: 33 additions & 7 deletions PlantsVsZombies/Classes/Based/UserInformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
*Author : LZ
*Date: 2020.2.20
*Email: [email protected]
*1.1.9.4
*/

#include "UserInformation.h"
#include "GlobalVariable.h"

const string UserInformation::_clientEdition = "9.9.9.9";
string UserInformation::_editionName = "";
bool UserInformation::_updateRequired = false;
DWORD UserInformation::_screenDisplayFrequency = 0;

UserInformation::UserInformation():
_isUpdate(false)
, _userName("·ßÅ­µÄС½©Ê¬")
, _userCaveFileNameKey{ "USERNAMEDATA","USERNAMEDATA_2","USERNAMEDATA_3","USERNAMEDATA_4","USERNAMEDATA_5","USERNAMEDATA_6","USERNAMEDATA_7","USERNAMEDATA_8" }
, _systemCaveFileName_difficult{ "WORLD_%d_LEVELS","WORLD_%d_LEVELS_2","WORLD_%d_LEVELS_3","WORLD_%d_LEVELS_4","WORLD_%d_LEVELS_5","WORLD_%d_LEVELS_6","WORLD_%d_LEVELS_7","WORLD_%d_LEVELS_8" }
, _systemCaveFileName{ "WORLD_%d_LEVELS_DIF","WORLD_%d_LEVELS_2_DIF","WORLD_%d_LEVELS_3_DIF","WORLD_%d_LEVELS_4_DIF","WORLD_%d_LEVELS_5_DIF","WORLD_%d_LEVELS_6_DIF","WORLD_%d_LEVELS_7_DIF","WORLD_%d_LEVELS_8_DIF" }
, _userName("")
, _soundEffectVolume(0.5f)
, _backGroundMusicVolume(0.2f)
, _userCaveFileNumber(0)
Expand All @@ -40,6 +40,16 @@ UserInformation::UserInformation():
, _stretchingShow(CheckBox::EventType::SELECTED)
, _selectWorldName(WorldName::Mordern)
{
string keyName[] = { "USERNAMEDATA","USERNAMEDATA_2","USERNAMEDATA_3","USERNAMEDATA_4","USERNAMEDATA_5","USERNAMEDATA_6","USERNAMEDATA_7","USERNAMEDATA_8" };
string fileName[] = { "WORLD_%d_LEVELS","WORLD_%d_LEVELS_2","WORLD_%d_LEVELS_3","WORLD_%d_LEVELS_4","WORLD_%d_LEVELS_5","WORLD_%d_LEVELS_6","WORLD_%d_LEVELS_7","WORLD_%d_LEVELS_8" };
string dfileName[] = { "WORLD_%d_LEVELS_DIF","WORLD_%d_LEVELS_2_DIF","WORLD_%d_LEVELS_3_DIF","WORLD_%d_LEVELS_4_DIF","WORLD_%d_LEVELS_5_DIF","WORLD_%d_LEVELS_6_DIF","WORLD_%d_LEVELS_7_DIF","WORLD_%d_LEVELS_8_DIF" };

for (int i = 0; i < 8; ++i)
{
_userCaveFileNameKey[i] = keyName[i];
_systemCaveFileName_difficult[i] = fileName[i];
_systemCaveFileName[i] = dfileName[i];
}
}

UserInformation::~UserInformation()
Expand Down Expand Up @@ -87,6 +97,11 @@ CheckBox::EventType UserInformation::getIsEaseAnimation() const
return _easeAnimation;
}

CheckBox::EventType UserInformation::getIsVerticalSynchronization() const
{
return _verticalSynchronization;
}

map<string, spSkeletonData*>& UserInformation::getAnimationData()
{
return _animationData;
Expand Down Expand Up @@ -282,9 +297,15 @@ void UserInformation::setUpdateRequired(const bool updateRequired)

DWORD UserInformation::getScreenDisplayFrequency()
{
DEVMODE dm;
::EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm);
return dm.dmDisplayFrequency;
if (!_screenDisplayFrequency ||
Global::getInstance()->userInformation->getIsSelectFullScreen() == cocos2d::ui::CheckBox::EventType::UNSELECTED)
{
DEVMODE dm;
dm.dmSize = sizeof(DEVMODE);
::EnumDisplaySettings(nullptr, ENUM_CURRENT_SETTINGS, &dm);
_screenDisplayFrequency = dm.dmDisplayFrequency;
}
return _screenDisplayFrequency;
}

void UserInformation::setGameDifficulty(const int difficulty)
Expand Down Expand Up @@ -429,6 +450,11 @@ void UserInformation::setIsEaseAnimation(CheckBox::EventType easeAnimation)
_easeAnimation = easeAnimation;
}

void UserInformation::setIsVerticalSynchronization(CheckBox::EventType verticalSynchronization)
{
_verticalSynchronization = verticalSynchronization;
}

void UserInformation::setIsMirrorScene(const bool isMirror)
{
_isMirrorScene = isMirror;
Expand Down
4 changes: 4 additions & 0 deletions PlantsVsZombies/Classes/Based/UserInformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class UserInformation
CheckBox::EventType getIsSelectCursorNotHide() const;
CheckBox::EventType getIsSelectStretchingShow() const;
CheckBox::EventType getIsEaseAnimation() const;
CheckBox::EventType getIsVerticalSynchronization() const;
map<string, spSkeletonData*>& getAnimationData();
map<string, string>& getGameText();
map<string, string>& getImagePath();
Expand Down Expand Up @@ -114,6 +115,7 @@ class UserInformation
void setIsSelectHighFPS(CheckBox::EventType isSelect);
void setIsShowInformation(CheckBox::EventType isShow);
void setIsEaseAnimation(CheckBox::EventType easeAnimation);
void setIsVerticalSynchronization(CheckBox::EventType verticalSynchronization);
void setIsMirrorScene(const bool isMirror);
void setIsReadFileData(const bool isRead);
bool getIsReadFileData() const;
Expand Down Expand Up @@ -144,6 +146,7 @@ class UserInformation
CheckBox::EventType _cursorNotHide; // 鼠标隐藏
CheckBox::EventType _stretchingShow; // 拉伸显示
CheckBox::EventType _easeAnimation; // 缓入动画
CheckBox::EventType _verticalSynchronization; // 垂直同步

map<string, spSkeletonData*> _animationData; // 动画存储
map<string, string> _gameText; // 游戏文本
Expand Down Expand Up @@ -186,4 +189,5 @@ class UserInformation
const static string _clientEdition; // 当前客户端版本
static string _editionName; // 版本名称
static bool _updateRequired; // 是否需要更新
static DWORD _screenDisplayFrequency; // 屏幕刷新率
};
3 changes: 1 addition & 2 deletions PlantsVsZombies/Classes/Plants/BattlePlants/CherryBomb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ void CherryBomb::explodeHurtZombies()
if (!zombie->getZombieIsSurvive())
{
zombie->setZombieOpacity(0);
zombie->playZombiesDieAnimation(
zombie->getZombieType() == ZombiesType::LmpZombies ? "LmpZombies_Charre" : "Zombies_Ash");
zombie->playZombiesDieAnimation();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void GSPauseQuitLayer::createDialog()
auto check2 = createCheckBox(Vec2(350, 310), Vec2(150, 310), _global->userInformation->getGameText().find("高帧率")->second, OptionScene_CheckBox::高帧率, "CheckBox2", "CheckBox", true);
auto check3 = createCheckBox(Vec2(800, 310), Vec2(600, 310), _global->userInformation->getGameText().find("鼠标显示")->second, OptionScene_CheckBox::鼠标隐藏, "CheckBox2", "CheckBox", true);
auto check4 = createCheckBox(Vec2(350, 240), Vec2(150, 240), _global->userInformation->getGameText().find("拉伸显示")->second, OptionScene_CheckBox::拉伸显示, "CheckBox2", "CheckBox", true);
auto check5 = createCheckBox(Vec2(800, 240), Vec2(600, 240), _global->userInformation->getGameText().find("缓入动画")->second, OptionScene_CheckBox::缓入动画, "CheckBox2", "CheckBox", true);
auto check5 = createCheckBox(Vec2(800, 240), Vec2(600, 240), _global->userInformation->getGameText().find("垂直同步")->second, OptionScene_CheckBox::垂直同步, "CheckBox2", "CheckBox", true);

check->setScale(0.6f);
check1->setScale(0.6f);
Expand Down
56 changes: 38 additions & 18 deletions PlantsVsZombies/Classes/Scenes/LoadingScene/LoadingScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
*Emal: [email protected]
*/

#include "Based/LevelData.h"
#include "LoadingScene.h"
#include "tinyxml2/tinyxml2.h"
#include "Based/LevelData.h"
#include "Based/UserInformation.h"
#include "Based/PlayMusic.h"
#include "AudioEngine.h"
Expand Down Expand Up @@ -72,9 +72,6 @@ void LoadingScene::loadUserData()
{
auto userdefault = UserDefault::getInstance();

_userData->createNewUserDataDocument();
loadUserFileData();

/* 读取用户存档名称 */
for (int i = 0; i < 8; i++)
{
Expand All @@ -92,6 +89,9 @@ void LoadingScene::loadUserData()
_global->userInformation->setUserName(_global->userInformation->getUserCaveFileName(_global->userInformation->getUserCaveFileNumber()));
_global->userInformation->setIsUpdate(true);

_userData->createNewUserDataDocument();
loadUserFileData();

/* 显示信息 */
switch (userdefault->getBoolForKey("SHOWINFORMATION"))
{
Expand All @@ -105,31 +105,29 @@ void LoadingScene::loadUserData()
break;
}

/* 是否全屏 */
switch (userdefault->getBoolForKey("SHOWFULLSCREEN"))
/* 是否高帧率 */
switch (userdefault->getBoolForKey("SHOWHIGHFPS"))
{
case true:
((GLViewImpl*)_director->getOpenGLView())->setFullscreen();
_global->userInformation->setIsSelectFullScreen(cocos2d::ui::CheckBox::EventType::SELECTED);
_director->setAnimationInterval(1.0f / UserInformation::getScreenDisplayFrequency());
_global->userInformation->setIsSelectHighFPS(cocos2d::ui::CheckBox::EventType::SELECTED);
break;
case false:
((GLViewImpl*)_director->getOpenGLView())->setWindowed(1280, 720);
_global->userInformation->setIsSelectFullScreen(cocos2d::ui::CheckBox::EventType::UNSELECTED);
_director->setAnimationInterval(1.0f / 45);
_global->userInformation->setIsSelectHighFPS(cocos2d::ui::CheckBox::EventType::UNSELECTED);
break;
}

/* 是否高帧率 */
switch (userdefault->getBoolForKey("SHOWHIGHFPS"))
/* 是否全屏 */
switch (userdefault->getBoolForKey("SHOWFULLSCREEN"))
{
case true:
_director->setAnimationInterval(1.0f / UserInformation::getScreenDisplayFrequency());
_global->userInformation->setIsSelectHighFPS(cocos2d::ui::CheckBox::EventType::SELECTED);
_global->userInformation->setFps(60);
((GLViewImpl*)_director->getOpenGLView())->setFullscreen();
_global->userInformation->setIsSelectFullScreen(cocos2d::ui::CheckBox::EventType::SELECTED);
break;
case false:
_director->setAnimationInterval(1.0f / 45);
_global->userInformation->setIsSelectHighFPS(cocos2d::ui::CheckBox::EventType::UNSELECTED);
_global->userInformation->setFps(45);
((GLViewImpl*)_director->getOpenGLView())->setWindowed(1280, 720);
_global->userInformation->setIsSelectFullScreen(cocos2d::ui::CheckBox::EventType::UNSELECTED);
break;
}

Expand All @@ -146,6 +144,19 @@ void LoadingScene::loadUserData()
break;
}

/* 是否垂直同步 */
switch (userdefault->getBoolForKey("VERTICALSYNCHRONIZATION"))
{
case true:
wglSwapIntervalEXT(1);
_global->userInformation->setIsVerticalSynchronization(CheckBox::EventType::SELECTED);
break;
case false:
_global->userInformation->setIsVerticalSynchronization(CheckBox::EventType::UNSELECTED);
wglSwapIntervalEXT(0);
break;
}

/* 是否隐藏鼠标 */
_global->userInformation->setIsSelectCursorNotHide(_userData->openBoolUserData("CURSORHIDE") ?
cocos2d::ui::CheckBox::EventType::SELECTED : cocos2d::ui::CheckBox::EventType::UNSELECTED);
Expand All @@ -157,6 +168,15 @@ void LoadingScene::loadUserData()

void LoadingScene::loadUserFileData()
{
if (Global::getInstance()->userInformation->getUserName() == "未命名存档")
{
UserDefault::getInstance()->setFloatForKey("SOUNDEFFECT", 0.5f);
UserDefault::getInstance()->setFloatForKey("GLOBALMUSIC", 0.2f);
UserDefault::getInstance()->setBoolForKey("SHOWFULLSCREEN", true);
UserDefault::getInstance()->setBoolForKey("SHOWHIGHFPS", true);
UserDefault::getInstance()->setBoolForKey("SHOWINFORMATION", true);
}

Global::getInstance()->userInformation->setUserCaveFileNumber(UserDefault::getInstance()->getIntegerForKey("USERDATANUMBER")); /* 存档编号 */
Global::getInstance()->userInformation->setSoundEffectVolume(UserDefault::getInstance()->getFloatForKey("SOUNDEFFECT")); /* 音效 */
Global::getInstance()->userInformation->setBackGroundMusicVolume(UserDefault::getInstance()->getFloatForKey("GLOBALMUSIC")); /* 音乐 */
Expand Down
40 changes: 28 additions & 12 deletions PlantsVsZombies/Classes/Scenes/MainMenuScene/InputDataScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ bool InputDataMenu::init()

Dialog::createShieldLayer(this);

this->createDialog();
createDialog();
inputNewFileDataName();

return true;
}
Expand Down Expand Up @@ -74,12 +75,12 @@ void InputDataMenu::createDialog()
if (_global->userInformation->getUserCaveFileNumber() == -1)
{
_caveFileNumber = UserData::getInstance()->openIntUserData("USERDATANUMBER");
_dataButton.find(_caveFileNumber)->second->setColor(Color3B::YELLOW);
_dataButton.find(_caveFileNumber)->second->setColor(Color3B(0, 255, 255));
}
else
{
_caveFileNumber = _global->userInformation->getUserCaveFileNumber();
_dataButton.find(_caveFileNumber)->second->setColor(Color3B::YELLOW);
_dataButton.find(_caveFileNumber)->second->setColor(Color3B(0, 255, 255));
}

/* 创建按钮 */
Expand Down Expand Up @@ -111,7 +112,7 @@ void InputDataMenu::CreateInputDialog()
_inputDataDialog->addChild(_inputCursor);
_inputCursor->runAction(RepeatForever::create(Sequence::create(FadeOut::create(0.25f), FadeIn::create(0.25f), nullptr)));

_textField = TextField::create("点击此处进行输入",GAME_FONT_NAME_1, FontSize);
_textField = TextField::create("点击此处输入存档名称",GAME_FONT_NAME_1, FontSize);
_inputDataDialog->addChild(_textField);
_textField->setPosition(Vec2(155, 137));
_textField->setMaxLengthEnabled(true);
Expand All @@ -125,7 +126,7 @@ void InputDataMenu::CreateInputDialog()
_inputCursor->setVisible(true);
break;
case cocos2d::ui::TextField::EventType::DETACH_WITH_IME:
_textField->setPlaceHolder("点击此处进行输入");
_textField->setPlaceHolder("点击此处进行输入存档名称");
_inputCursor->setVisible(false);
break;
case cocos2d::ui::TextField::EventType::INSERT_TEXT:
Expand Down Expand Up @@ -189,14 +190,21 @@ void InputDataMenu::createButtons(Sprite* sprite, const std::string &Label, Vec2
switch (ID)
{
case 1: /* 确定 */
caveData();
updateButtonText();
this->removeChildByName("_shieldDialogLayer");
_inputString.clear();
if (!_textField->getString().empty() &&
_textField->getString() != "未命名存档")
{
caveData();
updateButtonText();
this->removeChildByName("_shieldDialogLayer");
_inputString.clear();
}
break;
case 2: /* 取消 */
this->removeChildByName("_shieldDialogLayer");
_inputString.clear();
if (_global->userInformation->getUserName() != "未命名存档")
{
this->removeChildByName("_shieldDialogLayer");
_inputString.clear();
}
break;
case 3:
UserDefault::getInstance()->setIntegerForKey("USERDATANUMBER", _caveFileNumber); /* 记录所选存档 */
Expand Down Expand Up @@ -288,7 +296,7 @@ void InputDataMenu::setButtonColor(Button* button)
{
sp.second->setColor(Color3B::WHITE);
}
button->setColor(Color3B::YELLOW);
button->setColor(Color3B(0, 255, 255));
}

void InputDataMenu::setButtonText(Button* button, const string& text, const float& scale)
Expand Down Expand Up @@ -322,6 +330,14 @@ void InputDataMenu::updateButtonText()
}
}

void InputDataMenu::inputNewFileDataName()
{
if (_global->userInformation->getUserName() == "未命名存档")
{
createShieldLayer();
}
}

Label* InputDataMenu::onTextFieldInsertText()
{
auto textLabel = Label::createWithTTF(_newInputstring, GAME_FONT_NAME_1, FontSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class InputDataMenu :public Dialog
void setButtonText(Button* button, const string& text, const float& scale);
void caveData();
void updateButtonText();
void inputNewFileDataName();
Label* onTextFieldInsertText();
Label* onTextFieldDeleteBackward();

Expand Down
9 changes: 9 additions & 0 deletions PlantsVsZombies/Classes/Scenes/MainMenuScene/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ bool MainMenu::init()
this->createMainButton(); /* 创建按钮 */
this->schedule(schedule_selector(MainMenu::curUpdate), 0.05f);/* 定时器 */

createNewUserDataFileName();
#if MYRELEASE
# if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
if (UserInformation::getUpdateRequired())
Expand Down Expand Up @@ -172,6 +173,14 @@ void MainMenu::playMusicBleepInMainButtons(int ID, const Vec2& vec2)
}
}

void MainMenu::createNewUserDataFileName()
{
if (_global->userInformation->getUserName() == "未命名存档")
{
menuDataCallBack(nullptr);
}
}

MainMenu::MainMenuButton MainMenu::checkCurInButtons()
{
/* 检测鼠标的位置是否在按钮上 */
Expand Down
1 change: 1 addition & 0 deletions PlantsVsZombies/Classes/Scenes/MainMenuScene/MainMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class MainMenu :public Scene
void setCloudPosition(Node* node, int ID, const Vec2& vec2); /* 设置云的位置 */
void playMusicBleepInGameButtons(MainMenuButton ID); /* 播放音乐 */
void playMusicBleepInMainButtons(int ID, const Vec2& vec2);
void createNewUserDataFileName(); /* 创建新存档名称*/

/*游戏选择函数*/
void beginAdventureGame(); /* 冒险模式 */
Expand Down
Loading

0 comments on commit fba9173

Please sign in to comment.