public void gameOver(string playername)
 {
     Debug.Log("Game Over");
     if (playername == "AIPlayer")
     {
         hasWon = true;
         Debug.Log("For AI player");
         EnemyController.changeAnimationLost();
         GameObject ground = GameObject.Find("EnemyGround");
         Destroy(ground);
         GameObject playerFrameFloor = GameObject.Find("EnemyFrameFloor");
         Destroy(playerFrameFloor);
         GameObject AIPlayer = GameObject.Find("Player");
         Destroy(AIPlayer);
         GameObject YouWinComponents = GameObject.Find("YouWinComponents");
         YouWinComponents.transform.position = new Vector3(YouWinComponents.transform.position.x - 0.15f, YouWinComponents.transform.position.y + 3.50f, YouWinComponents.transform.position.z);
     }
     else
     {
         isGameOver = true;
         Debug.Log("For Human Player");
         EnemyController.changeAnimationWinning();
         EnemyLowerController.changeAnimationWinning();
         GameObject ground = GameObject.Find("Ground");
         Destroy(ground);
         GameObject playerFrameFloor = GameObject.Find("PlayerFrameFloor");
         Destroy(playerFrameFloor);
         GameObject AIPlayer = GameObject.Find("AIPlayer");
         Destroy(AIPlayer);
         // fade to black and go to game over screen after a certain amount of time
         StartCoroutine(Transition(3f));
     }
 }
Beispiel #2
0
    public void gameOver()
    {
        EnemyController.changeAnimationWinning();
        EnemyLowerController.changeAnimationWinning();
        GameObject beanDuo          = GameObject.Find("BeanDuo");
        GameObject beanHolders      = GameObject.Find("BeanHolders");
        GameObject enemybeanDuo     = GameObject.Find("EnemyBeanDuo");
        GameObject enemybeanHolders = GameObject.Find("EnemyBeanHolders");

        Destroy(beanDuo);
        Destroy(beanHolders);
        Destroy(enemybeanDuo);
        Destroy(enemybeanHolders);
        gameover = true;
        //play sound
        //disappear middle section of frame
        GameObject ground = GameObject.Find("Ground");

        Destroy(ground);
        GameObject playerFrameFloor = GameObject.Find("PlayerFrameFloor");

        //Add animation before destory
        Destroy(playerFrameFloor);
        StartCoroutine(MyFunction(0.1f));
    }
Beispiel #3
0
 /*in
  *  Detect Player collision with the bottom of the grid and call functions
  */
 public void OnCollisionEnter2D(Collision2D other)
 {
     if (NuisanceController.nuisanceState != 100)
     {
         squaresOccupied   += 2;
         objectCollidedWith = other.collider.gameObject.name;
         if (objectCollidedWith != "Ground")
         {
             string[] textSplit    = objectCollidedWith.Split(new string[] { "-" }, System.StringSplitOptions.None);
             int      firstNumber  = int.Parse(textSplit [1]);
             int      secondNumber = int.Parse(textSplit [2]);
             if (isMoveAllowed(firstNumber, secondNumber))
             {
                 updateGrid();
                 reinitGame();
             }
             else
             {
                 transform.position = oldPosition;
                 if (lastPressed == "r")
                 {
                     row--;
                 }
                 if (lastPressed == "l")
                 {
                     row++;
                 }
             }
         }
         else
         {
             if (squaresOccupied >= 29)
             {
                 EnemyController.changeAnimationWinning();
                 EnemyLowerController.changeAnimationWinning();
             }
             updateGrid();
             reinitGame();
         }
     }
     else
     {
         squaresOccupied += 1;
         nuisanceUpdateGrid();
         reinitGame();
     }
 }