void Move(int xStep, int zStep) { lastPosition.z = Mathf.RoundToInt(lastPosition.z += zStep); if (zStep == 1 || zStep == -1) { lastPosition.x = Mathf.RoundToInt(lastPosition.x += xStep); } else { lastPosition.x += xStep; } SoundManager.instance.PlayJump(); anim.Play("CharacterJumpUp"); CameraFollow.CameraMove(); }
/// <summary> /// Checking contact between the player /// </summary> void OnTriggerEnter2D(Collider2D col) { if (!isDie) { if (rb2d.velocity.y < 0 && col.tag.Equals("Platform")) { Jump(); camFollow.CameraMove(col.gameObject.transform.position); } else if (rb2d.velocity.y < 0 && col.tag.Equals("PlatformDestrucable")) { Jump(); camFollow.CameraMove(col.gameObject.transform.position); col.gameObject.GetComponent <DestructableLand>().Destruct(); } else if (rb2d.velocity.y < 5 && col.tag.Equals("Cloud")) { Jump(col.GetComponent <CloudEnemy>().jumpPower); camFollow.CameraMove(col.gameObject.transform.position); } else if (rb2d.velocity.y < 0 && col.tag.Equals("Spring")) { Jump(col.GetComponent <Spring>().jumpForce); col.GetComponent <Spring>().Springed(); springed = true; } else if (rb2d.velocity.y < 0 && col.tag.Equals("SpikeBuddy")) { sprSwitch.SwitchSprite(2); StartCoroutine(Die()); Invoke("SetToGameOver", 1.5f); //GameManager.instance.gameState = GameManager.GAME_STATE.GAMEOVER; } else if (rb2d.velocity.y < 5 && col.tag.Equals("SpikeUp")) { sprSwitch.SwitchSprite(2); StartCoroutine(Die()); Invoke("SetToGameOver", 1.5f); } else if (!gotPowers && rb2d.velocity.y > 0 && col.tag.Equals("SpikeBottom")) { sprSwitch.SwitchSprite(2); StartCoroutine(Die()); Invoke("SetToGameOver", 1.5f); } else if (col.tag.Equals("RocketItem")) { if (!gotPowers) { gotPowers = true; StartCoroutine(Rockets(col.GetComponent <RocketItem>().rocket.GetComponent <Rocket>().rocketForce, col.GetComponent <RocketItem>().rocket.GetComponent <Rocket>().timeRockets)); col.enabled = false; Instantiate(col.GetComponent <RocketItem>().rocket, Vector2.zero, Quaternion.identity); } iTween.ColorTo(col.gameObject, Color.clear, .2f); } else if (!gotPowers && col.tag.Equals("Lightning")) { sprSwitch.SwitchSprite(2); StartCoroutine(Die()); Invoke("SetToGameOver", 1.5f); //GameManager.instance.gameState = GameManager.GAME_STATE.GAMEOVER; } else if (col.tag.Equals("Coin")) { if (gotPowers || springed) { //Do Nothing } else { Jump(); camFollow.CameraMove(col.gameObject.transform.position); } GameManager.instance.coin += 1; col.GetComponent <Coin>().GotPoint(); if (GameManager.instance.coin >= 50 && PlayerPrefs.GetInt("CoinAccUnlocked", 0) == 0) { Services.UnlockingAchievement(Services.fiftyCoinsID); PlayerPrefs.SetInt("CoinAccUnlocked", 1); } } } }