// Method responsible for producing the effect of going back in time public void TimeTravel() { Array stack = TimeStack.ToArray(); // If stack is not empty if (stack.Length > 0) { // Remove and set the positions that the Sprites were previously in Laser.myPosition = (Vector2)TimeStack.Pop(); Asis.setDirection((String)TimeStack.Pop()); Asis.myPosition = (Vector2)TimeStack.Pop(); redEnemy.myPosition = (Vector2)TimeStack.Pop(); if (redEnemy.getAlive() == false) { redEnemy.Resurrect(); } myState = new TimeTravelState(this); } }
// Method responsible for producing the effect of going back in time public void TimeTravel() { // If stack is not empty if (TimeStack.Count > 0) { for (int i = PositionsList.Count - 1; i >= 0; i--) { PositionsList[i].myPosition = (Vector2)TimeStack.Pop(); } // Changes background color myState = new TimeTravelState(this); } }