Advertisement
Guest User

Ask

a guest
Sep 23rd, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.20 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class WoundController : MonoBehaviour
  4. {
  5.     public Humanoid humanoid_cs;
  6.     public bool Bot;
  7.  
  8.     private void OnCollisionEnter2D(Collision2D collision)
  9.     {
  10.         Debug.Log("Oke, be collision");
  11.  
  12.         if (collision.gameObject.tag == "Danger")
  13.         {
  14.             Debug.Log("Oke, this danger and be collision");
  15.  
  16.             if (humanoid_cs != null)
  17.             {
  18.                 humanoid_cs.Wound(Vector2.zero, this.gameObject);
  19.             }
  20.         }
  21.         else if (collision.gameObject.tag == "DamageBot" && Bot)
  22.         {
  23.             Debug.Log("Oke, this DamageBot and be collision");
  24.  
  25.             if (humanoid_cs != null)
  26.             {
  27.                 humanoid_cs.Wound(Vector2.zero, this.gameObject);
  28.             }
  29.         }
  30.     }
  31. }
  32.  
  33. using System.Collections;
  34. using UnityEngine;
  35.  
  36. public class Humanoid : MonoBehaviour
  37. {
  38.     public GunMechanics gunMechanics_cs;
  39.     public Transform PsBlood_tr;
  40.     public Bot bot_cs;
  41.  
  42.     [SerializeField] public Gun gun;
  43.     [SerializeField] public bool die = false;
  44.  
  45.     public GameObject[] toAddRbOfDie;
  46.     public Animator animator;
  47.     public GameObject Body;
  48.  
  49.  
  50.     private void Start()
  51.     {
  52.         if (bot_cs != null)
  53.         {
  54.             gun = bot_cs.gun;
  55.         }
  56.     }
  57.  
  58.     public void Wound(Vector2 _contant, GameObject _parent)
  59.     {
  60.         if (!die)
  61.         {
  62.             Die();
  63.         }
  64.         GameObject ps = Instantiate(PsBlood_tr.gameObject, _contant, Quaternion.identity, _parent.transform);
  65.         ps.SetActive(true);
  66.         ps.GetComponent<ParticleSystem>().Play();
  67.  
  68.         StartCoroutine(StopBlood(ps));
  69.     }
  70.  
  71.     void Die()
  72.     {
  73.         die = true;
  74.  
  75.         Destroy(GetComponent<Animator>());
  76.  
  77.         GetComponent<Rigidbody2D>().simulated = false;
  78.         Destroy(animator);
  79.  
  80.         foreach (GameObject i in toAddRbOfDie)
  81.         {
  82.             i.GetComponent<Rigidbody2D>().simulated = true;
  83.         }
  84.  
  85.     }
  86.  
  87.     IEnumerator StopBlood(GameObject _PS)
  88.     {
  89.         _PS.transform.position = new Vector3(transform.position.x, transform.position.y, -3f);
  90.         yield return new WaitForSeconds(Random.Range(5f, 10f));
  91.         Destroy(_PS);
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement