void Check() { // 判断左岸是否6人到达,若是则胜利 if (HumansOnLeft.Count == 3 && EvilsOnLeft.Count == 3) { //my.state = GameState.Win; my.setMessage("You Win !"); return; } // 计算船上人、鬼数量 int BoatH = 0, BoatE = 0; for (int i = 0; i < 2; i++) { if (OnBoat[i] != null && OnBoat[i].tag == "Human") { BoatH++; } if (OnBoat[i] != null && OnBoat[i].tag == "Evil") { BoatE++; } } // 计算两岸上人鬼数量对比 int numH = 0, numE = 0; if (side == 0) { numH = HumansOnLeft.Count + BoatH; numE = EvilsOnLeft.Count + BoatE; if (HumansOnRight.Count < EvilsOnRight.Count && HumansOnRight.Count > 0) { my.setMessage("You Lose !"); } } else if (side == 1) { numH = HumansOnRight.Count + BoatH; numE = EvilsOnRight.Count + BoatE; if (HumansOnLeft.Count < EvilsOnLeft.Count && HumansOnLeft.Count > 0) { my.setMessage("You Lose !"); } } if (numH > 0 && numH < numE) { my.setMessage("You Lose !"); } }
void check() { GameSceneController scene = GameSceneController.GetInstance(); int pOnb = 0, dOnb = 0; int priests_s = 0, devils_s = 0, priests_e = 0, devils_e = 0; if (priests_end.Count == 3 && devils_end.Count == 3) { scene.setMessage("Win!"); return; } for (int i = 0; i < 2; ++i) { if (boat[i] != null && boat[i].tag == "Priest") { pOnb++; } else if (boat[i] != null && boat[i].tag == "Devil") { dOnb++; } } if (side == 1) { priests_s = priests_start.Count + pOnb; devils_s = devils_start.Count + dOnb; priests_e = priests_end.Count; devils_e = devils_end.Count; } else if (side == 2) { priests_s = priests_start.Count; devils_s = devils_start.Count; priests_e = priests_end.Count + pOnb; devils_e = devils_end.Count + dOnb; } if ((priests_s != 0 && priests_s < devils_s) || (priests_e != 0 && priests_e < devils_e)) { scene.setMessage("Lose!"); } }