コード例 #1
0
    void checkAnswer()
    {
        if (selected_answer == null)
        {
            return;
        }

        // change the game status
        currentStatus = gameStatus.InCheck;

        displayAnswerButton.gameObject.SetActive(true);

        numberOfQuestionsAnswred += 1;  // to keep track of how many questions have been answered

        if (selected_answer.name.Equals(currentQuestionObject.name))
        {
            //selected_answer.transform.GetComponent<Image>().color = Color.green;
            selected_answer.transform.parent.GetComponent <Image>().sprite = buttonSprites[2];
            plusScore();
        }
        else
        {
            selected_answer.transform.parent.GetComponent <Image>().sprite = buttonSprites[3];
            scoreNumberLabel.text = score.ToString() + "/" + numberOfQuestionsAnswred;
        }
    }
コード例 #2
0
    // pick a random question from the List<Question> and display it
    void instantiateRandomQuestionToDisplay()
    {
        int randomNum = Random.Range(0, questions.Count);          // random a question

        currentQuestionObject = questions [randomNum];
        currentQuestion       = Instantiate(currentQuestionObject.gameObject, canvas.transform, false);         // instantiate the prefab
        questionName.text     = currentQuestionObject.name;

        // change the game status and deactivate the answer button
        currentStatus = gameStatus.InGame;

        mainQuestionSelectedToggles = new List <Toggle>();
        mainQuestionScore           = 0;
        calculateQtnTotalPossiblePts();

        getQuestionToggles();
        eToggleSelected = false;

        // getting the score number label
        Text[] textelements = canvas.GetComponentsInChildren <Text>();
        for (int i = 0; i < textelements.Length; i++)
        {
            if (textelements[i].tag.Equals("scorenumberlabel"))
            {
                scoreNumberLabel = textelements[i];
            }
        }
        updateScore();
    }
コード例 #3
0
    public void setCurrentGameState()
    {
        waveNumber += 1;
        Debug.Log("Current Wave number = " + waveNumber);
        if (TotalEscaped >= 10)
        {
            currentState = gameStatus.gameover;
        }
        else if (waveNumber == 0 && (totalKilled + roundEscaped) == 0)
        {
            currentState = gameStatus.play;
        }
        else if (waveNumber >= totalWaves)
        {
            currentState = gameStatus.win;

            //TODO:stop the rest of the robots from moving and then destroy them one by one.
            //foreach(Robot enemy in EnemyList){
            //	DestroyAllEnemies();
            //}

            for (int i = 0; i < EnemyList.Count; i++)
            {
                DestroyAllEnemies();
            }
        }
        else
        {
            currentState = gameStatus.next;
        }
    }
コード例 #4
0
    void checkAnswer()
    {
        // check for empty slots, return if there is empty one
        // for(int i = 0; i < currentQuestion.transform.childCount; i++) {
        //  if(currentQuestion.transform.GetChild(i).childCount == 0) {
        //      return;
        //  }
        // }
        if (!checkForEmptyCells())
        {
            return;
        }


        // change the game status
        currentStatus = gameStatus.InCheck;
        displayAnswerButton.gameObject.SetActive(true);
        numberOfQuestionsAnswred += 1;          // to keep track of how many questions have been answered

        // loop through the slots and check answer
        for (int i = 0; i < currentQuestion.transform.childCount; i++)
        {
            GameObject elementInCell = currentQuestion.transform.GetChild(i).GetChild(0).gameObject;
            if (elementInCell.tag == currentQuestionObject.answer[i])
            {
                plusScore();
                elementInCell.transform.GetComponent <Image>().color = Color.green;
            }
            else
            {
                Score += 0;
                elementInCell.transform.GetComponent <Image>().color = Color.red;
            }
        }
    }
