Esempio n. 1
0
        void OnCollisionEnter(Collision col)
        {
            if (HeadHit() && !IsOnGround())
            {
                if (col.gameObject.tag == "WallBrickStandard")
                {
                    PlayClip("Brick_Hit");
                }
                if (col.gameObject.tag == "WallBrickDestroyed")
                {
                    PlayClip("Brick_Hit"); //TO DO Find another sound to play when a brick is destroyed
                }
            }

            if (IsPlatformHit() && col.gameObject.tag == "JumpPlatform")
            {
                onJumpPlatform = true;
            }

            if (col.gameObject.tag == "Bullet" || col.gameObject.tag == "Fire_Ball" ||
                col.gameObject.tag == "Spear_Head")
            {
                var scoreManager = (ScoreManager)FindObjectOfType(typeof(ScoreManager));
                var uiText       = scoreManager.LifeText.GetComponent <Text>();
                var life         = uiText.text;
                var lifesLeft    = life.Split(':')[1];
                if (Convert.ToInt32(lifesLeft) < 0)
                {
                    var levelManager = (LevelManager)FindObjectOfType(typeof(LevelManager));
                    levelManager.LoadLevel("Lose");
                }
                Debug.Log(lifesLeft);
            }

            if (col.gameObject.tag == "Weapon")
            {
                ps         = gameObject.GetComponent <PlayerShoot>();
                ps.enabled = true;
            }
        }
Esempio n. 2
0
 private void Start()
 {
     _playerInfo.SetPlayer(this);
     _playerShootComponent = GetComponent <PlayerShoot>();
     _playerController     = GetComponent <PlayerController>();
 }