Esempio n. 1
0
 // Update is called once per frame
 private void Update()
 {
     if (goalStateFrame != startStateFrame)
     {
         this.lerpT += 0.01f * Mathf.Abs(goalStateFrame - startStateFrame);
         float t = Easings.easeInOut(this.lerpT);
         if (this.lerpT > 1)
         {
             if (this.stateIndex != goalStateFrame)
             {
                 this.stateIndex = stateIndex + (int)Mathf.Sign(goalStateFrame - stateIndex) * 1;
                 this._prevState = this._curState;
                 this._curState  = GetStateAtTime(this.stateIndex);
                 this.lerpT      = 0.0f;
             }
             else
             {
                 startStateFrame = goalStateFrame;
             }
         }
         else if (this._curState != null)
         {
             this.UpdateCurrentState(t);
         }
     }
 }
Esempio n. 2
0
 public void updateAllStates(WorkspaceState prevState, float t)
 {
     // t is used as the interpolation parameter.
     foreach (VisualElement element in this.elementStates.Keys)
     {
         VisualElementState curElementState = elementStates[element];
         if (prevState.ElementExists(element))
         {
             // Interpolate between states
             VisualElementState prevElementState = prevState.elementStates[element];
             prevElementState.BlendStates(curElementState, t);
         }
         else
         {
             // Pop in from zero scale
             VisualElementState pseudoState = new VisualElementState(curElementState);
             pseudoState.SetStateScale(Vector3.zero);
             pseudoState.BlendStates(curElementState, t);
         }
     }
     foreach (VisualElement element in prevState.elementStates.Keys)
     {
         if (!this.ElementExists(element))
         {
             // Disable
             VisualElementState prevElementState = prevState.elementStates[element];
             VisualElementState pseudoState      = new VisualElementState(prevElementState);
             pseudoState.SetStateScale(Vector3.zero);
             prevElementState.BlendStates(pseudoState, t);
         }
     }
 }
Esempio n. 3
0
        /// Adds a new state at the provided index. The default index (-1)
        /// will add a new state to the end of the state list.
        public void InsertNewState(int index = -1)
        {
            // Create the new state based on the current workspace conditions.
            WorkspaceState state;

            if (this._curState == null)
            {
                state = new WorkspaceState();
            }
            else
            {
                state = new WorkspaceState(this._curState);
            }
            this._prevState = this._curState;
            this._curState  = state;


            if (index < 0)
            {
                // Set to end
                this.stateHistory_.Add(state);
            }
            else
            {
                this.stateHistory_.Insert(index, state);
            }
            // increment slider size
            timeline.setStateCount(this.stateHistory_.Count);

            print("Total States: " + this.stateHistory_.Count);
        }
Esempio n. 4
0
 public WorkspaceState(WorkspaceState prevState)
 {
     this.elementStates = new Dictionary <VisualElement, VisualElementState>();
     foreach (VisualElement element in prevState.elementStates.Keys)
     {
         VisualElementState elementState    = prevState.elementStates[element];
         VisualElementState newElementState = new VisualElementState(elementState);
         this.elementStates.Add(element, newElementState);
     }
 }
Esempio n. 5
0
 public void OnTimelineChanged(int index)
 {
     Debug.Log(index);
     if (index == stateIndex)
     {
         return;
     }
     this._prevState      = this._curState;
     this.startStateFrame = this.stateIndex;
     this.goalStateFrame  = index;
     this.stateIndex      = stateIndex + (int)Mathf.Sign(index - stateIndex) * 1;
     this._curState       = GetStateAtTime(stateIndex);
     this.lerpT           = 0;
     // refresh selection, remove any elements that aren't in the current state
     RefreshSelection();
 }
Esempio n. 6
0
        public void ReqeuestPreviousSlide()
        {
            if (goalStateFrame != startStateFrame || this.stateIndex == 0)
            {
                return;
            }
            int index = this.stateIndex - 1;

            this._prevState      = this._curState;
            this.startStateFrame = this.stateIndex;
            this.goalStateFrame  = index;
            this.stateIndex      = stateIndex + (int)Mathf.Sign(index - stateIndex) * 1;
            this._curState       = GetStateAtTime(stateIndex);
            this.lerpT           = 0;
            // refresh selection, remove any elements that aren't in the current state
            RefreshSelection();
            timeline.SetSlider(index);
        }
Esempio n. 7
0
 public bool DeleteState(int index)
 {
     if (index < 0 || index >= this.stateHistory_.Count)
     {
         return(false);
     }
     this.stateHistory_.RemoveAt(index);
     if (index < this.stateIndex)
     {
         this.stateIndex -= 1;
     }
     else if (index == this.stateIndex)
     {
         if (index > 0)
         {
             this.stateIndex -= 1;
         }
         this._curState       = this.stateHistory_[stateIndex];
         this.goalStateFrame  = stateIndex;
         this.startStateFrame = stateIndex;
         this.UpdateCurrentState(1);
     }
     return(true);
 }