コード例 #5
0
ファイル: GameManager.cs プロジェクト: MaxRomagnoli/Appuzzle
    void TryGameOver()
    {
        // Verify all the tiles are in position
        foreach (PuzzleTile tile in tilesList)
        {
            if (!tile.IsInPosition())
            {
                return;
            }
        }

        // Set game over
        currentGameStatus = gameStatus.Over;

        // Print game over score
        int      movesScore     = SaveMovesScore();
        TimeSpan timeScore      = SaveTimeScore();
        TimeSpan gamingTimeSpan = TimeSpan.FromSeconds(gamingTime);

        gameOverScoreText.text = "Your score:\n" + moves.ToString() + " moves\n" +
                                 string.Format("{0:D2}:{1:D2}:{2:D2}", gamingTimeSpan.Hours, gamingTimeSpan.Minutes, gamingTimeSpan.Seconds);

        gameOverBestMovesText.text = "Best moves: " + movesScore.ToString();
        gameOverBestTimeText.text  = "Best time:" + string.Format("{0:D2}:{1:D2}:{2:D2}", timeScore.Hours, timeScore.Minutes, timeScore.Seconds);

        gameOverPanel.gameObject.SetActive(true);
    }
コード例 #6
0
    // pick a random question from the List<Question> and display it
    void instantiateRandomQuestionToDisplay()
    {
        nextButton.image.color = Color.white;
        int randomNum = Random.Range(0, questions.Count);        // random a question

        currentQuestionObject = questions[randomNum];
        currentQuestion       = Instantiate(currentQuestionObject.gameObject, canvas.transform, false); // instantiate the prefab
        currentQuestionAnswer = Instantiate(currentQuestionObject.answerObject, canvas.transform, false);
        if (leftHandMode)
        {
            currentQuestion.transform.localPosition       = new Vector2(-currentQuestion.transform.localPosition.x + 30, 0);
            currentQuestionAnswer.transform.localPosition = new Vector2(-currentQuestionAnswer.transform.localPosition.x + 30, 0);
        }
        currentQuestionAnswer.SetActive(false);
        questionName.text   = currentQuestionObject.name;
        totalNumberOfCells += currentQuestionObject.numberOfCells;         // record the number of cells for calculating result

        // change the game status and deactivate the answer button
        currentStatus = gameStatus.InGame;
        displayAnswerButton.gameObject.SetActive(false);



        // setup the answer choices
        var rnd           = new System.Random();
        var randomNumbers = Enumerable.Range(0, 4).OrderBy(x => rnd.Next()).Take(4).ToList();

        firstChoice.GetComponent <Text> ().text  = currentQuestionObject.answer[randomNumbers[0]];
        secondChoice.GetComponent <Text> ().text = currentQuestionObject.answer[randomNumbers[1]];
        thirdChoice.GetComponent <Text> ().text  = currentQuestionObject.answer[randomNumbers[2]];
        fourthChoice.GetComponent <Text> ().text = currentQuestionObject.answer[randomNumbers[3]];
    }
コード例 #7
0
        public void open(int index)
        {
            if (index == -1)
            {
                return;
            }
            var cell = Field[index];

            if (cell.hasBomb)
            {
                status = gameStatus.LOST;
                return;
            }
            if (cell.mark == cellStatus.OPENED)
            {
                return;
            }
            cell.mark = cellStatus.OPENED;
            if (Field.IndexOf(Field.Find(t => (!t.hasBomb && t.mark != cellStatus.OPENED))) == -1)
            {
                status = gameStatus.WON;
                return;
            }
            if (cell.bombNeighboursCount == 0)
            {
                open(Field.IndexOf(Field.Find(t => (t.c == cell.c + 1 && t.r == cell.r + 1))));
                open(Field.IndexOf(Field.Find(t => (t.c == cell.c && t.r == cell.r + 2))));
                open(Field.IndexOf(Field.Find(t => (t.c == cell.c - 1 && t.r == cell.r + 1))));
                open(Field.IndexOf(Field.Find(t => (t.c == cell.c - 1 && t.r == cell.r - 1))));
                open(Field.IndexOf(Field.Find(t => (t.c == cell.c && t.r == cell.r - 2))));
                open(Field.IndexOf(Field.Find(t => (t.c == cell.c + 1 && t.r == cell.r - 1))));
            }
        }
