示例#1
0
        private void SetCommand(FsmInput type, float value = 0f)
        {
            var command = CommandsContainer.GetAvailableItem();

            command.Type            = type;
            command.AdditioanlValue = value;
        }
示例#2
0
        protected void SetNewCommandFromFunctionCall(FsmInput type, float additionalValue = 0)
        {
            Logger.DebugFormat("Request Do Action : {0}   AdditionalValue  : {1}", type, additionalValue);
            var availableCommand = commandsContainer.GetAvailableItem();

            availableCommand.Type            = type;
            availableCommand.AdditionalValue = additionalValue;
        }
示例#3
0
 protected void SetNewCallbackFromFunctionCall(FsmInput trigger, FsmInput removeCondition, System.Action callBack)
 {
     if (callBack != null)
     {
         _callBackRegister.AddNewCallBack(trigger, removeCondition, callBack);
         Logger.DebugFormat("New callback from function call: {0}", trigger);
     }
 }
示例#4
0
        private void SetCommand(IAdaptiveContainer <IFsmInputCommand> commands,
                                FsmInput type,
                                float additionalValue      = float.NaN,
                                float alterAdditionalValue = float.NaN)
        {
            var item = commands.GetAvailableItem(command => (command.Type == FsmInput.None || command.Type == type));

            SetCommandParam(item, type, additionalValue, alterAdditionalValue);
        }
示例#5
0
        public static bool SimpleCommandHandler(IFsmInputCommand command, FsmInput type)
        {
            var ret = command.IsMatch(type);

            if (ret)
            {
                command.Handled = true;
            }
            return(ret);
        }
示例#6
0
 public void ResetItem(FsmInput type)
 {
     for (var i = 0; i < this.Length; ++i)
     {
         if (this[i].Type == type)
         {
             this[i].Reset();
         }
     }
 }
示例#7
0
            public void TryRemoveCallBack(FsmInput type)
            {
                System.Action remove;
                _callBackRemove.TryGetValue(type, out remove);

                if (remove != null)
                {
                    remove.Invoke();
                }
            }
示例#8
0
            public void TryInvokeCallBack(FsmInput type)
            {
                System.Action callBack;
                _inputCallBack.TryGetValue(type, out callBack);

                if (callBack != null)
                {
                    callBack.Invoke();
                    Logger.DebugFormat("Animation End Callback: {0}", type);
                }
            }
示例#9
0
 public void AddNewCallBack(FsmInput trigger, FsmInput removeCondition, System.Action callBack)
 {
     if (!_inputCallBack.ContainsKey(trigger))
     {
         if (!_callBackRemove.ContainsKey(removeCondition))
         {
             _callBackRemove[removeCondition] = default(System.Action);
         }
         _callBackRemove[removeCondition] += () => _inputCallBack[trigger] = null;
     }
     _inputCallBack[trigger] = callBack;
 }
示例#10
0
        private void SetCommandParam(IFsmInputCommand command, FsmInput type, float additionalValue = float.NaN,
                                     float alterAdditionalValue = float.NaN)
        {
            command.Type = type;

            if (!float.IsNaN(additionalValue))
            {
                command.AdditioanlValue = additionalValue;
            }
            if (!float.IsNaN(alterAdditionalValue))
            {
                command.AlternativeAdditionalValue = alterAdditionalValue;
            }
        }
示例#11
0
            public bool TryInvokeCallBack(FsmInput type)
            {
                bool ret = false;

                System.Action callBack;
                _inputCallBack.TryGetValue(type, out callBack);

                if (callBack != null)
                {
                    callBack.Invoke();
                    ret = true;
                    Logger.InfoFormat("Animation End Callback: {0}", type);
                }

                return(ret);
            }
示例#12
0
        private bool IsBeLimited(FsmInput input, List <FsmInput> limits)
        {
            if (null == limits)
            {
                return(false);
            }
            foreach (var limit in limits)
            {
                if (input != limit)
                {
                    continue;
                }
                Logger.ErrorFormat("FsmInput have be limited:  {0}", input);
                return(true);
            }

            return(false);
        }
示例#13
0
 private void ClearActionByCmdHelper(IAdaptiveContainer <IFsmInputCommand> commands, FsmInput clearAction)
 {
     for (int i = 0; i < commands.Length; ++i)
     {
         if (commands[i].Type == clearAction)
         {
             commands[i].Type    = FsmInput.None;
             commands[i].Handled = false;
             return;
         }
     }
 }
示例#14
0
 private void ClearActionByCmd(IAdaptiveContainer <IFsmInputCommand> commands, FsmInput cmd, FsmInput clearAction)
 {
     for (int i = 0; i < commands.Length; ++i)
     {
         if (commands[i].Type == cmd)
         {
             ClearActionByCmdHelper(commands, clearAction);
             return;
         }
     }
 }
示例#15
0
 // 添加需要打断的 input
 public void AddInterruptInput(FsmInput input)
 {
     _interruptInputs.Add(input);
 }
示例#16
0
 public DiveTransition(short id, short target, int duration, float fromValue, float toValue, FsmInput enterInput) : base(id, target, duration)
 {
     _fromValue = fromValue;
     _toValue   = toValue;
     _simpleTransferCondition =
         (command, addOutput) => FsmTransition.SimpleCommandHandler(command, enterInput);
 }
示例#17
0
 public bool IsMatch(FsmInput type)
 {
     return(!_handled && _type == type);
 }
示例#18
0
 private void CheckConditionAndSetCommand(IUserCmd cmd, XmlConfig.EPlayerInput mappedInput, FsmInput fsmInput)
 {
     if (null != cmd.FilteredInput && cmd.FilteredInput.IsInput(mappedInput))
     {
         SetCommand(fsmInput);
     }
     else
     {
         if (null == cmd.FilteredInput)
         {
             Logger.Error("FilteredInput in cmd should never be null !");
         }
     }
 }