第三周2

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");  
        }  
    }  




猜你喜欢

转载自blog.csdn.net/vancooler/article/details/79955133