コード例 #8
0
    // Update is called once per frame
    void Update()
    {
        // maquina de estados del juego
        switch (gStatus)
        {
        case (gameStatus.play):

            // comprobamos si ya no quedan bricks
            if (CheckEndLevel() || Input.GetKeyDown(KeyCode.Q))
            {
                gStatus = gameStatus.endLevel;
            }
            // comprovamos que al player le quede salud
            else if (playerController.playerLifes == 0 || Input.GetKeyDown(KeyCode.Insert))
            {
                gStatus = gameStatus.gameLost;
            }

            break;

        case (gameStatus.gameLost):

            levelLostCanvas.SetActive(true);

            Time.timeScale = 0f;                // paramos el tiempo
            if (Input.anyKeyDown)
            {
                // ocultamos el mensaje por si a caso
                levelLostCanvas.SetActive(false);

                Time.timeScale = 1f;                // reanudamos el tiempo ( se que depende para que cosas no funciona pero para simplificar opto por esta solucion)

                // empezamos el juego desde el primer nivel
                SceneManager.LoadScene(0, LoadSceneMode.Single);
            }


            break;


        case (gameStatus.endLevel):
            // el juego ya habra acabado y estaremos esperando al input del player
            // pasra pasar al siguiente nivel

            // activamos el panel que muestra que hemos acabado el nivel
            levelClearCanvas.SetActive(true);
            DataStorage.remainingLifes = playerController.playerLifes;
            DataStorage.storedPoints   = playerController.playerScore;
            Time.timeScale             = 0f;    // paramos el tiempo

            if (Input.anyKeyDown)
            {
                levelClearCanvas.SetActive(false);
                Time.timeScale = 1f;                // reanudamos el tiempo ( se que depende para que cosas no funciona pero para simplificar opto por esta solucion)
                SceneManager.LoadScene(1);          // no hay mas escenas por eso cargamos la misma escena de nuevo
            }

            break;
        }
    }
コード例 #9
0
 private void handleEscape()
 {
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         currentState = gameStatus.gameover;
         playBtnPressed(true);
         GameManager.instance.toggleAudioListener(true);
         StartCoroutine(unloadSceneWithData(false));
     }
 }
コード例 #10
0
 public void doDamageToPlayer(int damage)
 {
     playerHealth = playerHealth - damage;
     playerHpLbl.GetComponent <Text>().text = playerHealth.ToString();
     Debug.Log("playerHealth:" + playerHealth);
     if (playerHealth <= 0)
     {
         Debug.Log("Game Over - You Lost");
         currentState = gameStatus.gameover;
         updateGameStatus();
         Application.LoadLevel("EndGame");
     }
 }
コード例 #11
0
 public void revealAnswer()
 {
     for (int i = 0; i < deck.transform.childCount; i++)
     {
         GameObject elementInCell = deck.transform.GetChild(i).GetChild(0).gameObject;
         if (elementInCell.name.Equals(currentQuestionObject.name))
         {
             elementInCell.transform.parent.GetComponent <Image>().sprite = buttonSprites[2];
             currentStatus             = gameStatus.InCheck;
             numberOfQuestionsAnswred += 1;
         }
     }
 }
コード例 #12
0
 public void nextButtonPressed()
 {
     if (currentStatus == gameStatus.InGame)
     {
         checkMainQuestionAnswer();
         displayAnsPanel();
         addMainQuestionScore();
         updateScore();
     }
     else if (currentStatus == gameStatus.InCheck)
     {
         for (int j = 0; j < mainQuestionToggles.Length; j++)
         {
             Image[] toggleImages = mainQuestionToggles [j].GetComponentsInChildren <Image> ();
             Image   imagecm      = toggleImages [0];
             if (currentQuestionObject.answer.Contains(mainQuestionToggles [j].tag))
             {
                 if (mainQuestionSelectedToggles.Contains(mainQuestionToggles [j]))
                 {
                     imagecm.sprite = acolourgr;
                 }
                 else if (imagecm.sprite == acolourb)
                 {
                     imagecm.sprite = acolourgr;
                 }
             }
             else
             {
                 if (mainQuestionSelectedToggles.Contains(mainQuestionToggles [j]))
                 {
                     mainQuestionToggles [j].gameObject.SetActive(false);
                 }
             }
         }
         AnsPanel.SetActive(false);
         extra = Instantiate(currentQuestionObject.extraObject, canvas.transform, false);
         numberOfQuestionsAnswred += 1;              // to keep track of how many questions have been answered
         currentStatus             = gameStatus.InExtra;
     }
     else if (currentStatus == gameStatus.InExtra)
     {
         if (eToggleSelected)
         {
             displyFunFact();
         }
     }
     else
     {
         displayQuestion();
     }
 }
