Ejemplo n.º 1
0
    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);
    }
Ejemplo n.º 2
0
        /// <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));
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        /// <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);
            }
        }
Ejemplo n.º 5
0
        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;
            }
        }
Ejemplo n.º 6
0
        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));
        }
Ejemplo n.º 7
0
    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;
        }
    }
Ejemplo n.º 8
0
        /// <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);
        }
Ejemplo n.º 9
0
        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);
                }
            }
        }
Ejemplo n.º 10
0
        /// <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));
        }
Ejemplo n.º 11
0
        /// <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;
            }
        }
Ejemplo n.º 12
0
        /// <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));
        }
Ejemplo n.º 13
0
        /// <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);
        }
Ejemplo n.º 14
0
        /// <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);
        }
Ejemplo n.º 15
0
        /// <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);
        }
Ejemplo n.º 16
0
    /// <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);
    }
Ejemplo n.º 17
0
    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();
        }
    }
Ejemplo n.º 18
0
        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));
        }
Ejemplo n.º 19
0
    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));
    }
Ejemplo n.º 20
0
 public void SetActionType(ManipulatorActionType type)
 {
     if (state.ActionType != type)
     {
         state.ActionType = type;
         state.Action     = ActionFactory.Create(state.ActionType);
     }
 }
Ejemplo n.º 21
0
    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;
    }
Ejemplo n.º 22
0
        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());
        }
Ejemplo n.º 23
0
        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());
        }
Ejemplo n.º 24
0
    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);
        }
    }
Ejemplo n.º 25
0
        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);
        }
Ejemplo n.º 26
0
        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());
        }
Ejemplo n.º 27
0
        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);
        }
Ejemplo n.º 28
0
Archivo: Net.cs Proyecto: zhukaixy/Scut
    /// <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);
        }
    }
Ejemplo n.º 29
0
    /// <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);
        }
    }
Ejemplo n.º 30
0
    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);
        }
    }