示例#1
0
    //collision method
    protected override void OnCollisionEnter2D(Collision2D collision)
    {
        base.OnCollisionEnter2D(collision);

        if (collision.gameObject.tag == "Enemy")
        {
            BEnemy enemy = collision.gameObject.GetComponent <BEnemy>();
            enemy.health -= damage;

            GameObject.Find("Sound Manager").GetComponent <SoundManager>().PlayOneShot("Arrow_Hit");

            Rigidbody2D enemyRigidbody = collision.gameObject.GetComponent <Rigidbody2D>();
            enemyRigidbody.transform.Translate((transform.position - source.transform.position).normalized * .2f, Space.World);

            if (collision.gameObject.name == "Boss")
            {
                var eventObj = new Events.ComeToMeEvent(source.transform.position);
                eventObj.addListener(collision.gameObject);
                Events.EventManager.Instance.addEvent(eventObj, 0f);
            }
        }
        else if (collision != null)
        {
            GameObject.Find("Sound Manager").GetComponent <SoundManager>().PlayOneShot("Arrow_Hit_Obstacle");
        }
    }
示例#2
0
 public override void handleEvent(ComeToMeEvent eventObj)
 {
     if (!(enemy.mainGoal.getFrontMostSubgoal() is HandleComeToMe))
     {
         enemy.mainGoal.forwardGoal(new HandleComeToMe(enemy, eventObj));
     }
 }
示例#3
0
 public virtual void handleEvent(ComeToMeEvent eventObj)
 {
     throw new NotImplementedException();
 }