コード例 #13
0
    public void doDamageToEnemy(int damage)
    {
        enemyHealth = enemyHealth - damage;
        enemyHpLbl.GetComponent <Text>().text = enemyHealth.ToString();
        Debug.Log("enemyHealth:" + enemyHealth);
        if (enemyHealth <= 0)
        {
            Debug.Log("Game Over - You WIN");
            currentState = gameStatus.win;
            updateGameStatus();

            Application.LoadLevel("EndGame");
        }
    }
コード例 #14
0
    // pick a random question from the List<Question> and display it
    void instantiateRandomQuestionToDisplay()
    {
        displayAnswerButton.gameObject.SetActive(false);
        int randomNum = Random.Range(0, questions.Count); // random a question

        currentQuestionObject = questions[randomNum];
        currentQuestion       = Instantiate(currentQuestionObject.gameObject, canvas.transform, false); // instantiate the prefab
        if (leftHandMode)
        {
            currentQuestion.transform.localPosition = new Vector2(-currentQuestion.transform.localPosition.x, 0);
        }

        // change the game status and deactivate the answer button
        currentStatus = gameStatus.InGame;
    }
コード例 #15
0
 public void SetCurrentGamestate() //определим, в каком состоянии нах-ся игра
 {
     if (totalEscaped >= 3)        //если врагов сбежало больше """3"""
     {
         currentState = gameStatus.gameover;
     }
     else if ((TotalKilled + TotalEscaped) == 0)//если уровень еще не начат
     {
         currentState = gameStatus.play;
     }
     else if (TotalKilled >= totalEnemies - 2)//если убито врагов хотя бы 6
     {
         currentState = gameStatus.win;
     }
 }
コード例 #16
0
ファイル: GameManager.cs プロジェクト: MaxRomagnoli/Appuzzle
    public bool Move(PuzzleTile _tile1, Vector2 _direction)
    {
        // If the two tiles exist
        PuzzleTile _tile2 = GetTileFromDirection(_tile1, _direction);

        if (_tile1 == null || _tile2 == null)
        {
            return(false);
        }

        // One of the two tiles need to be the empty one
        if (!_tile1.IsLast() && !_tile2.IsLast())
        {
            return(false);
        }

        // invert parent and Sibling Index
        Transform tile1Transform    = _tile1.transform.parent;
        Transform tile2Transform    = _tile2.transform.parent;
        int       tile1SiblingIndex = _tile1.transform.GetSiblingIndex();
        int       tile2SiblingIndex = _tile2.transform.GetSiblingIndex();

        _tile1.transform.SetParent(tile2Transform);
        _tile2.transform.SetParent(tile1Transform);
        _tile1.transform.SetSiblingIndex(tile2SiblingIndex);
        _tile2.transform.SetSiblingIndex(tile1SiblingIndex);

        // invert index
        int tile1Index = _tile1.GetIndex();
        int tile2Index = _tile2.GetIndex();

        _tile1.SetCurrentIndex(tile2Index);
        _tile2.SetCurrentIndex(tile1Index);

        // Setup animation
        tile1ForAnimation         = _tile1;
        tile2ForAnimation         = _tile2;
        tile1PositionForAnimation = _tile1.transform.position;
        tile2PositionForAnimation = _tile2.transform.position;
        //tile1ForAnimation.transform.position = tile1PositionForAnimation;
        //tile2ForAnimation.transform.position = tile2PositionForAnimation;
        currentAnimationSpeed = 0;
        currentGameStatus     = gameStatus.Moving;

        return(true);
    }
