Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ARAstarNode"/> class.
 /// </summary>
 /// <param name='_g'>
 /// Node g-value
 /// </param>
 /// <param name='_h'>
 /// Node h-value
 /// </param>
 /// <param name='_previousStateRef'>
 /// Node's parent's state
 /// </param>
 /// <param name='_actionRef'>
 /// Action taken to generate node
 /// </param>
 public ARAstarNode(float _g, float _h, DefaultState _previousStateRef, DefaultAction _actionRef)
 {
     g             = _g;
     h             = _h;
     previousState = _previousStateRef;
     action        = _actionRef;
 }
Пример #2
0
 internal NetworkRuleSet(Bypass?bypass, IList <VirtualNetworkRule> virtualNetworkRules, IList <IPRule> ipRules, DefaultAction defaultAction)
 {
     Bypass = bypass;
     VirtualNetworkRules = virtualNetworkRules;
     IpRules             = ipRules;
     DefaultAction       = defaultAction;
 }
Пример #3
0
 public NetworkRuleSet(DefaultAction defaultAction)
 {
     ResourceAccessRules = new ChangeTrackingList <ResourceAccessRule>();
     VirtualNetworkRules = new ChangeTrackingList <VirtualNetworkRule>();
     IpRules             = new ChangeTrackingList <IPRule>();
     DefaultAction       = defaultAction;
 }
Пример #4
0
    /// <summary>
    /// Generates a node's successors.
    /// </summary>
    /// <param name='currentNode'>
    /// Current node.
    /// </param>
    void generateNodeSuccessors(ref ARAstarNode currentNode)
    {
        List <DefaultAction> possibleTransitions = new List <DefaultAction> ();

        selectedPlanningDomain.generateTransitions(ref currentNode.action.state, ref currentNode.previousState, ref goalNode.action.state, ref possibleTransitions);
        ARAstarNode nextNode;

        foreach (DefaultAction successorAction in possibleTransitions)
        {
            DefaultAction nextAction = successorAction;
            //float newg = currentNode.g + nextAction.cost;
            float newh = selectedPlanningDomain.ComputeHEstimate(nextAction.state, goalNode.action.state);
            if (!Visited.ContainsState(nextAction.state))
            {
                nextNode = new ARAstarNode(Mathf.Infinity, newh, currentNode.action.state, nextAction);
            }
            else
            {
                nextNode = Visited.nodeForState(nextAction.state);
            }
            nextNode.weightExpanded = inflationFactor;
            if (currentNode.highPriority > 0)
            {
                if (!Plan.ContainsState(nextNode.action.state))
                {
                    nextNode.highPriority = currentNode.highPriority - 1;
                }
            }
            UpdateVertex(nextNode);
        }
    }
Пример #5
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     if (Optional.IsDefined(Bypass))
     {
         writer.WritePropertyName("bypass");
         writer.WriteStringValue(Bypass.Value.ToString());
     }
     if (Optional.IsCollectionDefined(VirtualNetworkRules))
     {
         writer.WritePropertyName("virtualNetworkRules");
         writer.WriteStartArray();
         foreach (var item in VirtualNetworkRules)
         {
             writer.WriteObjectValue(item);
         }
         writer.WriteEndArray();
     }
     if (Optional.IsCollectionDefined(IpRules))
     {
         writer.WritePropertyName("ipRules");
         writer.WriteStartArray();
         foreach (var item in IpRules)
         {
             writer.WriteObjectValue(item);
         }
         writer.WriteEndArray();
     }
     writer.WritePropertyName("defaultAction");
     writer.WriteStringValue(DefaultAction.ToSerialString());
     writer.WriteEndObject();
 }
