private void toolPrev_Click(object sender, EventArgs e) { if (Step >= OperateList.Count - 1) { MessageBox.Show("End"); return; } Step++; Operate oper = OperateList[Step]; switch (oper.Direct) { case LEFT: Soko.Left(); break; case RIGHT: Soko.Right(); break; case UP: Soko.Up(); break; case DOWN: Soko.Down(); break; default: break; } ReDraw(); }
public void SetHomeSokoban(MapState[,] _OriginalMap, CSokoMan _soko) { while (_soko.GetRoadStackCount() > 0) { Operate oper = _soko.RoadStack.Pop(); OperateList.Insert(0, oper); } OriginalMap = _OriginalMap; Soko.Map = _OriginalMap; }
public void GoBack() { if (RoadStack.Count == 0) { return; } Operate r = RoadStack.Pop(); switch (r.Direct) { case LEFT: Right(); RoadStack.Pop(); if (r.PushBox) { if (map[ManX - 2, ManY] == MapState.BOX) { map[ManX - 2, ManY] = MapState.ROAD; } if (map[ManX - 2, ManY] == MapState.DIRECT_BOX) { map[ManX - 2, ManY] = MapState.DIRECT; } if (map[ManX - 1, ManY] == MapState.ROAD) { map[ManX - 1, ManY] = MapState.BOX; } if (map[ManX - 1, ManY] == MapState.DIRECT) { map[ManX - 1, ManY] = MapState.DIRECT_BOX; } } break; case RIGHT: Left(); RoadStack.Pop(); if (r.PushBox) { if (map[ManX + 2, ManY] == MapState.BOX) { map[ManX + 2, ManY] = MapState.ROAD; } if (map[ManX + 2, ManY] == MapState.DIRECT_BOX) { map[ManX + 2, ManY] = MapState.DIRECT; } if (map[ManX + 1, ManY] == MapState.ROAD) { map[ManX + 1, ManY] = MapState.BOX; } if (map[ManX + 1, ManY] == MapState.DIRECT) { map[ManX + 1, ManY] = MapState.DIRECT_BOX; } } break; case UP: Down(); RoadStack.Pop(); if (r.PushBox) { if (map[ManX, ManY - 2] == MapState.BOX) { map[ManX, ManY - 2] = MapState.ROAD; } if (map[ManX, ManY - 2] == MapState.DIRECT_BOX) { map[ManX, ManY - 2] = MapState.DIRECT; } if (map[ManX, ManY - 1] == MapState.ROAD) { map[ManX, ManY - 1] = MapState.BOX; } if (map[ManX, ManY - 1] == MapState.DIRECT) { map[ManX, ManY - 1] = MapState.DIRECT_BOX; } } break; case DOWN: Up(); RoadStack.Pop(); if (r.PushBox) { if (map[ManX, ManY + 2] == MapState.BOX) { map[ManX, ManY + 2] = MapState.ROAD; } if (map[ManX, ManY + 2] == MapState.DIRECT_BOX) { map[ManX, ManY + 2] = MapState.DIRECT; } if (map[ManX, ManY + 1] == MapState.ROAD) { map[ManX, ManY + 1] = MapState.BOX; } if (map[ManX, ManY + 1] == MapState.DIRECT) { map[ManX, ManY + 1] = MapState.DIRECT_BOX; } } break; } }