コード例 #17
0
ファイル: GameManager.cs プロジェクト: MaxRomagnoli/Appuzzle
    void Update()
    {
        if (currentGameStatus == gameStatus.Moving)
        {
            //Reset position with lerp
            if (currentAnimationSpeed < 1f)
            {
                // lerp towards our target
                tile1ForAnimation.transform.position = Vector3.Lerp(tile1PositionForAnimation, tile2PositionForAnimation, currentAnimationSpeed);
                tile2ForAnimation.transform.position = Vector3.Lerp(tile2PositionForAnimation, tile1PositionForAnimation, currentAnimationSpeed);
                currentAnimationSpeed += Time.deltaTime * (isMixing ? animationRandomSpeed : animationSpeed);
            }
            else
            {
                tile1ForAnimation.transform.position = tile2PositionForAnimation;
                tile2ForAnimation.transform.position = tile1PositionForAnimation;
                currentGameStatus = gameStatus.Gaming;

                if (!isMixing)
                {
                    // Update moves
                    moves++;
                    movesText.text = moves.ToString() + " moves";
                    TryGameOver();
                }
            }
        }
        else if (isMixing)
        {
            //If mixing matrix
            if (currentRandomIterations >= randomIterations)
            {
                currentGameStatus = gameStatus.Gaming;
                isMixing          = false;
            }
            else if (Move(GetRandomTile(), GetRandomDirection()))
            {
                currentRandomIterations++;
            }
        }
        else if (currentGameStatus == gameStatus.Gaming)
        {
            // Add time if is gaming
            gamingTime += Time.deltaTime;
        }
    }
コード例 #18
0
    void checkAnswer()
    {
        // check for empty slots, return if there is empty one
        // for(int i = 0; i < currentQuestion.transform.childCount; i++) {
        //  if(currentQuestion.transform.GetChild(i).childCount == 0) {
        //      return;
        //  }
        // }
        if (selected_answer == null)
        {
            return;
        }


        // change the game status
        currentStatus = gameStatus.InCheck;
        displayAnswerButton.gameObject.SetActive(true);
        numberOfQuestionsAnswred += 1;          // to keep track of how many questions have been answered

        // loop through the slots and check answer
//		for(int i = 0; i < currentQuestion.transform.childCount; i++) {
//			GameObject elementInCell = currentQuestion.transform.GetChild(i).GetChild(0).gameObject;
//			if(elementInCell.tag == currentQuestionObject.answer[i]) {
//				plusScore();
//				elementInCell.transform.GetComponent<Image>().color = Color.green;
//			}else {
//				Score += 0;
//				elementInCell.transform.GetComponent<Image>().color = Color.red;
//			}
//		}


        // just testing
        if (correctAnswer)
        {
            plusScore();
            selected_answer.transform.parent.GetComponent <Image>().sprite = buttonSprites[2];
            correctAnswer = false;
        }
        else
        {
            Score += 0;
            selected_answer.transform.parent.GetComponent <Image>().sprite = buttonSprites[3];
        }
    }
コード例 #19
0
ファイル: GameManager.cs プロジェクト: NikoLSDP/Ball-Game
 void SetCurrentState()
 {
     if (gameOver)
     {
         currentState = gameStatus.gameOver;
         playing      = false;
     }
     if (Win)
     {
         currentState = gameStatus.lvlFinished;
         playing      = false;
     }
     if (Playing)
     {
         currentState = gameStatus.gameStarted;
     }
     showMenu();
 }
