Exemplo n.º 1
0
    public override void Enter()
    {
        FireSlimeAI fireSlimeAI = (FireSlimeAI)GetAI();
        FireSlime   fireSlime   = (FireSlime)fireSlimeAI.getCharacter();
        GameObject  myBody      = fireSlime.GetGameObject();

        attackRange        = fireSlime.getAttr().getAttackRange();
        attackRate         = fireSlime.getAttr().getAttackRate();
        fusedLaser         = fireSlime.GetFusedLaser();
        currentAttackRate  = 0;
        currentRecoverTime = 0;
        currentDuring      = fireDuring;
        count  = 3;
        isFire = false;
    }
Exemplo n.º 2
0
    public override void Enter()
    {
        FireSlimeAI fireSlimeAI = (FireSlimeAI)GetAI();
        FireSlime   fireSlime   = (FireSlime)fireSlimeAI.getCharacter();

        attackRange = fireSlime.getAttr().getAttackRange();
    }
Exemplo n.º 3
0
    //碰撞判定
    void OnTriggerEnter2D(Collider2D collider)
    {
        IBullet bullet = collider.GetComponent <IBullet>();

        if (bullet != null)
        {
            Debug.Log("被攻击");
            myCharacter.UnderAttack(bullet.GetWeapon().GetOwner());
            if (myCharacter.getAttr().getHealth() <= 0)
            {
                Destroy(gameObject);
            }
        }
    }
Exemplo n.º 4
0
    public override State Update()
    {
        FireSlimeAI fireSlimeAI = (FireSlimeAI)GetAI();
        FireSlime   fireSlime   = (FireSlime)fireSlimeAI.getCharacter();
        GameObject  myBody      = fireSlime.GetGameObject();

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

        //如果有目标在视野内,则移动向目标,直到可以攻击到目标
        if (distance < fireSlime.getAttr().getAttackRange())
        {
            myBody.GetComponent <Rigidbody2D>().velocity = Vector3.zero;
            return(State.SUCESSED);
        }

        Vector3 dir = (fireSlime.currentTarget.transform.position - myBody.transform.position).normalized;

        myBody.GetComponent <Rigidbody2D>().velocity = dir * GetAI().getCharacter().getAttr().getSpeed() * Time.deltaTime;

        return(State.RUNNING);;
    }