예제 #1
0
    //to handle the player ControllerColliderHit information
    void OnControllerColliderHit(ControllerColliderHit incoming)
    {
        if (presentPlayerState != playerStates.Alive)
        {
            return;
        }

        //for player hit zombies when shield is off
        if (incoming.collider.name.Contains("Zombie") && !ShieldIcon)
        {
            SoundController.Static.PlayDeadSound();            //for player dead sound
            presentPlayerState = playerStates.dead;            //to take player is which state
            GameController.Static.isplayerDaed = true;
            incoming.collider.isTrigger        = true;
            Ace_IngameUiControl.Static.GameEnd();                                                                  //to calling gameEnd function
            sword.SetActive(false);                                                                                //to sword deactive when player is dead
            GameObject obj = Instantiate(PlayerDeadEffect, thisTrans.position, Quaternion.identity) as GameObject; //to player dead effect
            Destroy(obj, 0.5f);                                                                                    //for destroy zombie after some time
            Destroy(incoming.collider.gameObject.GetComponent <Collider> ());                                      //for destroy zombie collider
            GameObject.Find("Main Camera").GetComponent <CameraShake> ().enabled = true;                           //for camera shaking
        }
        //for player hit Obsticles when shield is off
        else if (incoming.collider.tag.Contains("Obstacles") && !ShieldIcon)
        {
            presentPlayerState = playerStates.dead;            //to take player is which state

            GameController.Static.isplayerDaed = true;
            SoundController.Static.PlayDeadSound();                                                                 //for player dead sound
            Ace_IngameUiControl.Static.GameEnd();                                                                   //to calling gameEnd function
            GameObject obj1 = Instantiate(PlayerDeadEffect, thisTrans.position, Quaternion.identity) as GameObject; //to player dead effect
            Destroy(obj1, 0.3f);                                                                                    //for destroy zombie after some time
            Destroy(incoming.collider.GetComponent <GameObject> ());                                                //for destroy zombie collider
            sword.SetActive(false);                                                                                 //to sword deactive when player is dead
            GameObject.Find("Main Camera").GetComponent <CameraShake> ().enabled = true;                            //for camera shaking
        }
        //for player hit Rock when shield is off
        else if (incoming.collider.name.Contains("Rock") && !ShieldIcon)
        {
            presentPlayerState = playerStates.dead;            //to take player is which state

            GameController.Static.isplayerDaed = true;
            SoundController.Static.PlayDeadSound();                                                                 //for player dead sound
            Ace_IngameUiControl.Static.GameEnd();                                                                   //to calling gameEnd function
            GameObject obj2 = Instantiate(PlayerDeadEffect, thisTrans.position, Quaternion.identity) as GameObject; //to player dead effect
            Destroy(obj2, 0.3f);                                                                                    //for destroy zombie after some time
            Destroy(incoming.collider.gameObject.GetComponent <Collider> ());                                       //for destroy zombie collider
            sword.SetActive(false);                                                                                 //to sword deactive when player is dead
            GameObject.Find("Main Camera").GetComponent <CameraShake> ().enabled = true;                            //for camera shaking
        }
        //for player hit zombies when shield is on
        if (incoming.collider.name.Contains("Zombie") && (ShieldIcon || !isPlayerOnTheGround))
        {
            ZombieController zombieScript = incoming.collider.GetComponent <ZombieController> ();
            zombieScript.DeathState();
            Ace_IngameUiControl.Static.inGameScoreCount++;
        }
        //for player hit Obsticles when shield is on
        else if (incoming.collider.tag.Contains("Obsticles") && ShieldIcon)
        {
            Destroy(incoming.collider.gameObject);
        }
        //for player hit Rock when shield is off
        else if (incoming.collider.name.Contains("Rock") && ShieldIcon)
        {
            Destroy(incoming.collider.transform.parent.gameObject);
        }
        else if (incoming.collider.name.Contains("broken_pot") || incoming.collider.name.Contains("broken_pot") && ShieldIcon)
        {
            incoming.gameObject.GetComponent <Collider> ().isTrigger = true;
        }
    }