private void CreateOrderMove(Vector3 direction) { if (CouldAddnewOrder() == false) { // Debug.Log("不能添加动作"); return; } if (lastDir != null) { direction = (direction + lastDir).normalized; lastDir = direction; } AgentOrder order = AgentOrderFactory.Create(AgentOrder.E_OrderType.E_GOTO); order.Direction = direction; order.MoveSpeedModifier = moveSpeed; Owner.BlackBoard.OrderAdd(order); Owner.BlackBoard.DesiredDirection = direction; ActionMove actionMove = ActionFactory.Create(ActionFactory.E_Type.E_MOVE) as ActionMove; GetComponent <AnimComponent>().HandleAction(actionMove); }
/// <summary> /// Profile and time measure the specified <paramref name="action"/> delegate. /// </summary> /// <typeparam name="T1">The type of the first parameter of the <paramref name="action" /> delegate.</typeparam> /// <typeparam name="T2">The type of the second parameter of the <paramref name="action" /> delegate.</typeparam> /// <typeparam name="T3">The type of the third parameter of the <paramref name="action" /> delegate.</typeparam> /// <typeparam name="T4">The type of the fourth parameter of the <paramref name="action" /> delegate.</typeparam> /// <typeparam name="T5">The type of the fifth parameter of the <paramref name="action" /> delegate.</typeparam> /// <typeparam name="T6">The type of the sixth parameter of the <paramref name="action" /> delegate.</typeparam> /// <typeparam name="T7">The type of the seventh parameter of the <paramref name="action" /> delegate.</typeparam> /// <typeparam name="T8">The type of the eighth parameter of the <paramref name="action" /> delegate.</typeparam> /// <typeparam name="T9">The type of the ninth parameter of the <paramref name="action" /> delegate.</typeparam> /// <typeparam name="T10">The type of the tenth parameter of the <paramref name="action" /> delegate.</typeparam> /// <param name="action">The delegate to time measure.</param> /// <param name="arg1">The first parameter of the <paramref name="action" /> delegate.</param> /// <param name="arg2">The second parameter of the <paramref name="action" /> delegate.</param> /// <param name="arg3">The third parameter of the <paramref name="action" /> delegate.</param> /// <param name="arg4">The fourth parameter of the <paramref name="action" /> delegate.</param> /// <param name="arg5">The fifth parameter of the <paramref name="action" /> delegate.</param> /// <param name="arg6">The sixth parameter of the <paramref name="action" /> delegate.</param> /// <param name="arg7">The seventh parameter of the <paramref name="action" /> delegate.</param> /// <param name="arg8">The eighth parameter of the <paramref name="action" /> delegate.</param> /// <param name="arg9">The ninth parameter of the <paramref name="action" /> delegate .</param> /// <param name="arg10">The tenth parameter of the <paramref name="action" /> delegate.</param> /// <param name="setup">The <see cref="TimeMeasureOptions"/> which need to be configured.</param> /// <returns>A <see cref="TimeMeasureProfiler"/> with the result of the time measuring.</returns> public static TimeMeasureProfiler WithAction <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Action <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> action, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, Action <TimeMeasureOptions> setup = null) { Validator.ThrowIfNull(action, nameof(action)); var factory = ActionFactory.Create(action, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); return(WithActionCore(factory, setup)); }
public void PlayerPlaysCard(Card card) { var player = players[activePlayerIndex]; player.hand.Remove(card); discardPile.AddToBottom(card); if (player.hand.Count == 0) // winner { PlayerWins(activePlayerIndex); } if (!playerSaidUno && player.hand.Count == 1) { GivePlayerACard(player, FromDrawPile()); GivePlayerACard(player, FromDrawPile()); } /* * else if (playerSaidUNO) * { * GivePlayerACard(player, FromDrawPile()); * GivePlayerACard(player, FromDrawPile()); * }//*/ BaseTemplate action = cardActionFactory.Create(card.type); //if (action != null) action.ProcessAction(this); // action card is responsible whose turn is next //else // NextPlayerTurn(); }
/// <summary> /// Loads code from a file, must be in native format /// </summary> /// <param name="parentNode">node to load from</param> public void LoadScript(IAppContext context, XmlNode parentNode) { XmlNodeList nodeList = parentNode.SelectNodes("Action"); if (nodeList == null) { return; } foreach (XmlNode node in nodeList) { string actionType = node.Attributes["ActionType"].Value; ActionBase action = ActionFactory.Create(actionType); if (action == null) { continue; } action.AppContext = context; if (action == null) { MessageBox.Show("Action " + node.Name + " could not be mapped-- application needs updating.", "Load Map Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); continue; } action.ParentTest = this; action.LoadFromXml(node); Add(action); } }
public void TestCustomCSharpAction_InSeperateAssembly() { var old = Compiler.Instance.TypeFactory; try { // Setup the TypeFactory to use both the main Wanderer assembly and our assembly Compiler.Instance.TypeFactory = new TypeCollectionFactory(typeof(Compiler).Assembly, typeof(TestAction).Assembly); var blue = Compiler.Instance.Deserializer.Deserialize <ActionBlueprint>(yaml); var dir = Path.Combine(TestContext.CurrentContext.TestDirectory, "EmptyFolder"); Directory.CreateDirectory(dir); var wf = new WorldFactory() { ResourcesDirectory = dir }; var world = wf.Create(); var f = new ActionFactory(); var action = f.Create(world, world.Player, blue); Assert.IsInstanceOf(typeof(TestAction), action); } finally { Compiler.Instance.TypeFactory = old; } }
private static Transformation ReadTransform(XmlNode transformNode) { string morpheme = transformNode.Attributes["morpheme"].InnerText; string actionName = transformNode.Attributes["action"].InnerText; string operandOne = transformNode.Attributes["operandOne"] != null ? transformNode.Attributes["operandOne"].InnerText : ""; string operandTwo = transformNode.Attributes["operandTwo"] != null ? transformNode.Attributes["operandTwo"].InnerText : ""; string flag = transformNode.Attributes["flag"] != null ? transformNode.Attributes["flag"].InnerText : ""; BaseAction action = ActionFactory.Create(actionName, _alphabet, operandOne, operandTwo, flag); ConditionContainer conditions = ConditionContainer.EmptyContainer(); if (transformNode.HasChildNodes) { conditions = ReadConditionContainer(transformNode.FirstChild); } return(new Transformation(action, morpheme, conditions)); }
public void OnTriggerEnter(Collider other) { TriggerObject interaction = other.GetComponent <TriggerObject>(); if (interaction != null) { if (interaction.GetEntryTransform() == null) { return; } // 当玩家碰到触发器,播放使用动画 Owner.transform.position = interaction.GetEntryTransform().position; Owner.transform.rotation = interaction.GetEntryTransform().rotation; useMode = false; AgentOrder order = AgentOrderFactory.Create(AgentOrder.E_OrderType.E_USE); order.InteractionObject = interaction; order.Position = order.InteractionObject.GetEntryTransform().position; order.Interaction = E_InteractionType.On; Owner.BlackBoard.OrderAdd(order); ActionUseLever actionUseLever = ActionFactory.Create(ActionFactory.E_Type.E_USE_LEVER) as ActionUseLever; actionUseLever.InterObj = interaction; actionUseLever.Interaction = E_InteractionType.On; GetComponent <AnimComponent>().HandleAction(actionUseLever); return; } }
/// <summary> /// Gets the actions for the given <paramref name = "eventType" /> for the given <paramref name = "profileNode" />. /// </summary> /// <param name = "profileNode">The profile node.</param> /// <param name = "eventType">Type of the event.</param> /// <returns>A list of <see cref = "IAction" />s for the given <paramref name = "eventType" />, or an empty list.</returns> private static IEnumerable <IAction> GetProfileActions(XmlNode profileNode, EventType eventType) { string eventTypeString = eventType.ToString(); eventTypeString = eventTypeString[0].ToString().ToLower() + eventTypeString.Substring(1); var nodeList = profileNode.SelectNodes(string.Format(XPATH_EVENTHANDLER_ACTION, eventTypeString)); IList <IAction> actionList = new List <IAction>(); if (nodeList != null) { foreach (XmlNode node in nodeList) { IDictionary <string, string> parameters = (from XmlAttribute xmlAttribute in node.Attributes where xmlAttribute.Name != "type" select new { key = xmlAttribute.Name, value = xmlAttribute.InnerText } ).ToDictionary(item => item.key, item => item.value); // Create and add the action if (node.Name == "action") { // Generic action, use the "type" attribute to figure out the type actionList.Add(ActionFactory.Create(node.Attributes["type"].InnerText, parameters)); } else { // Specific action; the node is the name of the action actionList.Add(ActionFactory.Create(node.Name, parameters)); } } } return(actionList); }
private void Update() { if (EnabledTileMap) { //This is being called too many times. //Need a fix for this, I need to not draw a tile if the mouse is over the position AND be allowed to highlight the tile to show the action. Vector3Int locationAtMouse = LocationAtMouse(this.GrassMap); //if(this.GrassMap.HasTile(locationAtMouse)) // todo only have this occur in situations where the farming is enabled. // It is called every frame and is useless to call when not needed. this.HighlightTileAtPosition(locationAtMouse); if (Input.GetMouseButtonDown(0) && this.Tilemaps[0].HasTile(locationAtMouse)) { Debug.Log($"Tile clicked. Selected tile {FarmerPlayer.instance.GetSelectedSeed()}"); IEnumerable <KeyValuePair <ActionBase, FarmingActionUI> > ActionsAtGridLocation = FarmingActionManager.instance.ActionsAtLocation(locationAtMouse); if (ActionsAtGridLocation.Count() > 0) { foreach (KeyValuePair <ActionBase, FarmingActionUI> baseA in ActionsAtGridLocation) { Debug.Log(baseA.Key.GetName()); } } TillSoilAction action = ActionFactory.Create <TillSoilAction>(locationAtMouse); FarmingActionManager.instance.EnqueueNewAction(action); } } }
/// <summary> /// Profile and time measure the specified <paramref name="action"/> delegate. /// </summary> /// <typeparam name="T1">The type of the first parameter of the <paramref name="action" /> delegate.</typeparam> /// <typeparam name="T2">The type of the second parameter of the <paramref name="action" /> delegate.</typeparam> /// <typeparam name="T3">The type of the third parameter of the <paramref name="action" /> delegate.</typeparam> /// <param name="action">The delegate to time measure.</param> /// <param name="arg1">The first parameter of the <paramref name="action" /> delegate.</param> /// <param name="arg2">The second parameter of the <paramref name="action" /> delegate.</param> /// <param name="arg3">The third parameter of the <paramref name="action" /> delegate.</param> /// <param name="setup">The <see cref="TimeMeasureOptions"/> which need to be configured.</param> /// <returns>A <see cref="TimeMeasureProfiler"/> with the result of the time measuring.</returns> public static TimeMeasureProfiler WithAction <T1, T2, T3>(Action <T1, T2, T3> action, T1 arg1, T2 arg2, T3 arg3, Action <TimeMeasureOptions> setup = null) { Validator.ThrowIfNull(action, nameof(action)); var factory = ActionFactory.Create(action, arg1, arg2, arg3); return(WithActionCore(factory, setup)); }
/// <summary> /// Event handler for the "Add Action" context menu item "Click" event /// </summary> /// <param name = "sender">The sender.</param> /// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param> private void AddActionClick(object sender, EventArgs e) { var parent = SelectedNode; if (parent is ProfileEventActionTreeNode) { parent = parent.Parent; } // Create a new action IAction action = ActionFactory.Create((sender as ToolStripMenuItem).Text, null, false); action.Description = string.Empty; // Get the form to display var form = ActionEditorFormFactory.CreateActionEditor(action); form.LoadAction(action); // Display the form if (form.ShowDialog(FindForm()) == DialogResult.OK) { // If we saved the result, add the node to the tree parent.Nodes.Add(new ProfileEventActionTreeNode(action, IMAGELIST_ICON_ACTION)); // Add the action to the collection EventType eventType = (parent as ProfileEventTreeNode).EventType; _profile.AssociateAction(eventType, action); _pendingChanges = true; } }
/// <summary> /// Profile and time measure the specified <paramref name="action"/> delegate. /// </summary> /// <param name="action">The delegate to time measure.</param> /// <param name="setup">The <see cref="TimeMeasureOptions"/> which need to be configured.</param> /// <returns>A <see cref="TimeMeasureProfiler"/> with the result of the time measuring.</returns> public static TimeMeasureProfiler WithAction(Action action, Action <TimeMeasureOptions> setup = null) { Validator.ThrowIfNull(action, nameof(action)); var factory = ActionFactory.Create(action); return(WithActionCore(factory, setup)); }
/// <summary> /// Queues the specified <paramref name="method"/> for execution. The <paramref name="method"/> executes when a thread pool thread becomes available. /// </summary> /// <typeparam name="T1">The type of the first parameter of the delegate <paramref name="method" />.</typeparam> /// <typeparam name="T2">The type of the second parameter of the delegate <paramref name="method" />.</typeparam> /// <typeparam name="T3">The type of the third parameter of the delegate <paramref name="method" />.</typeparam> /// <typeparam name="T4">The type of the fourth parameter of the delegate <paramref name="method" />.</typeparam> /// <param name="method">The delegate that is being invoked when a thread pool thread becomes available.</param> /// <param name="arg1">The first parameter of the delegate <paramref name="method" />.</param> /// <param name="arg2">The second parameter of the delegate <paramref name="method" />.</param> /// <param name="arg3">The third parameter of the delegate <paramref name="method" />.</param> /// <param name="arg4">The fourth parameter of the delegate <paramref name="method" />.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="method"/> is null. /// </exception> public static void QueueWork <T1, T2, T3, T4>(Action <T1, T2, T3, T4> method, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { Validator.ThrowIfNull(method, nameof(method)); var factory = ActionFactory.Create(method, arg1, arg2, arg3, arg4); QueueUserWorkItemCore(factory); }
/// <summary> /// Queues the specified <paramref name="method"/> for execution. The <paramref name="method"/> executes when a thread pool thread becomes available. /// </summary> /// <typeparam name="T">The type of the parameter of the delegate <paramref name="method" />.</typeparam> /// <param name="method">The delegate that is being invoked when a thread pool thread becomes available.</param> /// <param name="arg">The parameter of the delegate <paramref name="method" />.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="method"/> is null. /// </exception> public static void QueueWork <T>(Action <T> method, T arg) { Validator.ThrowIfNull(method, nameof(method)); var factory = ActionFactory.Create(method, arg); QueueUserWorkItemCore(factory); }
/// <summary> /// Queues the specified <paramref name="method"/> for execution. The <paramref name="method"/> executes when a thread pool thread becomes available. /// </summary> /// <typeparam name="T1">The type of the first parameter of the delegate <paramref name="method" />.</typeparam> /// <typeparam name="T2">The type of the second parameter of the delegate <paramref name="method" />.</typeparam> /// <typeparam name="T3">The type of the third parameter of the delegate <paramref name="method" />.</typeparam> /// <typeparam name="T4">The type of the fourth parameter of the delegate <paramref name="method" />.</typeparam> /// <typeparam name="T5">The type of the fifth parameter of the delegate <paramref name="method" />.</typeparam> /// <typeparam name="T6">The type of the sixth parameter of the delegate <paramref name="method" />.</typeparam> /// <typeparam name="T7">The type of the seventh parameter of the delegate <paramref name="method" />.</typeparam> /// <typeparam name="T8">The type of the eighth parameter of the delegate <paramref name="method" />.</typeparam> /// <typeparam name="T9">The type of the ninth parameter of the delegate <paramref name="method" />.</typeparam> /// <typeparam name="T10">The type of the tenth parameter of the delegate <paramref name="method" />.</typeparam> /// <param name="method">The delegate that is being invoked when a thread pool thread becomes available.</param> /// <param name="arg1">The first parameter of the delegate <paramref name="method" />.</param> /// <param name="arg2">The second parameter of the delegate <paramref name="method" />.</param> /// <param name="arg3">The third parameter of the delegate <paramref name="method" />.</param> /// <param name="arg4">The fourth parameter of the delegate <paramref name="method" />.</param> /// <param name="arg5">The fifth parameter of the delegate <paramref name="method" />.</param> /// <param name="arg6">The sixth parameter of the delegate <paramref name="method" />.</param> /// <param name="arg7">The seventh parameter of the delegate <paramref name="method" />.</param> /// <param name="arg8">The eighth parameter of the delegate <paramref name="method" />.</param> /// <param name="arg9">The ninth parameter of the delegate <paramref name="method" />.</param> /// <param name="arg10">The tenth parameter of the delegate <paramref name="method" />.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="method"/> is null. /// </exception> public static void QueueWork <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Action <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> method, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10) { Validator.ThrowIfNull(method, nameof(method)); var factory = ActionFactory.Create(method, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); QueueUserWorkItemCore(factory); }
/// <summary> /// rebuild socket send hearbeat package /// </summary> public SocketPackage ReBuildHearbeat() { var writer = NetWriter.Instance; SprotoType.package headPack = new SprotoType.package() { protoId = 2, session = NetWriter.MsgId, errorcode = 0, }; Sproto.SprotoPack pack = new Sproto.SprotoPack(); byte[] headBytes = headPack.encode(); writer.SetHeadBuffer(headBytes); writer.SetBodyData(new byte[0]); var data = writer.PostData(); NetWriter.resetData(); _hearbeatPackage = data; SocketPackage package = new SocketPackage(); package.MsgId = (int)headPack.session; package.ActionId = 2; package.Action = ActionFactory.Create(package.ActionId); package.SendTime = DateTime.Now; package.HasLoading = false; return(package); }
override public void Update() { UpdateFinalRotation(); // Debug.DrawLine(OwnerTransform.position + new Vector3(0, 1, 0), FinalPosition + new Vector3(0, 1, 0)); RotationProgress += Time.deltaTime * Owner.BlackBoard.RotationSmoothInMove; RotationProgress = Mathf.Min(RotationProgress, 1); Quaternion q = Quaternion.Slerp(StartRotation, FinalRotation, RotationProgress); Owner.Transform.rotation = q; if (MoveOk && AnimEngine[Action.Data.AnimName].time > AnimEngine[Action.Data.AnimName].length * 0.1f) { // Smooth the speed based on the current target direction float curSmooth = Owner.BlackBoard.SpeedSmooth * Time.deltaTime; Owner.BlackBoard.Speed = Mathfx.Hermite(Owner.BlackBoard.Speed, MaxSpeed, curSmooth); Owner.BlackBoard.MoveDir = Owner.Forward; float dist = Owner.BlackBoard.Speed * 2 * Time.deltaTime; MoveOk = Move(Owner.BlackBoard.MoveDir * dist); if (NoHitTimer < Time.timeSinceLevelLoad) { Owner.SoundPlayRoll(); NoHitTimer = Time.timeSinceLevelLoad + 0.75f; } // Åжϼ¼ÄÜÉ˺¦ Vector3 dirToPlayer = Player.Instance.transform.position - Owner.Transform.position; if (dirToPlayer.magnitude < Owner.BlackBoard.WeaponRange) { ActionInjury injury = ActionFactory.Create(ActionFactory.E_Type.E_INJURY) as ActionInjury; injury.Impuls = (dirToPlayer).normalized; Player.Instance.GetComponent <AnimComponent>().HandleAction(injury); Player.Instance.Owner.BlackBoard.Health -= 10; Player.Instance.comboHitNum = 0; } } if (Effect == null && Time.timeSinceLevelLoad > TimeToStartEffect && Time.timeSinceLevelLoad < TimeToEndEffect) { Effect = CombatEffectsManager.Instance.PlayWhirlEffect(Transform); } else if (Effect != null && Time.timeSinceLevelLoad > TimeToEndEffect) { CombatEffectsManager.Instance.ReturnWhirlEffect(Effect); Effect = null; } if (TimeToEndState < Time.timeSinceLevelLoad) { Owner.WorldState.SetWSProperty(E_PropKey.E_IDLING, true); Release(); } }
public async Task <ActionResult> DoAction( [FromRoute] string sessionId, [FromBody] ActionRequest actionRequest ) { UserModel userModel = await userManager.GetUserAsync(HttpContext.User); if (userModel?.UserId == null) { return(Status403Forbidden()); } if (sessionId == null) { return(NotFound()); } Task <Session?> sessionTask = sessionService.Get(sessionId); Session?session = await sessionTask; if (session == null) { return(Status404NotFound("Session")); } if (!session.HasPlayer(userModel.UserId)) { return(Status403Forbidden()); } string?failureMessage = null; try { AActionParams actionParams = await actionFactory.MakeActionParams(sessionId, actionRequest, userModel); if (ActionFactory.Create(actionParams, out AAction action)) { if (action != null && action.Execute(out failureMessage)) { await actionFactory.Commit(action); return(Ok()); } } else { failureMessage = "Request missing required parameter."; } } catch (Exception e) { failureMessage = e.Message; } return(failureMessage == null ? Status500UnknownError() : Status400Invalid(failureMessage)); }
private void CreateOrderStop() { AgentOrder order = AgentOrderFactory.Create(AgentOrder.E_OrderType.E_STOPMOVE); Owner.BlackBoard.OrderAdd(order); GetComponent <AnimComponent>().HandleAction(ActionFactory.Create(ActionFactory.E_Type.E_IDLE)); }
public void SetActionType(ManipulatorActionType type) { if (state.ActionType != type) { state.ActionType = type; state.Action = ActionFactory.Create(state.ActionType); } }
public void SetCallback(int actionId, Action <ActionResult> callback) { GameAction gameAction = ActionFactory.Create(actionId); if (gameAction == null) { throw new ArgumentException(string.Format("Not found {0} of GameAction object.", actionId)); } gameAction.Callback += callback; }
public void Action_Compute_Cordinate_Should_Return_Same_Cordinate(string currentDirection, string command, string expectedDirection) { var currDirection = DirectionFactory <int, int> .Create(currentDirection); var action = ActionFactory <int, int> .Create(command); var expectDirection = DirectionFactory <int, int> .Create(expectedDirection); var result = currDirection.NextFacing(action); result.GetType().Should().BeSameAs(expectDirection.GetType()); }
public Entity Handle() { var item = ItemRepository.Get(_id); return(new EntityBuilder() .WithClass("item") .WithProperty("id", item.Id) .WithProperty("value", item.Value.Units) .WithLink(() => LinkFactory.Create("item", _id, true)) .WithAction(() => ActionFactory.Create("basket", "post", item)) .Build()); }
public void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Player")) { // 玩家受到伤害 ActionInjury injury = ActionFactory.Create(ActionFactory.E_Type.E_INJURY) as ActionInjury; injury.Impuls = (other.gameObject.transform.position - transform.position).normalized * 2; Player.Instance.GetComponent <AnimComponent>().HandleAction(injury); Player.Instance.comboHitNum = 0; Player.Instance.Owner.BlackBoard.Health -= 10; MainPanelCtrl.Instance.ShowComboMessage(Player.Instance.comboHitNum); } }
public void PerfTestWithString() { void OnMsg(string x) { if (x == "end") { Console.WriteLine(x); } } ActionFactory <string> fact = new ActionFactory <string>(OnMsg); Stopwatch watch = Stopwatch.StartNew(); for (int i = 0; i < 5000000; i++) { Action act = fact.Create("s"); act(); } fact.Create("end")(); watch.Stop(); Console.WriteLine("Elapsed: " + watch.ElapsedMilliseconds); }
public void SetPropertiesTest() { XmlElement xe = (XmlElement)TestData.XmlDocument.SelectSingleNode("/CamBuildProject/WriteConsole"); IAction ba = ActionFactory.Create(xe); Assert.AreEqual("WriteConsole", ba.GetType().Name); Assert.IsTrue(ba.Fields.ContainsKey("Message")); Assert.IsNull(ba.GetType().GetProperty("Message").GetValue(ba, null)); ActionPropertySetter.SetProperties(ba); Assert.IsFalse(ba.Fields.ContainsKey("Message")); Assert.AreEqual("First test message", ba.GetType().GetProperty("Message").GetValue(ba, null).ToString()); }
public void PerfTestWithInt() { void OnMsg(int x) { } ActionFactory <int> fact = new ActionFactory <int>(OnMsg); Stopwatch watch = Stopwatch.StartNew(); for (int i = 0; i < 5000000; i++) { fact.Create(1); } watch.Stop(); Console.WriteLine("Elapsed: " + watch.ElapsedMilliseconds); }
/// <summary> /// Send /// </summary> /// <param name="actionId"></param> /// <param name="userData"></param> /// <param name="bShowLoading"></param> public void Send(int actionId, object userData, bool bShowLoading = true) { GameAction gameAction = ActionFactory.Create(actionId); if (gameAction == null) { throw new ArgumentException(string.Format("Not found {0} of GameAction object.", actionId)); } if (NetWriter.IsSocket()) { SocketRequest(gameAction, userData, HeadFormater, bShowLoading); } else { HttpRequest(gameAction, userData, HeadFormater, bShowLoading); } }
/// <summary> /// Send /// </summary> /// <param name="actionId"></param> /// <param name="callback"></param> /// <param name="actionParam"></param> /// <param name="bShowLoading"></param> public void Send(int actionId, Action <ActionResult> callback, ActionParam actionParam, bool bShowLoading = true) { GameAction gameAction = ActionFactory.Create(actionId); if (gameAction == null) { throw new ArgumentException(string.Format("Not found {0} of GameAction object.", actionId)); } gameAction.Callback += callback; if (NetWriter.IsSocket()) { SocketRequest(gameAction, actionParam, HeadFormater, bShowLoading); } else { HttpRequest(gameAction, actionParam, HeadFormater, bShowLoading); } }
public void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Player")) { ActionInjury injury = ActionFactory.Create(ActionFactory.E_Type.E_INJURY) as ActionInjury; injury.Impuls = (Direction).normalized; Player.Instance.GetComponent <AnimComponent>().HandleAction(injury); Player.Instance.comboHitNum = 0; Player.Instance.Owner.BlackBoard.Health -= 10; MainPanelCtrl.Instance.ShowComboMessage(Player.Instance.comboHitNum); Destroy(this.gameObject, 0.2f); } else { Destroy(this.gameObject, 2); } }