public override void Execute(MoveableObject pObject, ActionParameter pActionPara) { // TODO: add the run action implementation // 1. get object's rigid body // 2. get object's animation (from file) // 3. run the animation with the action parameter }
public void Execute( string pObjectName, string pActionName, ActionParameter pActionParameter ) { MoveableObject lObject = ObjectsItems.Items[pObjectName]; ActionDelegate lAction = ActionItems[pActionName]; lAction(lObject, pActionParameter); }
public WpfClient() { ModuleList = new List<ZeroModule>(); var param1 = new ActionParameter<ISyncService>(false, Config.CreateSyncConnection(), false); var param2 = new ActionParameter<IFileTransfer>(false, Config.CreateFileTranferConnection(), false); Terminal.Instance.Session[param1.Name] = param1; Terminal.Instance.Session[param2.Name] = param2; }
public FirewallRule(NameParameter name, DirectionParameter direction, ActionParameter action) { if (name == null) throw new ArgumentNullException(nameof(name)); if (direction == null) throw new ArgumentNullException(nameof(direction)); if (action == null) throw new ArgumentNullException(nameof(action)); Name = name; Direction = direction; Action = action; }
public void Should_get_value_from_argument() { var action = ActionMethod.From <ArgumentHandler>(x => x.Action(null, null)); var parameter = action.MethodDescriptor.Parameters .First(x => x.Name == "value"); var actionParameter = new ActionParameter(action, parameter); var arguments = new object[] { null, "fark" }; actionParameter.GetArgument(arguments).ShouldEqual("fark"); }
public IActionOutputParameter Action(ActionParameter actionParameter) { BaseServant servant = actionParameter.PrimaryCard as BaseServant; if (servant.Damage > 0 && servant.CanAttack && servant.RemainAttackTimes < 1) { servant.RemainAttackTimes += 1; } return(null); }
public static void BindProperty(this ActionParameter parameter, object instance, object value) { if (parameter.IsParameter) { throw new InvalidOperationException($"{parameter.Name} " + "must be a property or parameter property."); } parameter.PropertyDescriptor.SetValue(instance, value); }
public void Should_fail_to_bind_parameter() { var action = ActionMethod.From <PropertyBinderHandler>(x => x.Action(null)); var parameter = action.MethodDescriptor.Parameters.First(); var actionParameter = new ActionParameter(action, parameter); var model = new PropertyBinderHandler.Model(); actionParameter.Should().Throw <InvalidOperationException>( x => x.BindProperty(model, "fark")); }
public IActionOutputParameter Action(ActionParameter actionParameter) { GameContext context = actionParameter.GameContext; bool isActivation = actionParameter.IsActivation; T servant = Activator.CreateInstance <T>(); var player = context.Players.First(c => c.IsActivation == isActivation); servant.IsFirstPlayerCard = player.IsFirst; int deskIndex = -1; int searchCount = 0; for (int i = player.IsFirst ? 0 : 8; i < context.DeskCards.Count; i++) { searchCount++; if (searchCount > 8) { break; } if (context.DeskCards[i] == null) { deskIndex = i; break; } } if (deskIndex < 0) { return(null); } context.CastCardCount++; servant.CastIndex = context.CastCardCount; //context.AllCard.Add(servant); servant.DeskIndex = deskIndex; servant.CardInGameCode = context.AllCard.Count().ToString(); context.DeskCards[deskIndex] = servant; player.AllCards.Add(servant); ActionParameter castPara = new ActionParameter() { PrimaryCard = servant, GameContext = actionParameter.GameContext, DeskIndex = deskIndex }; CardActionFactory.CreateAction(servant, ActionType.进场).Action(castPara); //servant.Cast(context, deskIndex, -1); context.EventQueue.AddLast(new ServantInDeskEvent() { EventCard = servant, Parameter = actionParameter }); return(servant); }
private void AddActionForMapperAndDevice(sconnActionResultMapper maper, Device edited, int DevNo) { try { iotContext cont = new iotContext(); Device storedDevice = cont.Devices.Where(d => d.Id == edited.Id).First(); DeviceAction action = new DeviceAction(); action.RequiredParameters = new List <ActionParameter>(); action.ResultParameters = new List <DeviceActionResult>(); action.ActionName = "Output" + maper.SeqNumber; //TODO read from name cfg action.Device = storedDevice; action.LastActivationTime = DateTime.Now; cont.Actions.Add(action); cont.SaveChanges(); //copy maper for action sconnActionResultMapper actionResultMaper = new sconnActionResultMapper(); actionResultMaper.ConfigType = maper.ConfigType; actionResultMaper.SeqNumber = maper.SeqNumber; sconnActionMapper actionInputMaper = new sconnActionMapper(); actionInputMaper.ConfigType = maper.ConfigType; actionInputMaper.SeqNumber = maper.SeqNumber; ParameterType extType = ParamTypeForSconnMapper(maper); ParameterType inType = cont.ParamTypes.Where(p => p.Id == extType.Id).First(); ActionParameter inparam = new ActionParameter(); inparam.Value = sconnConfigToStringVal(actionInputMaper, site.siteCfg.deviceConfigs[DevNo]); inparam.Type = inType; inparam.Action = action; cont.ActionParameters.Add(inparam); actionInputMaper.ActionParam = inparam; cont.ActionParamMappers.Add(actionInputMaper); cont.SaveChanges(); //create result parameter and bind mapper to it DeviceActionResult param = new DeviceActionResult(); param.Value = sconnConfigToStringVal(maper, site.siteCfg.deviceConfigs[DevNo]); param.Type = inType; param.Action = action; cont.ActionResultParameters.Add(param); cont.SaveChanges(); actionResultMaper.ActionParam = param; cont.ActionResultMappers.Add(actionResultMaper); cont.SaveChanges(); } catch (Exception e) { nlogger.ErrorException(e.Message, e); } }
public ValueMapperConfigurationContext(Configuration configuration, HttpConfiguration httpConfiguration, ActionMethod actionMethod, RouteDescriptor routeDescriptor, ActionParameter parameter, object[] values) : base(parameter, values) { Configuration = configuration; HttpConfiguration = httpConfiguration; Action = actionMethod; Route = routeDescriptor; }
public void Should_return_null_if_property_argument_is_null() { var action = ActionMethod.From <ArgumentHandler>(x => x.Action(null, null)); var parameter = action.MethodDescriptor.Parameters .First(x => x.Name == "value"); var property = parameter.ParameterType.Properties.First(); var actionParameter = new ActionParameter(action, parameter, property); var arguments = new object[2]; actionParameter.GetArgument(arguments).ShouldBeNull(); }
public IActionOutputParameter Action(ActionParameter actionParameter) { TAG tag = Activator.CreateInstance <TAG>(); foreach (BaseBiology biology in actionParameter.GameContext.DeskCards.Where(tag.Filter(actionParameter)).OrderBy(c => c.CastIndex)) { DisableCardAbility(biology, actionParameter.GameContext); } return(null); }
public IActionOutputParameter Action(ActionParameter actionParameter) { int drawCount = actionParameter.DrawCount; UserContext uc = actionParameter.UserContext; BaseHero hero = actionParameter.GameContext.GetHeroByActivation(uc.IsActivation); for (int i = 1; i <= drawCount; i++) { //当牌库里有牌时 if (uc.StockCards.Count() > 0) { var drawCard = uc.StockCards.First(); if (uc.HandCards.Count() < 10) { //如果手牌没满则放入手牌中 //uc.HandCards.Add(drawCard); drawCard.CardLocation = CardLocation.手牌; } else { //否则撕了这张牌 drawCard.CardLocation = CardLocation.坟场; //uc.GraveyardCards.Add(drawCard); } //最后从牌库移除这张牌 //uc.StockCards.RemoveAt(0); } else { //没牌则计算疲劳值 uc.FatigueValue++; int trueDamege = uc.FatigueValue; if (trueDamege >= hero.Ammo) { trueDamege -= hero.Ammo; hero.Ammo = 0; } else { hero.Ammo -= trueDamege; trueDamege = 0; } new DeductionHeroLifeAction().Action(new ActionParameter() { PrimaryCard = hero, GameContext = actionParameter.GameContext, DamageOrHeal = trueDamege }); //hero.Life -= trueDamege; } } return(null); }
public void Should_fail_to_bind_property_to_arguments() { var action = ActionMethod.From <ArgumentHandler>(x => x.Action(null, null)); var property = action.MethodDescriptor.Parameters .First(x => x.Name == "model").ParameterType.Properties.First(); var actionParameter = new ActionParameter(action, property); var arguments = new object[2]; actionParameter.Should().Throw <InvalidOperationException>( x => x.BindArgument(arguments, "fark")); }
public IActionOutputParameter Action(ActionParameter actionParameter) { TAG tag = Activator.CreateInstance <TAG>(); foreach (Card card in actionParameter.GameContext.AllCard.Where(tag.Filter(actionParameter)).OrderBy(c => c.CastIndex)) { BaseBiology baseBiology = card as BaseBiology; baseBiology.IsDeathing = true; } return(null); }
public ScannerAction(ActionParameter param, ActionDelegate startScanner, ActionDelegate stopScanner) : base(param) { if (Param.Start) { scannerAction = CheckAction(startScanner); } else { scannerAction = CheckAction(stopScanner); } }
public static void SendSystemMessage(int systemID, ActionParameter parameter) { if (!systems.ContainsKey(systemID)) { return; } SystemBase _system = systems[systemID]; _system.Add(parameter); _system.Set(); }
public void Should_bind_parameter_to_arguments() { var action = ActionMethod.From <ArgumentHandler>(x => x.Action(null, null)); var parameter = action.MethodDescriptor.Parameters .First(x => x.Name == "value"); var actionParameter = new ActionParameter(action, parameter); var arguments = new object[2]; actionParameter.BindArgument(arguments, "fark"); arguments.ShouldOnlyContain(null, "fark"); }
public IActionOutputParameter Action(ActionParameter actionParameter) { foreach (BaseBiology biology in actionParameter.GameContext.DeskCards.Where(Activator.CreateInstance <TAG>().Filter(actionParameter))) { BaseHero hero = biology as BaseHero; if (hero.Equip != null) { hero.Equip.Durable = 0; } } return(null); }
public void Should_bind_parameter_property() { var action = ActionMethod.From <PropertyBinderHandler>(x => x.Action(null)); var parameter = action.MethodDescriptor.Parameters.First(); var property = parameter.ParameterType.Properties.First(); var actionParameter = new ActionParameter(action, parameter, property); var model = new PropertyBinderHandler.Model(); actionParameter.BindProperty(model, "fark"); model.Value.ShouldEqual("fark"); }
public IActionOutputParameter Action(ActionParameter actionParameter) { UC uc = GameActivator <UC> .CreateInstance(); var users = actionParameter.GameContext.Players.Where(uc.Filter(actionParameter)); foreach (UserContext user in users) { user.Power += GameActivator <Q> .CreateInstance().GetNumber(actionParameter); } return(null); }
public IActionOutputParameter Action(ActionParameter actionParameter) { GameContext context = actionParameter.GameContext; UserContext userContext = actionParameter.UserContext; T card = Activator.CreateInstance <T>(); card.IsFirstPlayerCard = userContext.IsFirst; //context.AllCard.Add(card); card.CardInGameCode = context.AllCard.Count().ToString(); context.Players.First(c => c == userContext).AllCards.Add(card); return(card); }
public IActionOutputParameter Action(ActionParameter actionParameter) { var user = actionParameter.GameContext.GetActivationUserContext(); CreateNewGenericCardInDeskAction <SilverHandRecruit> action = new CreateNewGenericCardInDeskAction <SilverHandRecruit>(); var para = new ActionParameter() { GameContext = actionParameter.GameContext, IsActivation = user.IsActivation, }; return(action.Action(para)); }
private CollectionsQueryModelParameterDetails GetDetailsForActionParameter(ActionParameter actionParam) { string key = nameof(CollectionsQueryModelParameterDetails); var value = actionParam.GetAdditionalDataOrDefault <CollectionsQueryModelParameterDetails>(key); if (value == null) { value = new CollectionsQueryModelParameterDetails(actionParam.Type); actionParam.SetAdditionalData(key, value); } return(value); }
public void TurnStart() { var cap = new ActionParameter() { GameContext = GameContext, PrimaryCard = GameContext.GetHeroByActivation() }; GameContext.EventQueue.AddLast(new MyTurnStartEvent() { Parameter = cap }); var uc = GameContext.GetActivationUserContext(); if (uc.FullPower < 10) { uc.FullPower += 1; } uc.Power = uc.FullPower; //抽牌 var para = new ActionParameter() { DrawCount = 1, GameContext = GameContext, UserContext = uc }; new DrawCardAction().Action(para); //GameContext.DrawCard(); //将英雄技能可用次数重置为1次 uc.RemainingHeroPowerCastCount = 1; var activationDeskCards = GameContext.DeskCards.GetDeskCardsByIsFirst(uc.IsFirst); //让场上的随从或英雄获取攻击次数 foreach (var card in activationDeskCards.Where(c => c != null)) { card.CanAttack = true; ActionParameter resetPara = new ActionParameter() { PrimaryCard = card, GameContext = GameContext }; CardActionFactory.CreateAction(card, ActionType.重置攻击次数).Action(resetPara); } GameContext.Settlement(); _gameCache.SetContext(GameContext); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.UpArrow)) { // get the action parameter ActionParameter lPara = new ActionParameter(); lPara.ActionName = "Run"; lPara.VectorT = new Vector3(1, 0, 0); lPara.Speed = 1.0; mActions.Execute(mMonsterDog.Name, "Run", lPara); } }
public void Should_get_value_from_argument_property() { var action = ActionMethod.From <ArgumentHandler>(x => x.Action(null, null)); var parameter = action.MethodDescriptor.Parameters .First(x => x.Name == "model"); var property = parameter.ParameterType.Properties.First(); var actionParameter = new ActionParameter(action, parameter, property); var arguments = new object[] { new ArgumentHandler.Model { Value = "fark" }, null }; actionParameter.GetArgument(arguments).ShouldEqual("fark"); }
public static void AddEndOfPlayerActionEvent(this GameContext context) { var para = new ActionParameter() { GameContext = context, PrimaryCard = context.DeskCards.GetHeroByIsFirst(context.GetActivationUserContext().IsFirst) }; context.EventQueue.AddLast(new EndOfPlayerActionEvent() { Parameter = para }); }
public IActionOutputParameter Action(ActionParameter actionParameter) { UC uc = GameActivator <UC> .CreateInstance(); var users = actionParameter.GameContext.Players.Where(uc.Filter(actionParameter)); foreach (UserContext user in users) { BaseHero hero = actionParameter.GameContext.DeskCards.GetHeroByIsFirst(user.IsFirst); hero.Ammo += GameActivator <Q> .CreateInstance().GetNumber(actionParameter); } return(null); }
public IActionOutputParameter Action(ActionParameter actionParameter) { BaseServant servant = actionParameter.PrimaryCard as BaseServant; GameContext gameContext = actionParameter.GameContext; Card triggerCard = actionParameter.SecondaryCard; servant.Life += actionParameter.DamageOrHeal; if (servant.Life > servant.BuffLife) { servant.Life = servant.BuffLife; } return(null); }
/// <summary> /// Gets the parameter value, parameter must be from route segment. /// </summary> /// <param name="actionCtx">The action context.</param> /// <param name="parameter">The parameter.</param> /// <param name="request">The request.</param> /// <returns>Value of the parsed parameter.</returns> /// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.InvalidOperationException">RouteSegmentQueryModelBinder supports only parameters from route segment.</exception> public static object GetParameterValue(ActionContext actionCtx, ActionParameter parameter, HttpRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } if (parameter == null) { throw new ArgumentNullException(nameof(parameter)); } if (actionCtx == null) { throw new ArgumentNullException(nameof(actionCtx)); } if (parameter.ParameterSource != ParameterSources.RouteSegment) { throw new InvalidOperationException($"{nameof(RouteSegmentModelBinder)} supports only parameters from route segment."); } string[] segments = request.Path.Value.TrimStart('/').TrimEnd('/').Split('/'); segments = segments.Skip(actionCtx.ParentController.RouteSegments.Length).ToArray(); // handle empty string if (segments.Length == actionCtx.RouteSegments.Length - 1 && request.Path.Value.EndsWith("/", StringComparison.Ordinal) && parameter.Type == typeof(string)) { return(""); } string stringValue = null; string paramName = parameter.Name; for (int i = 0; i < actionCtx.RouteSegments.Length; i++) { if (actionCtx.RouteSegments[i].IsParameter && actionCtx.RouteSegments[i].ParameterName == paramName) { if (i >= segments.Length) { throw new Exception($"Route segment for parameter {parameter} in action {actionCtx} not found"); } else { stringValue = segments[i]; break; } } } // shouldn't reach stringValue == null if (stringValue == null) { throw new Exception($"Route segment for parameter {parameter} in action {actionCtx} not found"); } return(BasicQueryModelBinder.ParseSingleQueryValue(stringValue, parameter.Type, false, parameter.Name, new Lazy <string>(() => parameter.ParentActionContext.ToString()))); }
private void OnTriggerEnter(Collider other) { if(other.gameObject.transform.tag == "Player" && !isTrigger){ ActionParameter actionParameter = new ActionParameter(); actionParameter.actionParameterData.source = this.gameObject; actionParameter.actionParameterData.target = other.gameObject; foreach( string commandName in commandNames){ Command command = CommandFactory.Instance.CreateCommand( commandName, actionParameter); commands.Add(command); } isTrigger = true; } }
/// <summary> /// 随从攻击进行阶段 /// </summary> /// <param name="servant"></param> /// <param name="target"></param> public void ServantAttack(BaseServant servant, int target) { ActionParameter para = new ActionParameter() { PrimaryCard = servant, GameContext = GameContext, SecondaryCard = GameContext.DeskCards[target] }; CardActionFactory.CreateAction(servant, ActionType.攻击).Action(para); // GameContext.AddEndOfPlayerActionEvent(); GameContext.Settlement(); _gameCache.SetContext(GameContext); }
private string MapParameterName(ActionParameter parameter) { var bindingMode = _configuration.HeadersBindingMode; if (bindingMode == BindingMode.Convention && HasHeaderPostfix(parameter.Name)) { return(parameter.Name.Truncate(HeaderPostfix.Length)); } if (bindingMode == BindingMode.Explicit || bindingMode == BindingMode.Implicit) { return(parameter.GetAttribute <FromHeadersAttribute>()?.Name ?? parameter.Name); } return(parameter.Name); }
public Command CreateCommand( string i_commandName, ActionParameter i_actionParameter ) { switch( i_commandName ){ case "AudioTriggerCommand": { //return i_actionParameter.actionParameterData.source.AddComponent<AudioTriggerCommand>(); return new AudioTriggerCommand( i_actionParameter); break; } default: Debug.LogError("There is no such command. Please check your request."); return null; break; } }
public abstract void Execute(MoveableObject pObjectName, ActionParameter pActionPara);
private void OpenLogInDialog() { #if DEBUG ActionParameterBase userpParam = new ActionParameter<User>(false, User.GetUser(K_administrator, true), false); Terminal.Instance.Session[userpParam.Name] = userpParam; #else var view = new UserLogIn(); Terminal.Instance.Client.ShowDialog(view,null, dialogResult => { if (dialogResult) { if (User.ValidateUser(view.UserName, view.UserPass)) { ActionParameterBase userpParam = new ActionParameter<User>(false, User.GetUser(view.UserName, true), false); Terminal.Instance.Session[typeof(User)] = userpParam; OpenHomePage(null); } else { Terminal.Instance.Client.ShowDialog(Resources.MsgIncorrectUserPassTryAgain,Resources.Fail, (res) => { OpenLogInDialog(); }, MessageBoxButtonEnum.OK); } } else { Terminal.Instance.Client.ShowDialog(Resources.MsgLogInPlease + "\nEl sistema se cerrara.", Resources.Fail, (res) => { if (Terminal.Instance.Session.Actions[Actions.AppExit] != null) { Terminal.Instance.Session.Actions[Actions.AppExit].TryExecute(); } }, MessageBoxButtonEnum.OK); } }); #endif }
public Command(ActionParameter i_actionParamter) { init (i_actionParamter); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.UpArrow)) { // get the action parameter ActionParameter lPara = new ActionParameter(); lPara.ActionName = "Run"; lPara.VectorT = new Vector3( 1, 0, 0 ); lPara.Speed = 1.0; mActions.Execute( mMonsterDog.Name, "Run", lPara ); } }
public virtual void init(ActionParameter i_actionParamter) { actionParamter = i_actionParamter; }
public AudioTriggerCommand(ActionParameter i_actionParamter) : base(i_actionParamter) { }
/// <summary> /// Returns the parameter list for the specified action /// </summary> /// <param name="action">action to get the parameters for</param> /// <returns>Dictionary of parameters if possible, else throws</returns> private static Dictionary<string, object> _GetParameters(this IAction action) { if (null == action) { throw new ArgumentNullException("action can not be null"); } var actionType = action.GetType(); ActionParameter actionParameter = null; if (actionType == _ScreenPressActionType.Value) { var x = _ScreenPressFieldInfoList.Value.Find(s => s.Name == "x").GetValue(action); var y = _ScreenPressFieldInfoList.Value.Find(s => s.Name == "y").GetValue(action); actionParameter = new ActionParameter("press"); actionParameter.AddParameter("x", x); actionParameter.AddParameter("y", y); } else if (actionType == _ScreenReleaseActionType.Value) { actionParameter = new ActionParameter("release"); } else if (actionType == _ScreenMoveActionType.Value) { var x = _ScreenMoveFieldInfoList.Value.Find(s => s.Name == "x").GetValue(action); var y = _ScreenMoveFieldInfoList.Value.Find(s => s.Name == "y").GetValue(action); actionParameter = new ActionParameter("moveTo"); actionParameter.AddParameter("x", x); actionParameter.AddParameter("y", y); } else if (actionType == typeof(WaitAction)) { actionParameter = new ActionParameter("wait"); actionParameter.AddParameter("ms", ((WaitAction)action).Duration); } if (null == actionParameter) { throw new NotImplementedException(string.Format("Multi Touch does not support this feature {0}", action.GetType())); } return actionParameter.GetDictionary(); }