Exemplo n.º 1
0
 void OnCollisionEnter2D(Collision2D col)
 {
     audio.Play();
     if (col.gameObject.tag == "Brick" && exploding)
     {
         explode = true;
         StartCoroutine(OffExplodeBall());
     }
     if (col.gameObject.tag == "Player")
     {
         GetComponent <Rigidbody2D>().velocity = new Vector2((transform.position.x - col.gameObject.transform.position.x) / col.gameObject.transform.lossyScale.x, 1).normalized *speed;
     }
     else if (col.gameObject.tag == "Dead Zone")
     {
         Debug.Log(number + ", " + GameStatic.GetBalls());
         if (GameStatic.GetLifes() - 1 <= 0 && number <= 1)
         {
             Debug.Log("koniec");
             GameStatic.SetLifes(GameStatic.GetLifes() - 1);
             gameOver.GetComponent <GameOver>().change = true;
             Destroy(gameObject);
             return;
         }
         else
         {
             if (number > 1)
             {
                 Destroy(gameObject);
                 return;
             }
             else
             {
                 GameStatic.SetLifes(GameStatic.GetLifes() - 1);
                 transform.localPosition = new Vector3(player.position.x, transformY, 0);
                 GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0);
                 GameObject go = GameObject.FindGameObjectWithTag("Player");
                 go.GetComponent <Player>().ball = gameObject;
                 move = false;
             }
         }
     }
     if (GetComponent <Rigidbody2D>().velocity.y < 0.2f && GetComponent <Rigidbody2D>().velocity.y >= 0)
     {
         GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0.2f) * speed;
     }
     else if (GetComponent <Rigidbody2D>().velocity.y > -0.2f && GetComponent <Rigidbody2D>().velocity.y < 0)
     {
         GetComponent <Rigidbody2D>().velocity = new Vector2(0, -0.2f) * speed;
     }
     if (GetComponent <Rigidbody2D>().velocity.magnitude < 4f && move)
     {
         GetComponent <Rigidbody2D>().velocity = GetComponent <Rigidbody2D>().velocity.normalized *speed;
     }
     if (!move)
     {
         GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0);
     }
 }
Exemplo n.º 2
0
 void Start()
 {
     bounce.bounciness = 1;
     str = GameStatic.LoadScore();
     scoresContent.offsetMin = new Vector2(scoresContent.offsetMin.x, int.Parse(str[2]) * -45);
     scoresNames.GetComponent <RectTransform>().offsetMin  = new Vector2(scoresNames.GetComponent <RectTransform>().offsetMin.x, int.Parse(str[2]) * -45);
     scoresValues.GetComponent <RectTransform>().offsetMin = new Vector2(scoresValues.GetComponent <RectTransform>().offsetMin.x, int.Parse(str[2]) * -45);
     scoresNames.GetComponent <Text>().text  = str[0];
     scoresValues.GetComponent <Text>().text = str[1];
 }
Exemplo n.º 3
0
 public void Disruption()
 {
     if (number < 7)
     {
         GameObject newObject  = Instantiate(gameObject, transform.position, transform.rotation) as GameObject;
         GameObject newObject2 = Instantiate(gameObject, transform.position, transform.rotation) as GameObject;
         newObject.GetComponent <Ball>().StartMove();
         newObject2.GetComponent <Ball>().StartMove();
         GameStatic.SetBalls((byte)(GameStatic.GetBalls() + 2));
     }
 }
Exemplo n.º 4
0
 void Start()
 {
     GameStatic.Revive();
     if (!GameStatic.IsNext())
     {
         GameStatic.ZeroAllScore();
     }
     GameStatic.ZeroScore();
     GameStatic.SetMaxScore(maxScore);
     GameStatic.SaveUnlockedLevels(world, lvl);
 }
Exemplo n.º 5
0
 void FixedUpdate()
 {
     if (score != GameStatic.GetScore())
     {
         col1  = 20 + (180 / GameStatic.GetMaxScore()) * GameStatic.GetScore();
         score = GameStatic.GetScore();
     }
     if (col1 != col2)
     {
         col2++;
         color = new Color(col2 / 255f, col2 / 255f, col2 / 255f);
         background.GetComponent <SpriteRenderer>().color = color;
     }
 }
Exemplo n.º 6
0
 void OnDestroy()
 {
     if (scoring)
     {
         GameStatic.AddScore();
     }
     if (GameStatic.CheckScore())
     {
         GameStatic.ZeroScore();
         if (!GameObject.FindGameObjectWithTag("GameOver").GetComponent <GameOver>().change&& SceneManager.GetActiveScene().buildIndex + 1 >= GameStatic.levels)
         {
             SceneManager.LoadScene(1);
         }
         else if (!GameObject.FindGameObjectWithTag("GameOver").GetComponent <GameOver>().change&& SceneManager.GetActiveScene().buildIndex + 1 < GameStatic.levels)
         {
             GameStatic.SetNext(true);
             SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
         }
         else
         {
             GameObject.FindGameObjectWithTag("GameOver").GetComponent <GameOver>().change = true;
         }
     }
 }
