示例#1
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        IFactionHolder holder = collision.transform.GetComponent <IFactionHolder>();

        // destroy self on enemy/neutral or on obstacles
        if (holder == null || holder.Faction != this.faction)
        {
            Destroy(gameObject);
        }
    }
示例#2
0
    private void Awake()
    {
        self  = GetComponent <IFactionHolder>();
        agent = GetComponent <PolyNav.PolyNavAgent>();

        Reporter.ComponentMissingCheck(self);
        Reporter.ComponentMissingCheck(agent);

        serachArea.radius = range;

        isAttacking = false;
    }
示例#3
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        // in attack mode no following
        if (isAttacking)
        {
            return;
        }

        IFactionHolder other = collision.GetComponent <IFactionHolder>();

        if (other != null)
        {
            if (other.Faction != self.Faction)
            {
                agent.SetDestination(collision.transform.position);
                target = collision.transform;
            }
        }
    }