Пример #1
0
    private int AddLoopActions(int representationIndex, LoopActions loopActions)
    {
        LoopUIHelper loopUIHelper = actionsSequenceContainer.actionRepresentations[representationIndex].GetComponent <LoopUIHelper>();

        for (int i = representationIndex + 1; i < actionsSequenceContainer.actionRepresentations.Count; i++)
        {
            if (actionsSequenceContainer.actionRepresentations[i].isLocked)
            {
                AgentState newState = Instantiate(actionsSequenceContainer.actionRepresentations[i].action.actionState);
                if (loopUIHelper.linkedActions.Contains(actionsSequenceContainer.actionRepresentations[i]))
                {
                    loopActions.loopStates.Add(newState);
                }
                else
                {
                    return(i - 1);
                }
                if (newState.GetType().Equals(typeof(LoopActions)))
                {
                    i = AddLoopActions(i, newState as LoopActions);
                }
            }
            else
            {
                return(i - 1);
            }
        }
        return(actionsSequenceContainer.actionRepresentations.Count);
    }
Пример #2
0
        private void _checkToChangeState(AgentState ms)
        {
            if (this.state != null)
            {
                //QuixConsole.Log("Check change");
                if (ms == this.state)
                {
                    this.state.OnRepeat();
                }
                else
                {
                    if (this.state != null)
                    {
                        this.state.OnDesactivate();
                    }

                    this.state = ms;
                    QuixConsole.Log("State", ms.GetType().ToString());
                    this.state.OnActivate();
                }
            }
            else
            {
                this.state = ms;
            }
        }
Пример #3
0
    public void Activate()
    {
        if (actionsSequenceContainer == null)
        {
            return;
        }
        isPlaying = true;
        anim.SetBool("IsRunning", true);
        ResetPosition();
        ShowSequenceEditor(false);
        playItterator = 0;

        runtimeStates = new List <AgentState>();

        //bool withinLoop = false;
        //        previousItteratorPosition = 0;
        //statePairs = new Dictionary<AgentState, AgentState>();
        for (int i = 0; i < actionsSequenceContainer.actionRepresentations.Count; i++)
        {
            AgentState newState = Instantiate(actionsSequenceContainer.actionRepresentations[i].action.actionState);
            runtimeStates.Add(newState);
            if (newState.GetType().Equals(typeof(LoopActions)))
            {
                i = AddLoopActions(i, newState as LoopActions);
            }
            //if (withinLoop)
            //{
            //    (runtimeStates[runtimeStates.Count - 1] as LoopActions).loopStates.Add(newState);
            //}
            //else
            //{
            //    runtimeStates.Add(newState);
            //}
        }
        LoadNextState();
    }