Пример #1
0
    void Shoot(int weapon)
    {
        switch (weapon)
        {
        case 1:
            if (Values.GetRevolvAmmo() > 0)
            {
                Ray        ray = new Ray(Camera.main.transform.position + transform.forward * 0.2f, Camera.main.transform.forward);
                RaycastHit hit;
                Revolver.gameObject.GetComponent <AudioSource>().Play();
                if (Physics.Raycast(ray, out hit) && hit.distance < revolverDistance && hit.collider.gameObject.tag == "Enemy")
                {
                    //		Debug.Log ("Distance: " + hit.distance + " GameObject " + hit.collider.gameObject);
                    Values.ChangeFettHealth(revolverDamage);
                }
                Values.AddAmmo(-1);
                StartCoroutine(Cooldown());
            }
            break;

        case 2:
            if (Values.GetTrapAmmo() > 0)
            {
                Instantiate(TrapPrefub, Player.transform.position + Player.transform.forward, Quaternion.identity);
                Values.AddTrap(-1);
                StartCoroutine(Cooldown());
            }
            break;
        }
    }
Пример #2
0
 void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.tag == "Player")
     {
         Values.ChangePlayerHealth(trapDamage + 10);
         trigger.Play();
     }
     else if (col.gameObject.tag == "Enemy")
     {
         Values.ChangeFettHealth(trapDamage);
         trigger.Play();
     }
 }
Пример #3
0
 void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.tag == "Player")
     {
         Values.ChangePlayerHealth(wireDamage + 15);
         explode.Play();
         gameObject.transform.GetChild(0).gameObject.SetActive(false);
     }
     else if (col.gameObject.tag == "Enemy")
     {
         Values.ChangeFettHealth(wireDamage);
         explode.Play();
         gameObject.transform.GetChild(0).gameObject.SetActive(false);
     }
 }