public bool UndoAStep() { if (PlayTimeLine.Count <= 0) { return(false); } PlayInfo oldPoint = PlayTimeLine.Pop(); Button btn = Matrix[oldPoint.Point.Y][oldPoint.Point.X]; btn.BackgroundImage = null; if (PlayTimeLine.Count <= 0) { CurrentPlayer = 0; } else { oldPoint = PlayTimeLine.Peek(); CurrentPlayer = oldPoint.CurrentPlayer == 1 ? 0 : 1; } ChangePlayer(); return(true); }
private bool UndoStep() { if (PlayTimeLine.Count <= 0) { return(false); } PlayInfo oldPoint = PlayTimeLine.Pop(); UndoTimeLine.Push(oldPoint); Button btn = Matrix[oldPoint.Point.Y][oldPoint.Point.X]; btn.BackgroundImage = null; if (PlayTimeLine.Count <= 0) { CurrentPlayer = 0; } else { oldPoint = PlayTimeLine.Peek(); } ChangePlayer(); return(true); }
public bool Redo() { if (UndoTimeLine.Count <= 0) { return(false); } bool isRedo1 = RedoStep(); bool isRedo2 = RedoStep(); PlayInfo oldPoint = PlayTimeLine.Peek(); CurrentPlayer = oldPoint.CurrentPlayer == 1 ? 0 : 1; return(isRedo1 && isRedo2); }
/// <summary> /// Đi lại cho quân cờ /// </summary> /// <returns></returns> public bool Undo() { if (PlayTimeLine.Count <= 0) { return(false); } bool isUndo1 = UndoAStep(); bool isUndo2 = UndoAStep(); if (PlayTimeLine.Count <= 0) { CurrentPlayer = 0; } else { PlayInfo oldPoint = PlayTimeLine.Peek(); CurrentPlayer = oldPoint.CurrentPlayer == 1 ? 0 : 1; } return(isUndo1 && isUndo2); }