Пример #6
0
    void generateNodePredecessors(ref PlanningDomainBase domain, ref ADAstarNode currentNode)
    {
        List <DefaultAction> possibleTransitions = new List <DefaultAction>();

        domain.generatePredecesors(ref currentNode.action.state, ref currentNode.previousState, ref goalNode.action.state, ref possibleTransitions);

        foreach (DefaultAction predecessorAction in possibleTransitions)
        {
            DefaultAction previousAction = predecessorAction;
            float         newg           = domain.ComputeEstimate(ref previousAction.state, ref goalNode.action.state, "g");
            float         newh           = domain.ComputeEstimate(ref startNode.action.state, ref previousAction.state, "h");
            ADAstarNode   previousNode   = new ADAstarNode(newg, newh, ref predecessorAction.state, ref previousAction);

            currentNode.predecessors.Add(previousNode);

            //If edge does not exist in the list, add it

            if (!edgeList.ContainsKey(new DefaultState[] { previousNode.action.state, currentNode.action.state }))
            {
                edgeList.Add(new DefaultState[] { previousNode.action.state, currentNode.action.state },
                             new Edge(previousNode.action.state, currentNode.action.state, previousNode.action.cost));
            }
            else              //If it exists update cost value if there was any change
            {
                if (edgeList[new DefaultState[] { previousNode.action.state, currentNode.action.state }].cost != currentNode.action.cost)
                {
                    //If there was a change in the cost, set bool to true and update the current cost
                    changeInEdgeCost = true;
                    edgeList[new DefaultState[] { previousNode.action.state, currentNode.action.state }].cost = currentNode.action.cost;
                }
            }
        }
    }
Пример #7
0
 internal Element(string title, string subTitle, Uri imageUrl, DefaultAction defaultAction, IList <Button> buttons)
 {
     _title         = title;
     _subTitle      = subTitle;
     _imageUrl      = imageUrl;
     _defaultAction = defaultAction;
     _buttons       = buttons;
 }
Пример #8
0
 public BestFirstSearchNode(float _g, float _f, ref DefaultState _previousStateRef, ref DefaultState _nextStateRef)
 //: g(_g), f(_f), previousState(_previousState), alreadyExpanded(false)
 {
     g            = _g; f = _f; previousState = _previousStateRef; alreadyExpanded = false;
     action       = new DefaultAction();
     action.cost  = 0.0f;
     action.state = _nextStateRef;
 }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the NetworkRuleSet class.
 /// </summary>
 /// <param name="defaultAction">Specifies the default action of allow
 /// or deny when no other rules match. Possible values include:
 /// 'Allow', 'Deny'</param>
 /// <param name="bypass">Specifies whether traffic is bypassed for
 /// Logging/Metrics/AzureServices. Possible values are any combination
 /// of Logging|Metrics|AzureServices (For example, "Logging, Metrics"),
 /// or None to bypass none of those traffics. Possible values include:
 /// 'None', 'Logging', 'Metrics', 'AzureServices'</param>
 /// <param name="virtualNetworkRules">Sets the virtual network
 /// rules</param>
 /// <param name="ipRules">Sets the IP ACL rules</param>
 public NetworkRuleSet(DefaultAction defaultAction, string bypass = default(string), IList <VirtualNetworkRule> virtualNetworkRules = default(IList <VirtualNetworkRule>), IList <IPRule> ipRules = default(IList <IPRule>))
 {
     Bypass = bypass;
     VirtualNetworkRules = virtualNetworkRules;
     IpRules             = ipRules;
     DefaultAction       = defaultAction;
     CustomInit();
 }
Пример #10
0
        /// <summary>
        /// Processes each record.
        /// </summary>
        protected override void ProcessRecord()
        {
            IAction action = new DefaultAction(Scope, Variable, Value);

            action.Execute(TestSuite);
            WriteObject(TestSuite);
            WriteVerbose(action.Display);
        }
 internal NetworkRuleSet(Bypass?bypass, IList <ResourceAccessRule> resourceAccessRules, IList <VirtualNetworkRule> virtualNetworkRules, IList <IPRule> ipRules, DefaultAction defaultAction)
 {
     Bypass = bypass;
     ResourceAccessRules = resourceAccessRules;
     VirtualNetworkRules = virtualNetworkRules;
     IPRules             = ipRules;
     DefaultAction       = defaultAction;
 }
Пример #12
0
        internal static NetworkRuleSet DeserializeNetworkRuleSet(JsonElement element)
        {
            Optional <Bypass> bypass = default;
            Optional <IList <VirtualNetworkRule> > virtualNetworkRules = default;
            Optional <IList <IPRule> >             ipRules             = default;
            DefaultAction defaultAction = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("bypass"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    bypass = new Bypass(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("virtualNetworkRules"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <VirtualNetworkRule> array = new List <VirtualNetworkRule>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(VirtualNetworkRule.DeserializeVirtualNetworkRule(item));
                    }
                    virtualNetworkRules = array;
                    continue;
                }
                if (property.NameEquals("ipRules"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <IPRule> array = new List <IPRule>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(IPRule.DeserializeIPRule(item));
                    }
                    ipRules = array;
                    continue;
                }
                if (property.NameEquals("defaultAction"))
                {
                    defaultAction = property.Value.GetString().ToDefaultAction();
                    continue;
                }
            }
            return(new NetworkRuleSet(Optional.ToNullable(bypass), Optional.ToList(virtualNetworkRules), Optional.ToList(ipRules), defaultAction));
        }
