Exemplo n.º 1
0
        public void Undo()
        {
            //I wrote this check, and I think it fixed the issue of undo-ing during aftermooves, but...
            //feels too easy for a fairly complex system. *squinty eyes* investigate if the problem is really fixed.
            _afterMove?.Undo();
            if (!executed)
            {
                Debug.LogWarning("cant undo a move that hasnt been executed?");
                return;
            }
            if (!_isComplete)
            {
                //The animation hasn't completed, we need to either complete it now (before instantly undoing it)
                //or stop it wherever it is, and bail out of any loops.
                _puzzleManager.CallCancelMove(this);
            }

            //the actual undo:
            foreach (var akp in _allSubMoves)
            {
                akp.Key.SnapTo(akp.Value.startingNode);
                akp.Key.SetFromLocationData(akp.Value.agentStartingData);
            }
            cancelled   = true;
            executed    = false;
            _isComplete = false;
        }