Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (!mainController.isRuning)
        {
            return;
        }
        if (mainController.time <= 0)
        {
            mainController.JudgeCallback(false, "Game Over!");
            return;
        }
        this.gameObject.GetComponent <UserGUI>().gameMessage = "";
        //判断是否已经胜利
        if (rightLandModel.priestNum == 3)
        {
            mainController.JudgeCallback(false, "You Win!");
            return;
        }
        else
        {
            //判断是否已经失败

            /*
             * leftPriestNum: 左边牧师数量
             * leftDevilNum: 左边恶魔数量
             * rightPriestNum: 右边牧师数量
             * rightDevilNum: 右边恶魔数量
             * 若任意一侧,牧师数量不为0且牧师数量少于恶魔数量,则游戏失败
             */
            int leftPriestNum, leftDevilNum, rightPriestNum, rightDevilNum;
            leftPriestNum = leftLandModel.priestNum + (boatModel.isRight ? 0 : boatModel.priestNum);
            leftDevilNum  = leftLandModel.devilNum + (boatModel.isRight ? 0 : boatModel.devilNum);
            if (leftPriestNum != 0 && leftPriestNum < leftDevilNum)
            {
                mainController.JudgeCallback(false, "Game Over!");
                return;
            }
            rightPriestNum = rightLandModel.priestNum + (boatModel.isRight ? boatModel.priestNum : 0);
            rightDevilNum  = rightLandModel.devilNum + (boatModel.isRight ? boatModel.devilNum : 0);
            if (rightPriestNum != 0 && rightPriestNum < rightDevilNum)
            {
                mainController.JudgeCallback(false, "Game Over!");
                return;
            }
        }
    }
    // 参考之前的 Check()
    void Update()
    {
        if (!sceneController.isRunning)
        {
            return;
        }
        if (sceneController.time <= 0)
        {
            sceneController.JudgeCallback("Game Over!", false);
            return;
        }
        this.gameObject.GetComponent <UserGUI>().result = "";

        if (desCoastModel.priestNum == 3)
        {
            sceneController.JudgeCallback("You Win!", false);
            return;
        }
        else
        {
            int leftPriestNum, leftDevilNum, rightPriestNum, rightDevilNum;
            leftPriestNum = srcCoastModel.priestNum + (boatModel.OnRight ? 0 : boatModel.priestNum);
            leftDevilNum  = srcCoastModel.devilNum + (boatModel.OnRight ? 0 : boatModel.devilNum);
            if (leftPriestNum != 0 && leftPriestNum < leftDevilNum)
            {
                sceneController.JudgeCallback("Game Over!", false);
                return;
            }

            rightPriestNum = desCoastModel.priestNum + (boatModel.OnRight ? boatModel.priestNum : 0);
            rightDevilNum  = desCoastModel.devilNum + (boatModel.OnRight ? boatModel.devilNum : 0);
            if (rightPriestNum != 0 && rightPriestNum < rightDevilNum)
            {
                sceneController.JudgeCallback("Game Over!", false);
                return;
            }
        }
    }
 // Update is called once per frame
 void Update()
 {
     if (!mainController.isRunning)
     {
         return;
     }
     if (mainController.time <= 0)
     {
         mainController.JudgeCallback(false, "Game Over!");
         return;
     }
     this.gameObject.GetComponent <UserGUI>().gameMessage = "";
     //判断是否已经胜利
     if (rightShoreModel.priestCount == 3)
     {
         mainController.JudgeCallback(false, "You Win!");
         return;
     }
     else
     {
         int leftPriestNum, leftDevilNum, rightPriestNum, rightDevilNum;
         leftPriestNum = leftShoreModel.priestCount + (boatModel.isRight ? 0 : boatModel.priestCount);
         leftDevilNum  = leftShoreModel.devilCount + (boatModel.isRight ? 0 : boatModel.devilCount);
         if (leftPriestNum != 0 && leftPriestNum < leftDevilNum)
         {
             mainController.JudgeCallback(false, "Game Over!");
             return;
         }
         rightPriestNum = rightShoreModel.priestCount + (boatModel.isRight ? boatModel.priestCount : 0);
         rightDevilNum  = rightShoreModel.devilCount + (boatModel.isRight ? boatModel.devilCount : 0);
         if (rightPriestNum != 0 && rightPriestNum < rightDevilNum)
         {
             mainController.JudgeCallback(false, "Game Over!");
             return;
         }
     }
 }