コード例 #20
0
    public void playBtnPressed(bool userClickedEscape)
    {
        GameStatusBtn.gameObject.SetActive(false);
        Debug.Log("playBtnPressed, currentState = " + currentState);
        switch (currentState)
        {
        case gameStatus.next:
            waveNumber   += 1;
            totalEnemies += waveNumber;
            break;

        case gameStatus.gameover:
            totalEnemies   = 3;
            TotalEscaped   = 0;
            waveNumber     = 0;
            enemiesToSpawn = 0;
            TotalMoney     = STARTING_MONEY;
            TowerManager.Instance.DestroyAllTowers();
            TowerManager.Instance.RenameTagsBuildSites();
            totalMoneyLabel.text = TotalMoney.ToString();
            escapedLabel.text    = "Escaped " + TotalEscaped + "/" + maxAllowedEscaped;
            GameStatusBtn.gameObject.SetActive(false);
            audioSource.PlayOneShot(SoundManager.Instance.NewGame);

            if (!userClickedEscape)
            {
                currentState = gameStatus.play;
            }
            break;

        case gameStatus.win:
            Debug.Log("win");
            TowerManager.Instance.DestroyAllTowers();
            StartCoroutine(unloadSceneWithData(true));
            break;
        }
        DestroyAllEnemies();
        TotalKilled  = 0;
        roundEscaped = 0;
        Debug.Log("wave number = " + waveNumber);
        waveLabel.text = "Wave " + (waveNumber + 1);
        StartCoroutine(spawn());
        playBtn.gameObject.SetActive(false);
    }
コード例 #21
0
 private void setCurrentGameState()
 {
     if (TotalEscaped >= totalEnemies)
     {
         currentState = gameStatus.gameover;
     }
     else if (waveNumber == 1 && (TotalKilled + RoundEscaped == 0))
     {
         currentState = gameStatus.play;
     }
     else if (waveNumber == totalWaves)
     {
         currentState = gameStatus.win;
     }
     else
     {
         currentState = gameStatus.next;
     }
 }
コード例 #22
0
 public void SetCurrentGameState()  // Состояние игры (победа, конец, начать игру)
 {
     if (totalEscaped >= totalEnemies)
     {
         currentState = gameStatus.gameover;
     }
     else if (waveNumber == 0 && (RoundEscaped + TotalKilled) == 0)
     {
         currentState = gameStatus.play;
     }
     else if (waveNumber >= totalWaves)
     {
         currentState = gameStatus.win;
     }
     else
     {
         currentState = gameStatus.next;
     }
 }
コード例 #23
0
ファイル: GameManager.cs プロジェクト: MigAlvar/Tower-Defense

        
コード例 #24
0
 public void SetCurentGameState()
 {
     if (TotalEscaped >= 10)
     {
         currentState = gameStatus.gameover;
     }
     else if ((waveNumber == 0) && (TotalKills + RoundEscaped) == 0)
     {
         currentState = gameStatus.play;
     }
     else if (waveNumber >= totalWaves)
     {
         currentState = gameStatus.win;
     }
     else
     {
         currentState = gameStatus.next;
     }
 }
コード例 #25
0
 public void setCurrentGameState()
 {
     if (totalEscaped >= maxEscapedEnemies)
     {
         currentState = gameStatus.gameover;
     }
     else if (waveNumber == 0 && (totalKilled + roundEscaped) == 0)
     {
         currentState = gameStatus.play;
     }
     else if (waveNumber >= totalWaves)
     {
         currentState = gameStatus.win;
     }
     else
     {
         currentState = gameStatus.next;
     }
 }
コード例 #26
0
 //when isWaveOver we have to change setCurrentGameState
 public void setCurrentGameState()
 {
     if (TotalEscaped >= escapeLimit)
     {
         currentState = gameStatus.gameover;
     }
     else if (waveNumber == 0 && (TotalKilled + TotalEscaped) == 0)
     {
         currentState = gameStatus.play;
     }
     else if (waveNumber >= totalWaves)
     {
         currentState = gameStatus.win;
     }
     //add for stop and shop btn
     else
     {
         currentState = gameStatus.next;
     }
 }
コード例 #27
0
ファイル: GameManager.cs プロジェクト: NikoLSDP/Ball-Game
    public void OnClickedBtn()
    {
        switch (btnPlayLabel.text)
        {
        case "Play":
            currentState = gameStatus.gameStarted;
            playing      = true;
            break;

        case "Next Level":
            SceneManager.LoadScene("LV 2", LoadSceneMode.Single);
            currentState = gameStatus.menu;
            break;

        case "Retry":
            currentState = gameStatus.menu;
            SceneManager
        }
        showMenu();
    }