Пример #13
0
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

            DefaultAction action = null;
            action = Actions.INSTANCE.getAction(EActions.ADICIONAR_PRESUPUESTO) as DefaultAction;
            if (action == null) return;
            action.Parameters.Add(EActionsParameters.CONTAINER, defaultContainerPanel);
            action.Ejecutar();
        }
Пример #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ARAstarNode"/> class.
 /// </summary>
 /// <param name='_g'>
 /// Node's g-value
 /// </param>
 /// <param name='_h'>
 /// Node's h-value
 /// </param>
 /// <param name='_previousStateRef'>
 /// Node's parent's state
 /// </param>
 /// <param name='_stateRef'>
 /// Node's state
 /// </param>
 public ARAstarNode(float _g, float _h, DefaultState _previousStateRef, DefaultState _stateRef)
 {
     g             = _g;
     h             = _h;
     previousState = _previousStateRef;
     action        = new DefaultAction();
     action.cost   = 0.0f;
     action.state  = _stateRef;
 }
Пример #15
0
        private async Task ProcessMessageCallback(CallbackData data)
        {
            if (data.Event == "message")
            {
                var messageText = ((TextMessage)data.Message).Text;

                if (messageText.ToLower() == "start")
                {
                    data.Message.TrackingData = ViberBotTrackingData.Empty();
                    await MenuAction.Execute(data);

                    return;
                }
                if (messageText.ToLower() == "cancel" || data.Message.TrackingData == null)
                {
                    data.Message.TrackingData = ViberBotTrackingData.Empty();
                    await DefaultAction.Execute(data);

                    return;
                }
                if (messageText.ToLower() == "help")
                {
                    data.Message.TrackingData = ViberBotTrackingData.Empty();
                    await HelpAction.Execute(data);

                    return;
                }
                try
                {
                    var trackingData = JsonConvert.DeserializeObject <ViberBotTrackingData>(data.Message.TrackingData);

                    if (messageText.Contains("Action"))
                    {
                        trackingData.NextAction = messageText;
                    }

                    if (trackingData != null && !string.IsNullOrEmpty(trackingData.NextAction))
                    {
                        Type magicType = Type.GetType($"ViberBot.Client.Actions.{trackingData.NextAction}");
                        if (magicType != null)
                        {
                            MethodInfo magicMethod = magicType.GetMethod("Execute");
                            magicMethod.Invoke(null, new object[] { data });
                        }
                    }
                    else
                    {
                        await DefaultAction.Execute(data);
                    }
                }
                catch
                {
                    await SendTextMessage(data.Sender.Id, BotError.SomethingWentWrong);
                }
            }
        }
Пример #16
0
            public override bool Equals(object obj)
            {
                DefaultAction defaultAction = obj as DefaultAction;

                if (defaultAction == null)
                {
                    return(false);
                }
                return(AreEqual(this, defaultAction));
            }
Пример #17
0
 public ADAstarNode(float _g, float _h, float _rhs, ref DefaultState _previousStateRef, ref DefaultState _nextStateRef)
 //: g(_g), f(_f), previousState(_previousState), alreadyExpanded(false)
 {
     g = _g; h = _h; previousState = _previousStateRef;
     alreadyExpanded = false;
     action          = new DefaultAction();
     action.cost     = 0.0f;
     action.state    = _nextStateRef;
     predecessors    = new List <ADAstarNode>();
 }
Пример #18
0
    bool doTunnelTask()
    {
        Stack <DefaultAction> convertedTunnel = new Stack <DefaultAction> ();

        // convert tunnel
        for (int i = 0; i < path.Count; i++)
        {
            GridPlanningState  gs = new GridPlanningState(path[i].getPosition());
            GridPlanningAction g  = new GridPlanningAction(gs, new Vector3());
            convertedTunnel.Push(g);
        }

        GridTunnelSearch gridTunnelSearch =
            new GridTunnelSearch(convertedTunnel,
                                 this.startState.getPosition(), startState._time, goalState._time, gridTimeDomain, 300, 2.0f, 1.0f, 1.0f, startState._speed);

        //new GridTunnelSearch(convertedTunnel, startState.getPosition(), 0.0F, 10.0F, gridTimeDomain, 250, 2.0F, 1.0F, 1.0F);



        //gridTunnelSearch.tryARAStarPlanner(spaceTimePath);
        //Debug.Log ("grid time plan using ara star planner " + spaceTimePath.Count);

        //return true;

        //// generating plan for now
        spaceTimePath.Clear();

        /*
         * // this is the state plan
         * Debug.Log ("grid tunnel plan using best first planner " + gridTunnelSearch.newStatePlan.Count);
         * while (gridTunnelSearch.newStatePlan.Count != 0)
         * {
         *      GridTimeState state = gridTunnelSearch.newStatePlan.Pop() as GridTimeState;
         *      //Debug.LogWarning ("space time state " + state.time);
         *      spaceTimePath.Add(new State(state.currentPosition, state.time));
         * }
         */

        // this is the action plan
        Debug.Log("grid tunnel plan using best first planner " + gridTunnelSearch.newPlan.Count);
        while (gridTunnelSearch.newPlan.Count != 0)
        {
            DefaultAction action = gridTunnelSearch.newPlan.Pop();
            GridTimeState state  = action.state as GridTimeState;
            //Debug.LogWarning ("space time state " + state.time + " " + state.currentPosition);
            spaceTimePath.Add(new State(state.currentPosition, state.time, state.speed));
        }

        bool planComputed = gridTunnelSearch.goalReached;

        //Debug.LogError("grid tunnel plan status " + planComputed);

        return(planComputed);
    }
Пример #19
0
 private void navTree_NodeSelectedChanged(object sender, TreeNodeMouseClickEventArgs e)
 {
     DefaultAction action = null;
     if (e.Node.Name == "PRESUPUESTOS_KEY")
     {
         action = Actions.INSTANCE.getAction(EActions.GESTIONAR_PRESUPUESTOS) as DefaultAction;
     }
     if (action == null) return;
     action.Parameters.Add(EActionsParameters.CONTAINER, defaultContainerPanel);
     action.Ejecutar();
 }
Пример #20
0
 //Parse NetworkRule property DefaultAction in SDK to wrapped property PSNetworkRuleDefaultActionEnum
 public static PSNetWorkRuleDefaultActionEnum ParsePSNetworkRuleDefaultAction(DefaultAction defaultAction)
 {
     if (defaultAction == Microsoft.Azure.Management.Storage.Models.DefaultAction.Allow)
     {
         return(PSNetWorkRuleDefaultActionEnum.Allow);
     }
     else
     {
         return(PSNetWorkRuleDefaultActionEnum.Deny);
     }
 }
Пример #21
0
        /// <summary>
        /// Sets a default action which defines what happens when the user clicks on the element.
        /// </summary>
        /// <param name="action">The default action instance.</param>
        /// <returns></returns>
        public ElementBuilder SetDefaultAction(DefaultAction action)
        {
            if (_defaultAction != null)
            {
                throw new InvalidOperationException("A default action has already been set for this element.");
            }

            _defaultAction = action;

            return(this);
        }
Пример #22
0
        private static DefaultAction GetDefaultAction(HtmlHelper html, DefaultAction action)
        {
            var           actionName = html.GetActionName();
            DefaultAction result;

            if (!Enum.TryParse <DefaultAction>(actionName, true, out result))
            {
                result = DefaultAction.Other;
            }
            return(result);
        }
Пример #23
0
        internal static string ToSerializedValue(this DefaultAction value)
        {
            switch (value)
            {
            case DefaultAction.Allow:
                return("Allow");

            case DefaultAction.Deny:
                return("Deny");
            }
            return(null);
        }
Пример #24
0
        public void Execute_NewDefaultConnectionString_DefaultAdded()
        {
            var state = new GenerationState();

            var action = new DefaultAction(DefaultType.Everywhere, "ConnectionString", ConnectionStringXml);

            action.Execute(state);
            var target = state.Settings.Defaults.FirstOrDefault(x => x.ApplyTo == SettingsXml.DefaultScope.Everywhere);

            Assert.That(target, Is.Not.Null);
            Assert.That(target.ConnectionStringSpecified, Is.True);
            Assert.That(target.ConnectionString.Inline, Is.EqualTo(ConnectionStringXml));
        }
Пример #25
0
        static object GetActualAction(BarItem barItem)
        {
            object action = GetAction(barItem);

            if (action != null)
            {
                return(action);
            }
            action = GetDefaultAction(barItem);
            if (action == null)
            {
                action = new DefaultAction(barItem);
                SetDefaultAction(barItem, action);
            }
            return(action);
        }
Пример #26
0
    public AnimationCurve[] GetPlanAnimationCurve(Stack <DefaultAction> outputPlan)
    {
        int numKeys = outputPlan.Count + 1;

        AnimationCurve curveX     = new AnimationCurve();
        AnimationCurve curveY     = new AnimationCurve();
        AnimationCurve curveZ     = new AnimationCurve();
        AnimationCurve curveSpeed = new AnimationCurve();


        float   time  = Time.time;
        Vector3 pos   = currentStateTransform.position;
        float   speed = currentSpeed;

        curveX.AddKey(time, pos.x);
        curveY.AddKey(time, pos.y);
        curveZ.AddKey(time, pos.z);
        curveSpeed.AddKey(time, speed);

        for (int i = 0; i < numKeys; i++)
        {
            DefaultAction action = outputPlan.ElementAt(i);
            if (action != null && action.state != null)
            {
                GridTimeState gridTimeState = action.state as GridTimeState;
                if (gridTimeState != null)
                {
                    time  = gridTimeState.time;
                    pos   = gridTimeState.currentPosition;
                    speed = gridTimeState.speed;
                }

                curveX.AddKey(time, pos.x);
                curveY.AddKey(time, pos.y);
                curveZ.AddKey(time, pos.z);
                curveSpeed.AddKey(time, speed);
            }
        }

        AnimationCurve[] curves = new AnimationCurve[4];
        curves[0] = curveX;
        curves[1] = curveY;
        curves[2] = curveZ;
        curves[3] = curveSpeed;

        return(curves);
    }
Пример #27
0
    public override TaskStatus execute(float maxTime)
    {
        Stack <DefaultAction> convertedTunnel = new Stack <DefaultAction> ();

        // convert tunnel
        for (int i = tunnel.Count - 1; i >= 0; i--)
        {
            GridPlanningState  gs = new GridPlanningState(tunnel[i].getPosition());
            GridPlanningAction g  = new GridPlanningAction(gs, new Vector3());
            convertedTunnel.Push(g);
        }

        GridTunnelSearch gridTunnelSearch =
            new GridTunnelSearch(convertedTunnel, startState.getPosition(), 0.0F, 10.0F, gridTimeDomain, 250, 2.0F, 1.0F, 1.0F);

        Debug.Log("grid tunnel plan " + gridTunnelSearch.newPlan.Count);

        //// generating plan for now
        spaceTimePath.Clear();

        while (gridTunnelSearch.newPlan.Count != 0)
        {
            DefaultAction action = gridTunnelSearch.newPlan.Pop();
            GridTimeState state  = action.state as GridTimeState;
            spaceTimePath.Add(new State(state.currentPosition, state.time));
        }

        bool planComputed = gridTunnelSearch.goalReached;



        // TODO : determine task status
        TaskStatus taskStatus = TaskStatus.Success;

        if (planComputed == true)
        {
            taskStatus = TaskStatus.Success;
        }
        else
        {
            taskStatus = TaskStatus.Failure;             // TODO: I dont know, check
        }
        setTaskPriority(TaskPriority.Inactive);

        return(taskStatus);
    }
Пример #28
0
        static async Task SendGenericTemplateAndQuickReplies()
        {
            // build image

            var msg = new AttachmentMessage()
                      .StartBuildingTemplateAttachment()
                      .UseGenericTemplate()
                      .AddElement(
                Element
                .StartBuilding()
                .SetTitle("You GOT IT!")
                .SetDefaultAction(
                    DefaultAction
                    .Create(new Uri("https://duckduckgo.com"))
                    .HideWebviewShareButton()
                    )
                .SetImageUrl("https://thechangreport.com/img/lightning.png")
                .AddButton(
                    new ShareButton(
                        "I took the math quiz!",
                        "My result: AWESOME",
                        "https://bot.peters-hats.com/img/hats/fez.jpg",
                        DefaultAction
                        .Create("http://m.me/petershats?ref=invited_by_24601"),
                        new UrlButton("Test", "https://duckduckgo.com")
                        )
                    )
                .AddButton(
                    new CallButton(
                        "Call this guy!",
                        "+12347234329"
                        )
                    )
                .Build()
                )
                      .BuildTemplate()
                      .AddTextQuickReply("test", "")
                      .AddQuickReply(QuickReplyContentType.UserEmail)
                      .ReturnCompletedMessage();

            // send message and print message id

            Console.WriteLine(await _client.SendMessage(_recipient, msg));
        }
Пример #29
0
        private void adicionar(object sender, EventArgs e)
        {
            DefaultAction action = Actions.INSTANCE.getAction(EActions.ADICIONAR_CATEGORIA_AL_LADO) as DefaultAction;

            if (action == null)
            {
                return;
            }
            if (categoriasTree.SelectedNode == null)
            {
                return;
            }
            action.Parameters.Add(EActionsParameters.CATEGORIAS, categorias);
            action.Parameters.Add(EActionsParameters.IDS, idSet);
            foreach (Categoria cat in categorias)
            {
                if (cat.Id.ToString() == categoriasTree.SelectedNode.Name)
                {
                    action.Parameters.Add(EActionsParameters.CATEGORIA, cat);
                }
            }
            if (categoriasTree.SelectedNode.Name == "INGRESOS_KEY_INDEX")
            {
                action.Parameters.Add(EActionsParameters.TIPO_CATEGORIA, ETipoCategoria.INGRESO);
            }
            if (categoriasTree.SelectedNode.Name == "EGRESOS_KEY_INDEX")
            {
                action.Parameters.Add(EActionsParameters.TIPO_CATEGORIA, ETipoCategoria.EGRESO);
            }
            action.Ejecutar();
            fillTree();
            //seleccionar la nueva categoria
            if (!action.Parameters.ContainsKey(EActionsParameters.NUEVA_CATEGORIA))
            {
                return;
            }
            Categoria nuevacat = action.Parameters[EActionsParameters.NUEVA_CATEGORIA] as Categoria;

            if (nuevacat == null)
            {
                return;
            }
            categoriasTree.SelectedNode = categoriasTree.Nodes.Find(nuevacat.Id.ToString(), true)[0];
        }
Пример #30
0
    public override FootstepPlanningAction getFirstAction()
    {
        FootstepPlanningAction firstAction = null;

        int plannedActions = outputPlan.Count;

        int  i            = 0;
        bool isGridAction = false;

        while (i < plannedActions && firstAction == null && !isGridAction)
        {
            DefaultAction defAction = outputPlan.Pop();
            firstAction = defAction as FootstepPlanningAction;

            if (firstAction == null)
            {
                GridPlanningAction gridAction = defAction as GridPlanningAction;
                if (gridAction != null)
                {
                    outputPlan.Push(defAction);
                    isGridAction = true;
                }
                else
                {
                    GridTimeAction gridTimeAction = defAction as GridTimeAction;
                    if (gridTimeAction != null)
                    {
                        outputPlan.Push(defAction);
                        isGridAction = true;
                    }
                }
            }

            i++;
        }

        if (firstAction != null)
        {
            currentState = firstAction.state as FootstepPlanningState;
        }

        return(firstAction);
    }
Пример #31
0
    private float[] ComputeNodeDistances(DefaultAction[] plan)
    {
        float[] distances = new float[plan.Length];
        int i = 0;
        GridPlanningAction action = null;
        GridPlanningState state = null;
        while( action == null && i < plan.Length)
        {
            action = plan[i] as GridPlanningAction;
            if (action != null)
                state = action.state as GridPlanningState;
            distances[i] = 0;
            i++;
        }

        GridPlanningState nextState;
        while(i+1 < plan.Length)
        {
            nextState = (plan[i+1] as GridPlanningAction).state as GridPlanningState;

            distances[i+1] = ( state.currentPosition - nextState.currentPosition ).magnitude;

            state = nextState;
            i++;
        }

        return distances;
    }