public void Update() { SimulationRunner.GetInstance().Update(m_machines); foreach (Machine m in m_machines) { m.DrawDebug(); } foreach (Conveyor c in m_conveyors) { c.DrawDebug(1 / 60.0f); } // Highlight mouse cursor tile Point mouseTile = InputManager.GetPointerTile(); GDK.DrawAABB(new Vector3(mouseTile.X + 0.5f, 0f, mouseTile.Y + 0.5f), new Vector3(0.45f, 0.1f, 0.45f), GDK.FadeColor(Color.yellow, 0.35f)); /* * Machine machineBeingPlaced = new Machine(); * machineBeingPlaced._size = new Point(3, 2); * machineBeingPlaced._position = mouseTile; * * machineBeingPlaced.DrawDebug(); * * PlacementCheckResult result = GetIntersections(machineBeingPlaced); * * foreach(Point p in result._intersectingPoints) * { * GDK.DrawAABB(new Vector3(p.X + 0.5f, 2f, p.Y + 0.5f), new Vector3(0.45f, 0.1f, 0.45f), GDK.FadeColor(Color.red, 0.5f)); * }*/ }
public void DrawDebug() { if (OccupiesTile(InputManager.GetPointerTile())) { GDK.DrawText(GetMachineInfoString(), _gridTransform.GetPos(), Color.black); } _gridTransform.DrawInWorld(Color.gray); if (_isSelected) { _gridTransform.DrawInWorld(GDK.FadeColor(Color.cyan, 0.25f), 1f, 0.1f); } foreach (MachineConnector m in _inputs) { if (m != null) { m.DebugDraw(); } } foreach (MachineConnector m in _outputs) { if (m != null) { m.DebugDraw(); } } }
public void DrawDebug(float relativeTime) { if (_start.GetPointsTo(_end).Contains(InputManager.GetPointerTile())) { StringBuilder sb = new StringBuilder(); sb.AppendLine(string.Format("Start at {0} from {1}", _start, _startCurveDirection)); sb.AppendLine(string.Format("Linear to {0}", _linearDirection)); sb.AppendLine(string.Format("Ends at {0} from {1}", _end, _endCurveDirection)); GDK.DrawText(sb.ToString(), _start.ToVector3(), Color.black); } if (_start.X == _end.X) { GDK.DrawFilledAABB(new Vector3(_start.X + 0.5f, 0.1f, (System.Math.Abs(_start.Y + _end.Y)) / 2.0f + 0.5f), new Vector3(System.Math.Abs(_end.X - _start.X) + 1, 0.1f, System.Math.Abs(_end.Y - _start.Y) + 1) / 2, Color.magenta); } else { GDK.DrawFilledAABB(new Vector3((_start.X + _end.X) / 2.0f + 0.5f, 0.1f, _start.Y + 0.5f), new Vector3(System.Math.Abs(_end.X - _start.X) + 1, 0.1f, System.Math.Abs(_end.Y - _start.Y) + 1) / 2, Color.magenta); } relativeTime -= _startLength; if (relativeTime >= 0) { float length = Length; for (float i = relativeTime % BOX_SPACING; i < Mathf.Min(relativeTime, length); i += BOX_SPACING) { DrawBox(i); } } }
public static void CreateInstance() { if (_instance == null) { _instance = new GDK(); } }
public void DebugDraw() { GDK.DrawFilledAABB(GetWorldPosition().ToVector3() + new Vector3(0.5f, 0.5f, 0.5f) + new Point(GetWorldDirection()).ToVector3() * 0.5f, new Vector3(0.25f, 0.25f, 0.25f), _input ? Color.red : Color.green); if (_input && IsConnected) { //GDK.DrawLine(GetWorldPosition().ToVector3() + new Vector3(0.5f, 0.5f, 0.5f) + Vector3.up * 0.5f + new Point(GetWorldDirection()).ToVector3() * 0.5f, _otherConnector.GetWorldPosition().ToVector3() + new Vector3(0.5f, 0.5f, 0.5f) + new Point(_otherConnector.GetWorldDirection()).ToVector3() * 0.5f, Color.black); } }
void DrawBox(float time) { if (time < StartLength) { if (_linearDirection == _startCurveDirection) { GDK.DrawFilledAABB(_start.ToVector3() + new Point(_linearDirection).ToVector3() * (time - 0.5f) + new Vector3(0.5f, 1.0f, 0.5f), new Vector3(0.25f, 0.25f, 0.25f), Color.yellow); } else { Vector3 entry = _start.ToVector3() - new Point(_startCurveDirection).ToVector3() * 0.5f; Vector3 centerOfRotation = entry + new Point(_linearDirection).ToVector3() * 0.5f; float angleToDo = Vector3.SignedAngle(new Point(_startCurveDirection).ToVector3(), new Point(_linearDirection).ToVector3(), new Vector3(0, 1, 0));; Matrix4x4 mat = Matrix4x4.Rotate(Quaternion.Euler(0, angleToDo * (time / StartLength), 0)); Vector3 displacement = mat.MultiplyVector(entry - centerOfRotation); Vector3 positionToDraw = centerOfRotation + displacement; GDK.DrawFilledAABB(positionToDraw + new Vector3(0.5f, 1.0f, 0.5f), new Vector3(0.25f, 0.25f, 0.25f), Color.yellow); } } else if (time < Length - EndLength) { GDK.DrawFilledAABB(_start.ToVector3() + new Point(_linearDirection).ToVector3() * (time - StartLength + 0.5f) + new Vector3(0.5f, 1.0f, 0.5f), new Vector3(0.25f, 0.25f, 0.25f), Color.yellow); } else { if (_linearDirection == _endCurveDirection) { GDK.DrawFilledAABB(_start.ToVector3() + new Point(_linearDirection).ToVector3() * (time - 0.5f) + new Vector3(0.5f, 1.0f, 0.5f), new Vector3(0.25f, 0.25f, 0.25f), Color.yellow); } else { Vector3 entry = _end.ToVector3() - new Point(_linearDirection).ToVector3() * 0.5f; Vector3 centerOfRotation = entry + new Point(_endCurveDirection).ToVector3() * 0.5f; float angleToDo = Vector3.SignedAngle(new Point(_linearDirection).ToVector3(), new Point(_endCurveDirection).ToVector3(), new Vector3(0, 1, 0));; Matrix4x4 mat = Matrix4x4.Rotate(Quaternion.Euler(0, angleToDo * ((time - Length + EndLength) / EndLength), 0)); Vector3 displacement = mat.MultiplyVector(entry - centerOfRotation); Vector3 positionToDraw = centerOfRotation + displacement; GDK.DrawFilledAABB(positionToDraw + new Vector3(0.5f, 1.0f, 0.5f), new Vector3(0.25f, 0.25f, 0.25f), Color.yellow); } } }
private void Awake() { if (_instance != null && _instance != this) { Destroy(gameObject); return; } _instance = this; DontDestroyOnLoad(gameObject); GDK.CreateInstance(); MachineManager.CreateInstance(); InputManager.CreateInstance(); SimulationRunner.CreateInstance(); }
public void DrawInWorld(Color color, float height = 1f, float border = 0f) { Vector3 halfExtents = GetCurrentVectorSize(height) * 0.5f + new Vector3(border, border, border); GDK.DrawFilledAABB(GetCenterPos(), halfExtents, color); }
private void OnGUI() { GDK.GetInstance().OnGUI(); }
private void DrawObjects(Camera camera) { GDK.GetInstance().DrawObjects(); }
private void Update() { GDK.GetInstance().Update(); MachineManager.GetInstance().Update(); InputManager.GetInstance().Update(); }