From 9bca2747fc961614b441b8d9c8a01152c9d0f32c Mon Sep 17 00:00:00 2001 From: renfei147 Date: Tue, 28 Jun 2016 15:51:55 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=87=A0?= =?UTF-8?q?=E4=B8=AA=E9=87=8D=E8=A6=81=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/GameScene.cpp | 28 +++++++++++++++------------- Classes/PvoGameScene.cpp | 1 + Server/Server/src/Room.js | 4 +++- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Classes/GameScene.cpp b/Classes/GameScene.cpp index 3daf25f..2fd0370 100644 --- a/Classes/GameScene.cpp +++ b/Classes/GameScene.cpp @@ -225,7 +225,7 @@ Sprite* GameScene::createSpriteByChessman(Chessman type) bool GameScene::ejectorTouchBeganCallback(Touch * touch, Event * event) { - if (controllable) { + if (controllable && state != ActionState::moving) { //遍历当前边的发射器 for (int i = 0; i < (turn == left ? lCol : rCol); i++) { //判断鼠标是否处于发射器内(45°倾斜的正方形) @@ -387,22 +387,24 @@ void GameScene::endMoving() break; } } - - if (controllable) { - if (touching && totalMovements < maxMovementTimes) { - scheduleOnce(CC_CALLBACK_0(GameScene::beginMoving, this, movingCol), movingCooling, "cool"); - state = ActionState::cooling; + if (lastChessman == Chessman::flip && controllable) { + changeTurn(); + } + else { + if (controllable) { + if (touching && totalMovements < maxMovementTimes) { + scheduleOnce(CC_CALLBACK_0(GameScene::beginMoving, this, movingCol), movingCooling, "cool"); + state = ActionState::cooling; + } + else { + changeTurnAndSetTurnFlag(); + } } else { - changeTurn(); - if (lastChessman != Chessman::flip) { - setTurnFlag(); - } + state = ActionState::nothing; } } - else { - state = ActionState::nothing; - } + } void GameScene::setTurn(Side turn) diff --git a/Classes/PvoGameScene.cpp b/Classes/PvoGameScene.cpp index cb0f104..d119807 100644 --- a/Classes/PvoGameScene.cpp +++ b/Classes/PvoGameScene.cpp @@ -145,6 +145,7 @@ void PvoGameScene::onStart(SIOClient * client, const std::string & data) Json j(data); if (j.getInt("side") == right) { setTurn(right); + setTurnFlag(); controllable = false; } else { diff --git a/Server/Server/src/Room.js b/Server/Server/src/Room.js index 61463c3..a84aeb3 100644 --- a/Server/Server/src/Room.js +++ b/Server/Server/src/Room.js @@ -115,7 +115,6 @@ Room.prototype.createAndTellNextChessman = function () { this.nextChessman = this.getRandomChessman(); this.leftPlayer.emit('nextChessman', { chessman: this.nextChessman }); this.rightPlayer.emit('nextChessman', { chessman: this.nextChessman }); - console.log('told'); } Room.prototype.getRandomChessman = function () { @@ -200,6 +199,9 @@ Room.prototype.move = function (col, chessman) { break; } } + if (lastChessman == Chessman.flip) { + this.totalMovementTimes = config.maxMovementTimes; + } return false; } From 623b53166c30c6126453bbc495a44305e5ba7e71 Mon Sep 17 00:00:00 2001 From: renfei147 Date: Tue, 28 Jun 2016 22:00:44 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86AI=E6=97=A0?= =?UTF-8?q?=E8=A7=86=E6=8E=A8=E5=87=BA=E7=BF=BB=E8=BD=AC=E7=90=83=E5=90=8E?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E5=86=8D=E6=8E=A8=E9=99=90=E5=88=B6=E8=80=8C?= =?UTF-8?q?=E4=BA=A7=E7=94=9F=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/PvaGameScene.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Classes/PvaGameScene.cpp b/Classes/PvaGameScene.cpp index a73bb7a..b4f35a8 100644 --- a/Classes/PvaGameScene.cpp +++ b/Classes/PvaGameScene.cpp @@ -25,6 +25,9 @@ void PvaGameScene::endMoving() GameScene::endMoving(); if (originalTurn == right) { if (AIMovementTimes > 0) { + if (chessmen[lCol - 1][movingCol] == Chessman::flip) { + AIMovementTimes = 1; + } AIMovementTimes--; scheduleOnce([this](float) {beginMoving(movingCol); }, movingCooling, "cool"); } From bfedd41b66527405ef6a0961bd06ea0ed4ccf0f7 Mon Sep 17 00:00:00 2001 From: renfei147 Date: Wed, 29 Jun 2016 16:09:41 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E7=BB=A7=E7=BB=AD=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=87=A0=E4=B8=AA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/GameDefinitions.h | 2 +- Classes/GameScene.cpp | 20 +++++++++++--------- Classes/PvaGameScene.cpp | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Classes/GameDefinitions.h b/Classes/GameDefinitions.h index 422d95e..db4708a 100644 --- a/Classes/GameDefinitions.h +++ b/Classes/GameDefinitions.h @@ -7,7 +7,7 @@ const int maxMovementTimes = 5;//最大移动数量 const int timeLimit = 20;//超时时间 const float boardScaleTime = 0.2f;//缩放动画时间 -const float boardFilpTime = 0.8f;//翻转动画时间 +const float boardFilpTime = 0.5f;//翻转动画时间 const float nextChessmanChangeTime = 0.5f;//切换下一个棋子提示的时间 enum Side { left, right }; diff --git a/Classes/GameScene.cpp b/Classes/GameScene.cpp index 2fd0370..c4ea025 100644 --- a/Classes/GameScene.cpp +++ b/Classes/GameScene.cpp @@ -77,8 +77,9 @@ void GameScene::setNextChessman(Chessman chessman) auto old = this->getChildByName("next"); auto moveAction = MoveBy::create(nextChessmanChangeTime, Vec2(0, -20)); if (old) { + old->setName(""); auto fadeOutAction = FadeOut::create(nextChessmanChangeTime); - auto callAction = CallFunc::create([this]() {this->removeChildByName("next"); }); + auto callAction = CallFunc::create([this, old]() {this->removeChild(old); }); auto sequenceAction = Sequence::create(fadeOutAction, callAction, NULL); old->runAction(moveAction); old->runAction(sequenceAction); @@ -387,11 +388,12 @@ void GameScene::endMoving() break; } } - if (lastChessman == Chessman::flip && controllable) { - changeTurn(); - } - else { - if (controllable) { + + if (controllable) { + if (lastChessman == Chessman::flip) { + changeTurn(); + } + else { if (touching && totalMovements < maxMovementTimes) { scheduleOnce(CC_CALLBACK_0(GameScene::beginMoving, this, movingCol), movingCooling, "cool"); state = ActionState::cooling; @@ -400,9 +402,9 @@ void GameScene::endMoving() changeTurnAndSetTurnFlag(); } } - else { - state = ActionState::nothing; - } + } + else { + state = ActionState::nothing; } } diff --git a/Classes/PvaGameScene.cpp b/Classes/PvaGameScene.cpp index b4f35a8..9c8720d 100644 --- a/Classes/PvaGameScene.cpp +++ b/Classes/PvaGameScene.cpp @@ -23,7 +23,7 @@ void PvaGameScene::endMoving() { Side originalTurn = turn;//去除这次endMoving才变成right的情况 GameScene::endMoving(); - if (originalTurn == right) { + if (originalTurn == right && turn == right) { if (AIMovementTimes > 0) { if (chessmen[lCol - 1][movingCol] == Chessman::flip) { AIMovementTimes = 1; From 75a9d38c3fe64464e1c1a5c6ae451ea2ac32fad0 Mon Sep 17 00:00:00 2001 From: renfei147 Date: Wed, 29 Jun 2016 19:41:07 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=AE=E4=BA=86=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E9=87=8D=E5=A4=A7BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/GameDefinitions.h | 3 ++- Classes/GameScene.cpp | 8 ++++---- Classes/GameScene.h | 1 + Classes/PvaGameScene.cpp | 9 ++++++--- Server/Server/src/Room.js | 4 ++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Classes/GameDefinitions.h b/Classes/GameDefinitions.h index db4708a..d76783e 100644 --- a/Classes/GameDefinitions.h +++ b/Classes/GameDefinitions.h @@ -6,8 +6,9 @@ const float movingTime = 0.3f;//移动用时 const int maxMovementTimes = 5;//最大移动数量 const int timeLimit = 20;//超时时间 +const float aiThinkingTime = 0.8f; const float boardScaleTime = 0.2f;//缩放动画时间 -const float boardFilpTime = 0.5f;//翻转动画时间 +const float boardFilpTime = 0.4f;//翻转动画时间 const float nextChessmanChangeTime = 0.5f;//切换下一个棋子提示的时间 enum Side { left, right }; diff --git a/Classes/GameScene.cpp b/Classes/GameScene.cpp index c4ea025..9a84926 100644 --- a/Classes/GameScene.cpp +++ b/Classes/GameScene.cpp @@ -284,9 +284,10 @@ bool GameScene::setBoardSize(int lCol, int rCol) void GameScene::flip() { - for (int i = 0; i < lCol; i++) + Chessman tempChessman[maxLCol][maxRCol]; + for (int i = 0; i < maxLCol; i++) { - for (int j = i + 1; j < rCol; j++) + for (int j = i + 1; j < maxRCol; j++) { std::swap(chessmen[i][j], chessmen[j][i]); } @@ -331,7 +332,7 @@ void GameScene::beginMoving(int col) for (int i = 0; i < (turn == left ? rCol : lCol); i++) { chessmanNode->getChildByTag(turn == left ? movingCol*rCol + i : i*rCol + movingCol)->runAction(movingAction->clone()); } - newChessman->runAction(movingAction->clone()); + newChessman->runAction(movingAction); scheduleOnce(CC_CALLBACK_0(GameScene::endMoving, this), movingTime, "move"); totalMovements++; } @@ -339,7 +340,6 @@ void GameScene::beginMoving(int col) void GameScene::endMoving() { - Chessman lastChessman;//暂存最底下的棋子 if (turn == left) { lastChessman = chessmen[movingCol][rCol - 1]; for (int i = rCol - 1; i > 0; i--) { diff --git a/Classes/GameScene.h b/Classes/GameScene.h index f00f2b8..50df173 100644 --- a/Classes/GameScene.h +++ b/Classes/GameScene.h @@ -29,6 +29,7 @@ class GameScene :public cocos2d::Scene ActionState state; int movingCol;//移动中的列 bool controllable = false; + Chessman lastChessman;//暂存最底下的棋子 void setNames(std::string left, std::string right); Chessman getNextChessman() { return nextChessman; }; diff --git a/Classes/PvaGameScene.cpp b/Classes/PvaGameScene.cpp index 9c8720d..ce63dba 100644 --- a/Classes/PvaGameScene.cpp +++ b/Classes/PvaGameScene.cpp @@ -23,7 +23,7 @@ void PvaGameScene::endMoving() { Side originalTurn = turn;//去除这次endMoving才变成right的情况 GameScene::endMoving(); - if (originalTurn == right && turn == right) { + if (originalTurn == right) { if (AIMovementTimes > 0) { if (chessmen[lCol - 1][movingCol] == Chessman::flip) { AIMovementTimes = 1; @@ -32,7 +32,10 @@ void PvaGameScene::endMoving() scheduleOnce([this](float) {beginMoving(movingCol); }, movingCooling, "cool"); } else { - changeTurnAndSetTurnFlag(); + changeTurn(); + if (lastChessman != Chessman::flip) { + setTurnFlag(); + } } } } @@ -43,7 +46,7 @@ void PvaGameScene::changeTurn() if (turn == right) { controllable = false; //切换回合后冷却一下再让AI下(否则看起来太突然) - scheduleOnce(CC_CALLBACK_0(PvaGameScene::AIMove, this), movingCooling, "changeCool"); + scheduleOnce(CC_CALLBACK_0(PvaGameScene::AIMove, this), aiThinkingTime, "changeCool"); } else { controllable = true; diff --git a/Server/Server/src/Room.js b/Server/Server/src/Room.js index a84aeb3..ded758d 100644 --- a/Server/Server/src/Room.js +++ b/Server/Server/src/Room.js @@ -206,8 +206,8 @@ Room.prototype.move = function (col, chessman) { } Room.prototype.flip = function () { - for (var i = 0; i < this.lCol; i++) { - for (var j = i + 1; j < this.rCol; j++) { + for (var i = 0; i < config.maxLCol; i++) { + for (var j = i + 1; j < config.maxRCol; j++) { this.chessmen[i][j] ^= this.chessmen[j][i]; this.chessmen[j][i] ^= this.chessmen[i][j]; this.chessmen[i][j] ^= this.chessmen[j][i]; From 04946234d7ea4afe2e0c3e327f2d54fa11a8cc58 Mon Sep 17 00:00:00 2001 From: renfei147 Date: Wed, 29 Jun 2016 23:54:35 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=9C=A8?= =?UTF-8?q?=E5=8F=AA=E6=9C=893=E5=88=97=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=E6=8E=A8=E5=87=BA=E5=87=8F=E5=88=97=E7=90=83=E4=BC=9A?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E4=B8=8B=E4=B8=80=E6=AC=A1=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E5=87=BA=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/GameScene.cpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/Classes/GameScene.cpp b/Classes/GameScene.cpp index 9a84926..1ef87ef 100644 --- a/Classes/GameScene.cpp +++ b/Classes/GameScene.cpp @@ -256,35 +256,36 @@ void GameScene::ejectorTouchEndedCallback(Touch * touch, Event * event) bool GameScene::setBoardSize(int lCol, int rCol) { - if (lCol > maxLCol || lColmaxRCol || rCol < minRCol) - return false; - //如果棋盘变大,把多出来的那部分清空 - if (this->lCol < lCol) { - for (int i = this->lCol; i < lCol; i++) { - for (int j = 0; j < rCol; j++) { - chessmen[i][j] = Chessman::common; + if (lCol <= maxLCol && lCol >= minLCol && rCol <= maxRCol && rCol >= minRCol) + { + //如果棋盘变大,把多出来的那部分清空 + if (this->lCol < lCol) { + for (int i = this->lCol; i < lCol; i++) { + for (int j = 0; j < rCol; j++) { + chessmen[i][j] = Chessman::common; + } } } - } - if (this->rCol < rCol) { - for (int i = 0; i < lCol; i++) { - for (int j = this->rCol; j < rCol; j++) { - chessmen[i][j] = Chessman::common; + if (this->rCol < rCol) { + for (int i = 0; i < lCol; i++) { + for (int j = this->rCol; j < rCol; j++) { + chessmen[i][j] = Chessman::common; + } } } + board->setScale((float)(lCol + rCol) / (this->lCol + this->rCol)); + auto scaleAction = ScaleTo::create(boardScaleTime, 1); + board->runAction(scaleAction); + this->lCol = lCol; + this->rCol = rCol; } - board->setScale((float)(lCol + rCol) / (this->lCol + this->rCol)); - auto scaleAction = ScaleTo::create(boardScaleTime, 1); - board->runAction(scaleAction); - this->lCol = lCol; - this->rCol = rCol; + buildChessboard(); return true; } void GameScene::flip() { - Chessman tempChessman[maxLCol][maxRCol]; for (int i = 0; i < maxLCol; i++) { for (int j = i + 1; j < maxRCol; j++) From 8cd7e6494b660142717df959d68a734d8cccbc65 Mon Sep 17 00:00:00 2001 From: renfei147 Date: Thu, 30 Jun 2016 20:24:16 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E6=96=87=E5=AD=97=E5=92=8CREADME.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/MainScene.cpp | 2 +- README.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Classes/MainScene.cpp b/Classes/MainScene.cpp index e8590f1..29c19c5 100644 --- a/Classes/MainScene.cpp +++ b/Classes/MainScene.cpp @@ -114,7 +114,7 @@ bool MainScene::init() updatePlayerLabel(); } - auto versionLabel = MyCreator::createLabel("Alpha 0.3", 25, Color4B(0, 0, 0, 255)); + auto versionLabel = MyCreator::createLabel("Alpha 0.3.1", 25, Color4B(0, 0, 0, 255)); versionLabel->setPosition(visibleSize.width - versionLabel->getContentSize().width / 2, versionLabel->getContentSize().height / 2); this->addChild(versionLabel); return true; diff --git a/README.md b/README.md index 0e27664..10fb0ae 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Myomyw -**Myomyw Alpha 0.3 宸插彂甯!** +**Myomyw Alpha 0.3.1 宸插彂甯!** ## 娓告垙瑙勫垯 娓告垙鐣岄潰涓袱杈规槸鍙戝皠鍣紝涓棿鏄鐩橈紝杞埌浣犳椂浣犲彲浠ョ偣鍑讳綘鐨勪竴涓彂灏勫櫒锛岃繖鏍峰氨鍙互鎶婄悆鎺ㄥ嚭鍘伙紝鎸変綇鍙戝皠鍣ㄥ彲浠ヨ繛缁彂灏勭悆锛屼絾鏈澶氬彧鑳藉彂灏勪簲娆° @@ -28,3 +28,4 @@ * 2016/2/28 鍙戝竷Alpha 0.1.1 * 2016/3/27 鍙戝竷Alpha 0.2 * 2016/6/28 鍙戝竷Alpha 0.3 +* 2016/6/30 鍙戝竷Alpha 0.3.1