void onMoveDol() { if (Game.selectedDol != null && Game.targetDol != null && mydolType == 0) { Game.lastMovedDol = Game.selectedDol; Debug.Log(string.Format("Bound - SwapDol:{0} {1}", Game.selectedDol.name, Game.targetDol.name)); //SwapDolPos(ref Game.selectedDol, ref Game.targetDol); MoveInfoReq moveInfoReq = new MoveInfoReq(); moveInfoReq.source.setPos(Game.selectedDol.dolPos); moveInfoReq.target.setPos(Game.targetDol.dolPos); if (Game.isOffLineMode == false) { Game.send(moveInfoReq.ToString()); } else { MoveInfoRes moveInfoRes = new MoveInfoRes(); moveInfoRes.source.setPos(Game.selectedDol.dolPos); moveInfoRes.target.setPos(Game.targetDol.dolPos); Game.sendLocalData("MoveInfoRes", moveInfoRes.ToString()); TurnInfo turnInfo = new TurnInfo(); if (Game.local_turn == Game.selectedDol.GetMyDolType()) { turnInfo.isMe = false; } else { turnInfo.isMe = true; } turnInfo.isBlack = Game.selectedDol.GetMyDolType() == 1 ? true : false; Game.sendLocalData("TurnInfo", turnInfo.ToString()); Game.local_turn = Game.local_turn == 2 ? 1 : 2; Game.isMyDolColorBlack = Game.selectedDol.GetMyDolType() == 1 ? true : false; } Game.selectedDol = null; Game.targetDol = null; Dols.SetOffAllCanMove(); indicator.SetActive(false); } }
public void moveInfoReq(MoveInfoReq req, bool isBlack) { if (gameState == GameTableState.PLAYING) { MoveInfoRes moveInfoRes = new MoveInfoRes(); moveInfoRes.writeFromReqData(req); if (req.source.x != -1) { sendAllData("MoveInfoRes", moveInfoRes); } isNowPlayerBlack = !isNowPlayerBlack; sendTurnInfo(); } }
void FixedUpdate() { if (PlayDol.isRunAnimation == true) { return; } if (isNetworkPlay && isOffLineMode == false) { if (globalTimeLeft < 0) { //GameOver(); if (isOffLineMode == false) { } GameResultInfo gameResultInfo = new GameResultInfo(); if (myPlyScore > otherPlyScore) { gameResultInfo.winnerColor = isMyDolColorBlack == true ? 2 : 1; gameResultInfo.wiinerScore = myPlyScore; gameResultInfo.loseScore = otherPlyScore; gameResultInfo.wiinnerIsme = true; showResult("You Win", true); ws.Send(gameResultInfo.ToString()); } else if (myPlyScore < otherPlyScore) { gameResultInfo.winnerColor = isMyDolColorBlack == true ? 1 : 2; gameResultInfo.wiinerScore = otherPlyScore; gameResultInfo.loseScore = myPlyScore; gameResultInfo.wiinnerIsme = false; showResult("You Lost", true); ws.Send(gameResultInfo.ToString()); } else { gameResultInfo.winnerColor = isMyDolColorBlack == true ? 2 : 1; gameResultInfo.wiinerScore = myPlyScore; gameResultInfo.loseScore = otherPlyScore; gameResultInfo.wiinnerIsme = true; showResult("Drawgame", true); ws.Send(gameResultInfo.ToString()); } globalTimeLeft = gameInfo.totalTimeBank + 10; } else { globalTimeLeft -= Time.fixedDeltaTime; txtTotalRemainTime.text = string.Format("RemainTime:{0}", (int)globalTimeLeft); } if (isMyTurn) { if (0 < privateTimeLeft) { privateTimeLeft -= Time.fixedDeltaTime; txtPrivateTime.text = string.Format("You,Limit:{0}", (int)privateTimeLeft); } else { if (Game.selectedDol != null) { Game.selectedDol.indicatorOff(); } Game.selectedDol = null; Game.targetDol = null; Dols.SetOffAllCanMove(); MoveInfoReq moveInfoReq = new MoveInfoReq(); VectorDol nullPos = new VectorDol(); nullPos.x = -1; moveInfoReq.source.setPos(nullPos); moveInfoReq.target.setPos(nullPos); send(moveInfoReq.ToString()); privateTimeLeft = gameInfo.privateTimeBank; } } else { if (0 < privateTimeLeft) { privateTimeLeft -= Time.fixedDeltaTime; txtPrivateTime.text = string.Format("He,Limit:{0}", (int)privateTimeLeft); } else { privateTimeLeft = gameInfo.privateTimeBank; } } } ProcessPackets(); }