Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class WoundController : MonoBehaviour
- {
- public Humanoid humanoid_cs;
- public bool Bot;
- private void OnCollisionEnter2D(Collision2D collision)
- {
- Debug.Log("Oke, be collision");
- if (collision.gameObject.tag == "Danger")
- {
- Debug.Log("Oke, this danger and be collision");
- if (humanoid_cs != null)
- {
- humanoid_cs.Wound(Vector2.zero, this.gameObject);
- }
- }
- else if (collision.gameObject.tag == "DamageBot" && Bot)
- {
- Debug.Log("Oke, this DamageBot and be collision");
- if (humanoid_cs != null)
- {
- humanoid_cs.Wound(Vector2.zero, this.gameObject);
- }
- }
- }
- }
- using System.Collections;
- using UnityEngine;
- public class Humanoid : MonoBehaviour
- {
- public GunMechanics gunMechanics_cs;
- public Transform PsBlood_tr;
- public Bot bot_cs;
- [SerializeField] public Gun gun;
- [SerializeField] public bool die = false;
- public GameObject[] toAddRbOfDie;
- public Animator animator;
- public GameObject Body;
- private void Start()
- {
- if (bot_cs != null)
- {
- gun = bot_cs.gun;
- }
- }
- public void Wound(Vector2 _contant, GameObject _parent)
- {
- if (!die)
- {
- Die();
- }
- GameObject ps = Instantiate(PsBlood_tr.gameObject, _contant, Quaternion.identity, _parent.transform);
- ps.SetActive(true);
- ps.GetComponent<ParticleSystem>().Play();
- StartCoroutine(StopBlood(ps));
- }
- void Die()
- {
- die = true;
- Destroy(GetComponent<Animator>());
- GetComponent<Rigidbody2D>().simulated = false;
- Destroy(animator);
- foreach (GameObject i in toAddRbOfDie)
- {
- i.GetComponent<Rigidbody2D>().simulated = true;
- }
- }
- IEnumerator StopBlood(GameObject _PS)
- {
- _PS.transform.position = new Vector3(transform.position.x, transform.position.y, -3f);
- yield return new WaitForSeconds(Random.Range(5f, 10f));
- Destroy(_PS);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement