第三周2

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/vancooler/article/details/79955133

Boss 的行为方式:


巡逻的节点转换:

private enum MonsterState  
    {  
        AVOID,      //  避开障碍
        CHECK,       //原地观察  
        WALK,       //巡逻   
        CHASE,      //追击玩家  
        RETURN,      //玩家逃脱则返回  
        ATTACK,       //进入攻击模式

    }  
void RandomAction(num)  
    {  
        //更新行动时间  
        weight[]=getWeight(num) 
        //根据权重匹配数组
        float number = Random.Range(0, actionWeight[0] + actionWeight[1] + actionWeight[2]);  
        if (number <= actionWeight[0])  
        {  
            currentState = MonsterState.CHECK;  
            thisAnimator.SetTrigger("CHECK");  
        }  
        else if (actionWeight[0] < number && number <= actionWeight[0] + actionWeight[1])  
        {  
            currentState = MonsterState.ATTACK;  
            thisAnimator.SetTrigger("ATTACK");  
        }  
        if (actionWeight[0] + actionWeight[1] < number && number <= actionWeight[0] + actionWeight[1] + actionWeight[2])  
        {  
            currentState = MonsterState.WALK;  
            //随机一个朝向  
            targetRotation = Quaternion.Euler(0, Random.Range(1, 5) * 90, 0);  
            thisAnimator.SetTrigger("Walk");  
        }  
    }  




阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页