Exemplo n.º 7
0
 void OnDestroy()
 {
     --number;
     GameStatic.SetBalls(GameStatic.GetBalls() - 1);
 }
Exemplo n.º 8
0
 void Update()
 {
     score.text = "Score: " + GameStatic.GetAllScore();
     lives.text = "Lifes: " + GameStatic.GetLifes();
 }
Exemplo n.º 9
0
 // Update is called once per frame
 void Update()
 {
     if (change)
     {
         GameStatic.SetNext(false);
         if (c1.a < 1)
         {
             c1.a      += 0.01f;
             c2.a      += 0.01f;
             im.color   = c1;
             text.color = c2;
         }
         else
         {
             Destroy(Button);
             change  = false;
             change2 = true;
         }
     }
     if (change2)
     {
         if (text.transform.localScale.y > 0)
         {
             text.transform.localScale = new Vector3(text.transform.localScale.x, text.transform.localScale.y - 0.05f, text.transform.localScale.z);
         }
         else
         {
             text.text = "Type your name";//alt+0160
             change2   = false;
             change3   = true;
         }
     }
     if (change3)
     {
         if (text.transform.localScale.y < 1)
         {
             text.transform.localScale = new Vector3(text.transform.localScale.x, text.transform.localScale.y + 0.05f, text.transform.localScale.z);
             c3.a          += 0.05f;
             c4.a          += 0.05f;
             c5.a          += 0.05f;
             textName.color = c4;
             inputName.GetComponent <Image>().color = c5;
         }
         else
         {
             change3 = false;
         }
     }
     if (change4 && change4_1)
     {
         if (text.transform.localScale.y > 0)
         {
             text.transform.localScale = new Vector3(text.transform.localScale.x, text.transform.localScale.y - 0.05f, text.transform.localScale.z);
         }
         else
         {
             text.text   = "Tap to save";//alt+0160
             change4_1   = false;
             change5     = true;
             End.enabled = true;
         }
     }
     if (change5)
     {
         if (text.transform.localScale.y < 1)
         {
             text.transform.localScale = new Vector3(text.transform.localScale.x, text.transform.localScale.y + 0.05f, text.transform.localScale.z);
         }
         else
         {
             change5 = false;
         }
     }
 }
Exemplo n.º 10
0
 public void Save()
 {
     GameStatic.SaveScore(textName.text);
     ChangeScene.menuScore = true;
     ChangeScene.Change(0);
 }
Exemplo n.º 11
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Player")
     {
         if ((byte)bonus == 0)
         {
             col.gameObject.GetComponent <Player>().Enlarge(0.1F);
         }
         else if ((byte)bonus == 1)
         {
             col.gameObject.GetComponent <Player>().Reduce(0.1F);
         }
         else if ((byte)bonus == 2)
         {
             GameObject[] gos = GameObject.FindGameObjectsWithTag("Ball") as GameObject[];
             foreach (GameObject go in gos)
             {
                 go.GetComponent <Ball>().Disruption();
             }
         }
         else if ((byte)bonus == 3)
         {
             GameStatic.SetLifes(GameStatic.GetLifes() + 1);
         }
         else if ((byte)bonus == 4)
         {
             GameObject[] gos = GameObject.FindObjectsOfType(typeof(GameObject)) as GameObject[];
             foreach (GameObject go in gos)
             {
                 if (go.CompareTag("Ball"))
                 {
                     go.GetComponent <Ball>().FireBall();
                 }
             }
         }
         else if ((byte)bonus == 5)
         {
             Instantiate(barrier, new Vector3(0, -3.08f, 0.1f), new Quaternion(0, 0, 0, 0));
         }
         else if ((byte)bonus == 6)
         {
             col.gameObject.GetComponent <Player>().Fire();
         }
         else if ((byte)bonus == 7)
         {
             GameObject[] gos = GameObject.FindObjectsOfType(typeof(GameObject)) as GameObject[];
             foreach (GameObject go in gos)
             {
                 if (go.CompareTag("Ball"))
                 {
                     go.GetComponent <Ball>().ExplodingBall();
                 }
             }
         }
         Destroy(gameObject);
     }
     else if (col.gameObject.tag == "Dead Zone")
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 12
0
 public void ShowCursor()
 {
     GameStatic.DeactivateChildren(gameObject, true, "FireShoot");
 }
Exemplo n.º 13
0
 public void HideCursor()
 {
     GameStatic.DeactivateChildren(gameObject, false, "FireShoot");
 }
Exemplo n.º 14
0
 public void Change(string scene)
 {
     GameStatic.SetNext(true);
     ChangeScene.Change(scene);
 }