Ejemplo n.º 1
0
        //Actions
        public bool TryGetAction(UseActionButton useButton, out UseAction action)
        {
            int maxPriority            = int.MinValue;
            int maxPriorityActionIndex = -1;

            if (availableActions.ContainsKey(useButton))
            {
                for (int i = 0; i < availableActions[useButton].Count; i++)
                {
                    var curAction = availableActions[useButton][i];
                    if (curAction.AvailableForChar(this) && curAction.Priority > maxPriority)
                    {
                        //action = availableActions[useButton][i];
                        maxPriorityActionIndex = i;
                        maxPriority            = curAction.Priority;
                    }
                }
            }
            if (maxPriorityActionIndex != -1)
            {
                action = availableActions[useButton][maxPriorityActionIndex];
                return(true);
            }
            else
            {
                action = null;
                return(false);
            }
        }
Ejemplo n.º 2
0
        protected bool TryExecuteAction(UseActionButton button)
        {
            UseAction action;

            if (charController.TryGetAction(button, out action))
            {
                ExecuteAction(action);
                return(true);
            }
            return(false);
        }