public void moveRole(roleModel role) { if (role.isOnBoat()) // from boat to land { landModel land; if (boat.getBoatFlag() == 1) { land = startLand; } else { land = endLand; } role.getOnLand(land); } else if (!role.isOnBoat()) //from land to boat { landModel land = role.getLand(); if (boat.getEmptyPosIndex() == -1 || boat.getBoatFlag() != land.getLandFlag()) { return; } role.getOnBoat(boat); } }
//change in v2 public void moveBoat() { if (boat.isEmpty()) { return; } //action Vector3 target = boat.getBoatFlag() == 1 ? boat.getEndPos() : boat.getStartPos(); actionManager.moveBoat(boat.getBoat(), target, 100 * Time.deltaTime); boat.setBoatFlag(-boat.getBoatFlag()); }
protected void Update() { int[] startLandCount = startLand.getRoleCount(); int[] endLandCount = endLand.getRoleCount(); int[] boatCount = boat.getRoleCount(); int startPriestsCount = startLandCount[0]; //including roles on boat if the boat is at the same side int startDevilsCount = startLandCount[1]; int endPriestsCount = endLandCount[0]; int endDevilsCount = endLandCount[1]; int boatPriestsCount = boatCount[0]; int boatDevilsCount = boatCount[1]; if (boat.getBoatFlag() == 1) { startPriestsCount += boatPriestsCount; startDevilsCount += boatDevilsCount; } else if (boat.getBoatFlag() == -1) { endPriestsCount += boatPriestsCount; endDevilsCount += boatDevilsCount; } if ((startPriestsCount > 0 && startDevilsCount > startPriestsCount) || (endPriestsCount > 0 && endDevilsCount > endPriestsCount)) //lose { callback.JudgeEvent(JudgeEventType.lose); } else if (startDevilsCount + startPriestsCount == 0 && endPriestsCount + endDevilsCount == 6 && boatPriestsCount == 0 && boatDevilsCount == 0) //win { callback.JudgeEvent(JudgeEventType.win); } else { callback.JudgeEvent(JudgeEventType.unfinish); //continue playing } }