예제 #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 !");
         }
     }
 }