示例#1
0
        void Update()
        {
            int  currentAnimationHash = _animator.GetCurrentAnimatorStateInfo(0).fullPathHash;
            bool inTransition         = _animator.IsInTransition(0);
            bool idle = currentAnimationHash == idleAnimationHash;

            if (idle && !inTransition)
            {
                BirdAction nextAction = _actionSelector.NextAction(_birdState);
                TriggerAction(nextAction.Action);
            }
        }
        public BirdAction NextAction(BirdState state)
        {
            Int16 percent = (Int16)UnityEngine.Random.Range(1, 100);
            // Much more likely to fly if worried

            /*
             * if (state == BirdState.Worried && percent < 30) {
             * _previousAction = BirdAction.Fly;
             * return _previousAction;
             * }
             */
            var        likelyAction = LikelyAction();
            BirdAction nextAction;

            do
            {
                percent    = (Int16)UnityEngine.Random.Range(1, 100);
                nextAction = likelyAction.Next(percent);
            } while(!nextAction.CanPerformAction(state));

            _previousAction = nextAction;
            return(_previousAction);
        }