Exemplo n.º 1
0
    public override State Update()
    {
        IceSlimeBossAI iceSlimeBossAI = (IceSlimeBossAI)GetAI();
        IceSlimeBoss   iceSlimeBoss   = (IceSlimeBoss)iceSlimeBossAI.getCharacter();
        GameObject     myBody         = iceSlimeBoss.GetGameObject();

        attackRange = iceSlimeBoss.getAttr().getAttackRange();
        speed       = iceSlimeBoss.getAttr().getSpeed();

        float distance = Vector3.Distance(myBody.transform.position, iceSlimeBoss.currentTarget.transform.position);

        if (distance < attackRange)
        {
            myBody.GetComponent <Rigidbody2D>().velocity = Vector3.zero;
            return(State.SUCESSED);
        }
        Vector3 dir = (iceSlimeBoss.currentTarget.transform.position - myBody.transform.position).normalized;

        myBody.GetComponent <Rigidbody2D>().velocity = dir * GetAI().getCharacter().getAttr().getSpeed() * Time.deltaTime;
        return(State.RUNNING);
    }
Exemplo n.º 2
0
    //碰撞判定
    void OnTriggerEnter2D(Collider2D collider)
    {
        IBullet bullet = collider.GetComponent <IBullet>();

        if (bullet != null)
        {
            iceSlimeBoss.UnderAttack(bullet.GetWeapon().GetOwner());
            if (iceSlimeBoss.getAttr().getHealth() <= 0)
            {
                Destroy(gameObject);
            }
        }
    }
Exemplo n.º 3
0
    public override State Update()
    {
        IceSlimeBossAI iceSlimeBossAI = (IceSlimeBossAI)GetAI();
        IceSlimeBoss   iceSlimeBoss   = (IceSlimeBoss)iceSlimeBossAI.getCharacter();
        GameObject     myBody         = iceSlimeBoss.GetGameObject();

        float distance = Vector3.Distance(myBody.transform.position, iceSlimeBoss.currentTarget.transform.position);

        if (distance < iceSlimeBoss.getAttr().getAttackRange())
        {
            Debug.Log("距离足够");
            return(State.SUCESSED);
        }
        Debug.Log("距离不够");
        return(State.FAILED);
    }