Exemplo n.º 1
0
 /// <summary>
 /// Start is called on the frame when a script is enabled just before
 /// any of the Update methods is called the first time.
 /// </summary>
 void Start()
 {
     self = gameObject.GetComponent <BallModule>();
     gameObject.GetComponent <Renderer>().material = levelMatrials[ballCurrentLevel - 1];
     ballSizeCurrent = ballSizeInit + 5 * GM.Instance.ballSizeStep * (ballCurrentLevel - 1);
     gameObject.transform.localScale += new Vector3(1, 1, 1) * (ballSizeCurrent - 1) * GM.Instance.ballSizeStep;
 }
Exemplo n.º 2
0
 private void initPlayers()
 {
     player = GameObject.Find("Player").GetComponent <BallModule>();
     GameObject[] enemies = GameObject.FindGameObjectsWithTag("enemy");
     players.Add(player);
     for (int i = 0; i < enemies.Length; i++)
     {
         players.Add(enemies[i].GetComponent <BallModule>());
     }
 }
Exemplo n.º 3
0
 private void setText(Text text, string content, BallModule ball)
 {
     if (ball == GM.Instance.getPlayer())
     {
         text.color = Color.yellow;
     }
     else
     {
         text.color = Color.black;
     }
     text.text = content;
 }
Exemplo n.º 4
0
 private void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.tag == "obstacle")
     {
         Obst obst = (Obst)col.gameObject.GetComponent <Obst>();
         if (ballCurrentLevel < obst.obstLevel)
         {
             GM.Instance.levelDown++;
             LevelInit();
         }
         else if (ballCurrentLevel == obst.obstLevel)
         {
             LevelUp();
             //Destroy(col.gameObject);
         }
     }
     if (col.gameObject.tag == "enemy")
     {
         BallModule enemy = (BallModule)col.gameObject.GetComponent <BallModule>();
         // if (ballCurrentLevel < enemy.ballCurrentLevel)
         // {
         //     GM.Instance.smallerInCollision++;
         //     LevelDown();
         //     int CoinNum = 0;
         //     BallBounce(gameObject);
         //     if (coinTotal > 5)
         //     {
         //         CoinNum = 5;
         //         coinTotal -= 5;
         //     }
         //     else
         //     {
         //         CoinNum = coinTotal;
         //         coinTotal = 0;
         //     }
         //     enemy.SpreadCoins(CoinNum);
         // }
         if (ballCurrentLevel > enemy.ballCurrentLevel)
         {
             GM.Instance.biggerInCollision++;
         }
         if (ballCurrentLevel < enemy.ballCurrentLevel)
         {
             GM.Instance.smallerInCollision++;
             this.LevelDown();
             int CoinNum = 0;
             BallBounce(col.gameObject);
             if (this.coinTotal > 5)
             {
                 CoinNum         = 5;
                 this.coinTotal -= 5;
             }
             else
             {
                 CoinNum        = this.coinTotal;
                 this.coinTotal = 0;
             }
             this.SpreadCoins(CoinNum);
         }
         GM.Instance.totalCollision++;
     }
 }