void Start() { Space_Img.SetActive(false); AdManager.AdManage.bannerView.Destroy(); AdManager.AdManage.Request_Banner(); GameOverController.End_Panel.SetActive(false); StartGame = false; StartGameCountdownEnded = false; current_score = 0; temp_score = 0; Application.targetFrameRate = 200; Screen.sleepTimeout = SleepTimeout.NeverSleep; Player = GameObject.Find("Player"); rb = Player.GetComponent <Rigidbody2D>(); Left_Portal = GameObject.Find("Left_Portal"); Right_Portal = GameObject.Find("Right_Portal"); Current_World_Img = GameObject.Find("Current_World_Img"); Left_World_Img = GameObject.Find("Left_World_Img"); Right_World_Img = GameObject.Find("Right_World_Img"); Game_Sound.Play(); BlockList_Hide(); CarrotList_Hide(); Player.GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation; PlayerDataUpgrade loadedData = SaveLoadUpgrade.LoadPlayer(); Score_Multiplier = loadedData.Score_Multiplier; }
void OnCollisionEnter2D(Collision2D col) { rb.drag = 0; player_min_pos = Player.transform.localPosition; float x = 0; Player.GetComponent <Animator>().SetBool("isPlayerDownTrigger", false); Player.GetComponent <Animator>().SetBool("isPlayerDown", false); Player.GetComponent <Animator>().SetBool("isPlayerUp", true); if (StartGame && StartGameCountdownEnded) { x = getAcceleration(); } if (col.gameObject.tag == "jumpblock") { Player.GetComponent <Animator>().SetTrigger("isPlayerJump"); col.gameObject.GetComponent <Animator>().SetTrigger("MushroomJump"); Mushroom_Sound.Play(); rb.AddForce(new Vector2(rb.velocity.x, 40f), ForceMode2D.Impulse); } else if (col.gameObject.tag == "toggle") { Break_Sound.Play(); rb.velocity = Vector2.zero; rb.AddForce(new Vector2(20 * x, 20f), ForceMode2D.Impulse); } else if (col.gameObject.tag == "startblock") { if (StartGameCountdownEnded) { for (int i = 0; i < GenerateBlocks.BlockList.Count; i++) { GenerateBlocks.BlockList[i].SetActive(true); } for (int i = 0; i < GenerateBlocks.CarrotList.Count; i++) { GenerateBlocks.CarrotList[i].SetActive(true); } StartGameScript.ins.Countdown.text = "Go!"; StartGameScript.Top_Panel.SetActive(true); StartGame = true; } } else if (col.gameObject.tag == "trap") { StartCoroutine(CameraShake.CamShake.Camera_Shake()); Game_Sound.Stop(); Ouch_Sound.Play(); Player.transform.localPosition = new Vector2(0, Player.transform.localPosition.y); StartGame = false; GameOver(); } else { Grass_Sound.Play(); rb.velocity = Vector2.zero; rb.AddForce(new Vector2(20 * x, 20f), ForceMode2D.Impulse); } }