Exemplo n.º 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.GetComponent <HostageManager>() != null)
        {
            HostageManager manager = collision.GetComponent <HostageManager>();
            //Add collision force
            collision.GetComponent <Rigidbody2D>().AddForce(GetComponent <Rigidbody2D>().GetPointVelocity(collision.transform.position) * GetComponent <Rigidbody2D>().mass);

            //'Disable' bullet
            this.GetComponent <Rigidbody2D>().isKinematic     = true;
            this.GetComponent <SpriteRenderer>().enabled      = false;
            this.GetComponent <Collider2D>().isTrigger        = false;
            this.GetComponent <Rigidbody2D>().velocity        = Vector2.zero;
            this.GetComponent <Rigidbody2D>().angularVelocity = 0;
            Instantiate(blood).transform.position             = collision.transform.position;
            if (manager.hostage != null)
            {
                if (manager.hostage.type == HostageType.NORMAL)
                {
                    manager.ComputeDeath();
                }
            }
        }
        else if (collision.GetComponent <PlayerManager>() != null)
        {
            Instantiate(blood).transform.position = collision.transform.position;
            collision.GetComponent <PlayerManager>().HP--;
        }
        StartCoroutine(DestroySelf());
    }
Exemplo n.º 2
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.transform.tag == "Player")
     {
         HostageManager.SaveHostage(this);
         ScoreManager.AddScore(point);
         PlayRescueEffect();
     }
 }
Exemplo n.º 3
0
 void Awake()
 {
     instance  = this;
     rescues   = new List <Hostage>();
     observers = new List <IObserver <Hostage> >();
 }