示例#1
0
        /**
         * Perform multiple actions when binding to an ActionAcceptor
         */

        public void Bind(IBinder binder)
        {
            IActionPerformer   performer   = binder as IActionPerformer;
            PerformableActions performable = performer.PerformableActions;
            AcceptableActions  acceptable  = binder.BoundAcceptor.AcceptableActions;

            performable.RefreshEnabledActions();
            acceptable.Bind(performer);
            acceptable.RefreshEnabledActions();

            PerformerAction matching = null;

            foreach (var action in performable.EnabledActions)
            {
                AcceptorAction acceptorAction;
                if (acceptable.EnabledActions.TryGetValue(action.Key, out acceptorAction))
                {
                    PerformerAction performerAction = action.Value;
                    performerAction.Bind(acceptorAction.AcceptCondition);
                    matching = performerAction;
                    break;
                }
            }

            StartCoroutine(PerformActions(binder, matching));
        }
示例#2
0
        IEnumerator Perform(PerformerAction action)
        {
            float time  = action.Duration;
            float eTime = 0;

            while (eTime < time)
            {
                eTime += Time.deltaTime;
                action.Perform(eTime / time);
                yield return(null);
            }

            action.End();
        }
示例#3
0
        IEnumerator PerformActions(IBinder binder, PerformerAction action)
        {
            if (action != null)
            {
                yield return(StartCoroutine(Perform(action)));

                Bind(binder);
            }
            else
            {
                IActionPerformer performer = binder as IActionPerformer;
                performer.PerformableActions.RefreshEnabledActions();
                binder.OnEndActions();
            }
        }
示例#4
0
        /**
         * Perform a single action
         */

        public void StartAction(PerformerAction action)
        {
            StartCoroutine(Perform(action));
        }