private void fromCenterSwitch(TraceInfo info, Color colorTrace, float secondsUntil) { switch (info.to) { case Direction.North: counterNorth--; north.DrawTraceLater(info.time / 2.0f, true, counterNorth, colorTrace, (info.time / 2.0f) + secondsUntil, info.goingBack); break; case Direction.South: counterSouth--; south.DrawTraceLater(info.time / 2.0f, true, counterSouth, colorTrace, (info.time / 2.0f) + secondsUntil, info.goingBack); break; case Direction.East: counterEast--; east.DrawTraceLater(info.time / 2.0f, true, counterEast, colorTrace, (info.time / 2.0f) + secondsUntil, info.goingBack); break; case Direction.West: counterWest--; west.DrawTraceLater(info.time / 2.0f, true, counterWest, colorTrace, (info.time / 2.0f) + secondsUntil, info.goingBack); break; } }
private void SingularPathCall(int dirX, int dirY, float posX, float posY, float secondsUntil, bool end = false) { TraceInfo info = new TraceInfo(); if (!end) { info.from = Direction.Center; if (dirX > 0) { info.to = Direction.East; } else if (dirX < 0) { info.to = Direction.West; } else if (dirY > 0) { info.to = Direction.North; } else if (dirY < 0) { info.to = Direction.South; } } else { info.to = Direction.Center; if (dirX < 0) { info.from = Direction.East; } else if (dirX > 0) { info.from = Direction.West; } else if (dirY < 0) { info.from = Direction.North; } else if (dirY > 0) { info.from = Direction.South; } } info.time = 1 / (speed * 2); if (Movements.Count > 0 && Movements.Peek().from == info.to && Movements.Peek().to == info.from) { Movements.Pop(); info.goingBack = true; } else { info.goingBack = false; Movements.Push(info); } board.GetTile(posX, posY).trace(info, secondsUntil); }
private void makeHintTrace(Point start, Point end) { TraceInfo ifo = new TraceInfo(); float xOffset = -(map.GetWidth() + 1) / 2.0f; float yOffset = -(map.GetHeight() + 1) / 2.0f; ifo.from = Direction.Center; if (start.x < end.x) { ifo.to = Direction.East; } else if (start.x > end.x) { ifo.to = Direction.West; } else if (start.y < end.y) { ifo.to = Direction.North; } else if (start.y > end.y) { ifo.to = Direction.South; } ifo.time = 0; GetTile(start.x + xOffset + 1, start.y + yOffset + 1).hintTrace(ifo); ifo.to = Direction.Center; if (start.x < end.x) { ifo.from = Direction.West; } else if (start.x > end.x) { ifo.from = Direction.East; } else if (start.y < end.y) { ifo.from = Direction.South; } else if (start.y > end.y) { ifo.from = Direction.North; } GetTile(end.x + xOffset + 1, end.y + yOffset + 1).hintTrace(ifo); }
public void hintTrace(TraceInfo info) { hintTraces.makeTrace(info, Color.yellow, 0); }
public void trace(TraceInfo info, float secondsUntil) { traces.makeTrace(info, color, secondsUntil); }
public void makeTrace(TraceInfo info, Color colorTrace, float secondsUntil) { bool fromCenter = false; switch (info.from) { case Direction.North: counterNorth++; if (info.to == Direction.Center) { north.DrawTraceLater(info.time, fromCenter, counterNorth, colorTrace, secondsUntil, info.goingBack); } else { north.DrawTraceLater(info.time / 2, fromCenter, counterNorth, colorTrace, secondsUntil, info.goingBack); fromCenterSwitch(info, colorTrace, secondsUntil); } break; case Direction.South: counterSouth++; if (info.to == Direction.Center) { south.DrawTraceLater(info.time, fromCenter, counterSouth, colorTrace, secondsUntil, info.goingBack); } else { south.DrawTraceLater(info.time / 2, fromCenter, counterSouth, colorTrace, secondsUntil, info.goingBack); fromCenterSwitch(info, colorTrace, secondsUntil); } break; case Direction.East: counterEast++; if (info.to == Direction.Center) { east.DrawTraceLater(info.time, fromCenter, counterEast, colorTrace, secondsUntil, info.goingBack); } else { east.DrawTraceLater(info.time / 2, fromCenter, counterEast, colorTrace, secondsUntil, info.goingBack); fromCenterSwitch(info, colorTrace, secondsUntil); } break; case Direction.West: counterWest++; if (info.to == Direction.Center) { west.DrawTraceLater(info.time, fromCenter, counterWest, colorTrace, secondsUntil, info.goingBack); } else { west.DrawTraceLater(info.time / 2, fromCenter, counterWest, colorTrace, secondsUntil, info.goingBack); fromCenterSwitch(info, colorTrace, secondsUntil); } break; case Direction.Center: switch (info.to) { case Direction.North: counterNorth--; fromCenter = true; north.DrawTraceLater(info.time, fromCenter, counterNorth, colorTrace, secondsUntil, info.goingBack); break; case Direction.South: counterSouth--; fromCenter = true; south.DrawTraceLater(info.time, fromCenter, counterSouth, colorTrace, secondsUntil, info.goingBack); break; case Direction.East: counterEast--; fromCenter = true; east.DrawTraceLater(info.time, fromCenter, counterEast, colorTrace, secondsUntil, info.goingBack); break; case Direction.West: counterWest--; fromCenter = true; west.DrawTraceLater(info.time, fromCenter, counterWest, colorTrace, secondsUntil, info.goingBack); break; } break; } }