Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (ailibrary.thedistancetohero() <= Attackdistance && !ailibrary.havehinder())//判断自身的和玩家的状态,如果进入攻击范围,或者某个距离,那就不追了,执行相应函数(攻击函数)
        {
            nowmovetoplayer = false;
            ailibrary.playerstopmovetohero();
            ailibrary.playerstopmove();
            ailibrary.Attackpalyerwithmainskill();               //怪物攻击玩家
            ailibrary.lookatpalyer();                            //怪物实时朝向玩家
        }
        else if (ailibrary.thedistancetohero() > Attackdistance) //如果它大于某个临界值的话,那就智能的去追击玩家
        {
            nowmovetoplayer = true;
            ailibrary.playerstartmovetohero();
            ailibrary.MovetoplayerwithmoerAI();
        }
        else
        {
            ailibrary.nouseskill1();//不满足攻击的条件,那就强制攻击制否
        }

        //怪物一直追赶玩家
        if (nowmovetoplayer)
        {
            // ailibrary.MovetoplayerwithmoerAI();
        }



        //一直持续的函数

        ailibrary.selfbeAttack();     //一直检测自己被袭击
        ailibrary.showselflife();     //一直显示自己的血条
        //ailibrary.Movetoplayer();
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        actionmachine();//调用核心的逻辑重现函数

        //ai核心的switch,实际作出行动的执行行为
        switch (state)
        {
        case 0:                                                 //默认行为,默认的巡逻方式

            if (patrolmonster)
            {
                ailibrary.monsterpatrol();
            }
            else
            {
                ailibrary.monsterrandomwalk();
            } break;

        case 1:       //逃跑行为,从默认行为转换为逃跑行为
            ailibrary.monsterescape();
            break;

        case 2:       //停止行为 仅从逃跑行为转成暂时停止
            ailibrary.playerstopmove();
            break;

        case 3:       //追击玩家
            ailibrary.playerstopmove();
            ailibrary.playerstartmovetohero();
            ailibrary.MovetoplayerwithmoerAI();
            // Debug.Log("isinview = " + ailibrary.playerisinAttackview());
            //Debug.Log("havehender = " + !ailibrary.havehinder());
            break;

        case 4:       //攻击玩家,初始版
            if (ismoreaiattack)
            {
                ailibrary.moreAIattack();
            }
            else
            {
                ailibrary.AIAttack();
            }

            //ailibrary.playerstopmovetohero();
            //ailibrary.playerstopmove();
            //ailibrary.Attackpalyer();//怪物攻击玩家
            //ailibrary.lookatpalyer();//怪物实时朝向玩家
            break;
        }

        //一直持续的函数

        ailibrary.selfbeAttack();     //一直检测自己被袭击
        ailibrary.showselflife();     //一直显示自己的血条
                                      //ailibrary.Movetoplayer();
        if (transform.position.y < -100)
        {
            Destroy(gameObject);
        }
        if (ailibrary.lifeValue <= 0)
        {
            Invoke("destroyself", 3f);
        }
        //Debug.Log("state = "+state);
    }