コード例 #28
0
 public void setCurrentGameState()
 {
     if (TotalEscaped >= maxAllowedEscaped)
     {
         currentState = gameStatus.gameover;
     }
     else if (waveNumber == 0 && (TotalKilled + RoundEscaped) == 0)
     {
         currentState = gameStatus.play;
     }
     else if (waveNumber >= totalWaves)
     {
         Debug.Log("waveNumber >= totalWaves");
         currentState = gameStatus.win;
     }
     else
     {
         currentState = gameStatus.next;
     }
 }
コード例 #29
0
 private void setCurrentGameState()
 {
     //hard coded after 10 escaped enemies the game is over
     if (TotalEscaped >= 10)
     {
         currentState = gameStatus.gameover;
     }
     else if (waveNumber == 0 && (TotalKilled + WaveEscaped) == 0)
     {
         currentState = gameStatus.play;
     }
     else if (waveNumber >= totalWaves)
     {
         currentState = gameStatus.win;
     }
     else
     {
         currentState = gameStatus.next;
     }
 }
コード例 #30
0
ファイル: BoardScorer.cs プロジェクト: randomdude/DoktorChess
        public BoardScorer(DoktorChessAIBoard toScore, pieceColour newViewpoint, scoreModifiers newModifiers)
        {
            modifiers = newModifiers;
            viewpoint = newViewpoint;
            List<square> myPieces = toScore.getPiecesForColour(viewpoint);
            List<square> enemyPieces = toScore.getPiecesForColour(viewpoint == pieceColour.black ? pieceColour.white : pieceColour.black);

            parentBoard = toScore;

            if (viewpoint == pieceColour.black)
            {
                _myMaterialAdvantage = toScore.blackMaterialAdvantage;
                _myMaterialDisadvantage = toScore.whiteMaterialAdvantage;
            } else if (viewpoint == pieceColour.white)
            {
                _myMaterialAdvantage = toScore.whiteMaterialAdvantage;
                _myMaterialDisadvantage = toScore.blackMaterialAdvantage;
            }

            _status = toScore.getGameStatus(myPieces, enemyPieces);
        }
コード例 #31
0
    // pick a random question from the List<Question> and display it
    void instantiateRandomQuestionToDisplay()
    {
        nextButton.image.color = Color.white;
        int randomNum = Random.Range(0, questions.Count);        // random a question

        currentQuestionObject = questions[randomNum];
        currentQuestion       = Instantiate(currentQuestionObject.gameObject, canvas.transform, false); // instantiate the prefab
        currentQuestionAnswer = Instantiate(currentQuestionObject.answerObject, canvas.transform, false);
        if (leftHandMode)
        {
            currentQuestion.transform.localPosition       = new Vector2(-currentQuestion.transform.localPosition.x + 30, 0);
            currentQuestionAnswer.transform.localPosition = new Vector2(-currentQuestionAnswer.transform.localPosition.x + 30, 0);
        }
        currentQuestionAnswer.SetActive(false);
        questionName.text   = currentQuestionObject.name;
        totalNumberOfCells += currentQuestionObject.numberOfCells;         // record the number of cells for calculating result

        // change the game status and deactivate the answer button
        currentStatus = gameStatus.InGame;
        displayAnswerButton.gameObject.SetActive(false);
    }
コード例 #32
0
ファイル: UIManager.cs プロジェクト: stopengin0012/RapSense
	IEnumerator ChangeTurnSpan(float sec){
		yield return new WaitForSeconds(sec);
		if(nowPlayer == 1){
			Change1to2();
		}else if(nowPlayer != 1 && nowStageNum < 4){
			StartCoroutine(NowStageUIIn());
			StartCoroutine(GameStartCor());
		}else{
			OutPanel2();
			state = gameStatus.End;
			StartCoroutine(EndGame());
		}
	}