Ejemplo n.º 1
0
    void SaveState()
    {
        TimelapseContainer container = new TimelapseContainer(this._actor);

        _statsList[_currentIndex] = container;
        _currentIndex             = (_currentIndex + 1) % _numStored;
    }
Ejemplo n.º 2
0
    void Awake()
    {
        _actor = this.GetComponent <Actor>();

        _updateIntervall = _rewindTime / _numStored;
        _currentIndex    = 0;


        _statsList = new List <TimelapseContainer>();
        _statsList.Clear();
        for (int i = 0; i < 20; i++)
        {
            TimelapseContainer container = new TimelapseContainer(this._actor);
            _statsList.Add(container);
        }
    }
Ejemplo n.º 3
0
    //Coroutine
    IEnumerator MoveEnumerator()
    {
        //stop recording states
        StopRecord();
        int i = _currentIndex;

        while (i != (_currentIndex + 1) % _numStored)
        {
            //negative modulo does not seem to work propperly, so if i is negatetive here add _numStored
            if (i < 0)
            {
                i += _numStored;
            }
            //which might lead to meeting the exit condition, so break in that case.
            if (i == _currentIndex + 1)
            {
                break;
            }

            this._actor._ActorData._HP = _statsList[i]._HP;
            this._actor._ActorData._MP = _statsList[i]._MP;
            this._actor._ActorData._EP = _statsList[i]._EP;
            this.transform.position    = _statsList[i]._pos;
            this.transform.rotation    = _statsList[i]._rot;
            i = ((i - 1) % _numStored);
            yield return(null);
        }
        // at the end of the coroutine:
        // clear the list and set all of them to the point of this rewind
        _statsList.Clear();
        for (int j = 0; j < 20; j++)
        {
            TimelapseContainer container = new TimelapseContainer(this._actor);
            _statsList.Add(container);
        }
        //resume recording states
        StartRecord();
    }