public override void OnGUI(Context context) { Color color = Color.white; switch (m_ColorMode) { case ColorMode.Fixed: color = Color.red; break; case ColorMode.Rainbow: color = m_ColorModifierRainbow.Current; break; } Vector2 startPos = m_StartPosition == TracerStartPosition.w_2_0 ? new Vector2(Screen.width / 2f, 0f) : m_StartPosition == TracerStartPosition.w_2_h ? new Vector2(Screen.width / 2f, Screen.height) : new Vector2(Screen.width / 2f, Screen.height / 2f); foreach (AgentHumanDT agentHumanDT in context.LivingEnitites) { if (m_ColorMode == ColorMode.Visibility) { color = context.VisibleEntities.Contains(agentHumanDT) ? Color.green : Color.red; } Vector3 tPos = Camera.main.WorldToScreenPoint(agentHumanDT.transform.position); if (tPos.z > 0f) { Vector2 gPos = GUIUtility.ScreenToGUIPoint(tPos); gPos.y = Screen.height - gPos.y; if (m_ColorMode == ColorMode.Gradient) { GLDraw.DrawLine(startPos, gPos, m_ColorModifierAnimatedGradient.Colors[0, 0], m_ColorModifierAnimatedGradient.Colors[1, 0], 2f); } else { GLDraw.DrawLine(startPos, gPos, color, 2f); } } } }
public override void OnGUI(Context context) { Color color = Color.white; switch (m_ColorMode) { case ColorMode.Fixed: color = Color.red; break; case ColorMode.Rainbow: color = m_ColorModifierRainbow.Current; break; } Camera cam = Camera.main; foreach (AgentHumanDT agentHumanDT in context.LivingEnitites) { if (m_ColorMode == ColorMode.Visibility) { color = context.VisibleEntities.Contains(agentHumanDT) ? Color.green : Color.red; } if (m_Is2D) { Vector3 pos = agentHumanDT.transform.position; Vector3 bsPoint = cam.WorldToScreenPoint(pos); pos.y += 1.7f; Vector3 tsPoint = cam.WorldToScreenPoint(pos); if (bsPoint.z > 0f && tsPoint.z > 0f) { Vector3 bgPoint = GUIUtility.ScreenToGUIPoint(bsPoint); bgPoint.y = Screen.height - bgPoint.y; Vector3 tgPoint = GUIUtility.ScreenToGUIPoint(tsPoint); tgPoint.y = Screen.height - tgPoint.y; float width = Mathf.Abs(bgPoint.y - tgPoint.y) / 2f; //height dif / 2 float distFromPivot = width / 2f; Vector2 bleft = new Vector2(bgPoint.x - distFromPivot, bgPoint.y); Vector2 bright = new Vector2(bgPoint.x + distFromPivot, bgPoint.y); Vector2 tleft = new Vector2(tgPoint.x - distFromPivot, tgPoint.y); Vector2 tright = new Vector2(tgPoint.x + distFromPivot, tgPoint.y); if (m_ColorMode == ColorMode.Gradient) { Color[,] c = m_ColorModifierAnimatedGradient.Colors; GLDraw.DrawLine(bleft, bright, c[0, 0], c[0, 1], 2f); GLDraw.DrawLine(bleft, tleft, c[1, 0], c[1, 1], 2f); GLDraw.DrawLine(tleft, tright, c[2, 0], c[2, 1], 2f); GLDraw.DrawLine(tright, bright, c[3, 0], c[3, 1], 2f); continue; } GLDraw.DrawLine(bleft, bright, color, 2f); GLDraw.DrawLine(bleft, tleft, color, 2f); GLDraw.DrawLine(tleft, tright, color, 2f); GLDraw.DrawLine(tright, bright, color, 2f); } } else { // ____ //2d view | | // | . | // |____| Vector3 pos = agentHumanDT.transform.position; Vector3 bfrPos = cam.WorldToScreenPoint(new Vector3(pos.x + 0.8f, pos.y, pos.z + 0.8f)); Vector3 bflPos = cam.WorldToScreenPoint(new Vector3(pos.x - 0.8f, pos.y, pos.z + 0.8f)); Vector3 bbrPos = cam.WorldToScreenPoint(new Vector3(pos.x + 0.8f, pos.y, pos.z - 0.8f)); Vector3 bblPos = cam.WorldToScreenPoint(new Vector3(pos.x - 0.8f, pos.y, pos.z - 0.8f)); pos.y += 1.7f; Vector3 tfrPos = cam.WorldToScreenPoint(new Vector3(pos.x + 0.8f, pos.y, pos.z + 0.8f)); Vector3 tflPos = cam.WorldToScreenPoint(new Vector3(pos.x - 0.8f, pos.y, pos.z + 0.8f)); Vector3 tbrPos = cam.WorldToScreenPoint(new Vector3(pos.x + 0.8f, pos.y, pos.z - 0.8f)); Vector3 tblPos = cam.WorldToScreenPoint(new Vector3(pos.x - 0.8f, pos.y, pos.z - 0.8f)); if (bfrPos.z > 0f && bflPos.z > 0f && bbrPos.z > 0f && bblPos.z > 0f && tfrPos.z > 0f && tflPos.z > 0f && tbrPos.z > 0f && tblPos.z > 0f) { Vector2 _bfrPos = GUIUtility.ScreenToGUIPoint(bfrPos); _bfrPos.y = Screen.height - _bfrPos.y; Vector2 _bflPos = GUIUtility.ScreenToGUIPoint(bflPos); _bflPos.y = Screen.height - _bflPos.y; Vector2 _bbrPos = GUIUtility.ScreenToGUIPoint(bbrPos); _bbrPos.y = Screen.height - _bbrPos.y; Vector2 _bblPos = GUIUtility.ScreenToGUIPoint(bblPos); _bblPos.y = Screen.height - _bblPos.y; Vector2 _tfrPos = GUIUtility.ScreenToGUIPoint(tfrPos); _tfrPos.y = Screen.height - _tfrPos.y; Vector2 _tflPos = GUIUtility.ScreenToGUIPoint(tflPos); _tflPos.y = Screen.height - _tflPos.y; Vector2 _tbrPos = GUIUtility.ScreenToGUIPoint(tbrPos); _tbrPos.y = Screen.height - _tbrPos.y; Vector2 _tblPos = GUIUtility.ScreenToGUIPoint(tblPos); _tblPos.y = Screen.height - _tblPos.y; if (m_ColorMode == ColorMode.Gradient) { Color[,] c = m_ColorModifierAnimatedGradient.Colors; GLDraw.DrawLine(_bfrPos, _bflPos, c[0, 0], c[0, 1], 2f); GLDraw.DrawLine(_bbrPos, _bblPos, c[0, 0], c[0, 1], 2f); GLDraw.DrawLine(_bfrPos, _bbrPos, c[1, 0], c[1, 1], 2f); GLDraw.DrawLine(_bflPos, _bblPos, c[1, 0], c[1, 1], 2f); GLDraw.DrawLine(_tfrPos, _tflPos, c[0, 0], c[0, 1], 2f); GLDraw.DrawLine(_tbrPos, _tblPos, c[0, 0], c[0, 1], 2f); GLDraw.DrawLine(_tfrPos, _tbrPos, c[1, 0], c[1, 1], 2f); GLDraw.DrawLine(_tflPos, _tblPos, c[1, 0], c[1, 1], 2f); GLDraw.DrawLine(_bfrPos, _tfrPos, c[2, 0], c[2, 1], 2f); GLDraw.DrawLine(_bbrPos, _tbrPos, c[2, 0], c[2, 1], 2f); GLDraw.DrawLine(_bflPos, _tflPos, c[3, 0], c[3, 1], 2f); GLDraw.DrawLine(_bblPos, _tblPos, c[3, 0], c[3, 1], 2f); continue; } GLDraw.DrawLine(_bfrPos, _bflPos, color, 2f); GLDraw.DrawLine(_bbrPos, _bblPos, color, 2f); GLDraw.DrawLine(_bfrPos, _bbrPos, color, 2f); GLDraw.DrawLine(_bflPos, _bblPos, color, 2f); GLDraw.DrawLine(_tfrPos, _tflPos, color, 2f); GLDraw.DrawLine(_tbrPos, _tblPos, color, 2f); GLDraw.DrawLine(_tfrPos, _tbrPos, color, 2f); GLDraw.DrawLine(_tflPos, _tblPos, color, 2f); GLDraw.DrawLine(_bfrPos, _tfrPos, color, 2f); GLDraw.DrawLine(_bbrPos, _tbrPos, color, 2f); GLDraw.DrawLine(_bflPos, _tflPos, color, 2f); GLDraw.DrawLine(_bblPos, _tblPos, color, 2f); } } } }
public override void OnGUI(Context context) { Camera cam = Camera.main; Color color = Color.white; switch (m_ColorMode) { case ColorMode.Fixed: color = Color.red; break; case ColorMode.Rainbow: color = m_ColorModifierRainbow.Current; break; } foreach (AgentHumanDT agentHumanDT in context.LivingEnitites) { if (m_ColorMode == ColorMode.Visibility) { color = context.VisibleEntities.Contains(agentHumanDT) ? Color.green : Color.red; } Vector3 pos = agentHumanDT.transform.position; if (!((Boxes)HackManager.Instance.GetHack(1, 0)).Is2D) { pos.z += 0.8f; } Vector3 bsPos = cam.WorldToScreenPoint(pos); pos.y += 1.7f; Vector3 tsPos = cam.WorldToScreenPoint(pos); if (bsPos.z > 0f && tsPos.z > 0f) { Vector2 bgPos = GUIUtility.ScreenToGUIPoint(bsPos); bgPos.y = Screen.height - bgPos.y; Vector2 tgPos = GUIUtility.ScreenToGUIPoint(tsPos); tgPos.y = Screen.height - tgPos.y; float height = Mathf.Abs(bgPos.y - tgPos.y); float width = height / 2f; float distanceFromPivot = width / 2f; if (m_Layout == HealthLayout.Horizontal) { GLDraw.DrawLine(new Vector2(bgPos.x - distanceFromPivot, bgPos.y + distanceFromPivot / 2f), new Vector2(bgPos.x + distanceFromPivot, bgPos.y + distanceFromPivot / 2f), new Color32(32, 32, 32, 255), distanceFromPivot / 4f); if (m_ColorMode == ColorMode.Gradient) { GLDraw.DrawLine(new Vector2(bgPos.x - distanceFromPivot, bgPos.y + distanceFromPivot / 2f), new Vector2(bgPos.x - distanceFromPivot + 2f * distanceFromPivot * (agentHumanDT.BlackBoard.Health / agentHumanDT.BlackBoard.RealMaxHealth), bgPos.y + distanceFromPivot / 2f), m_ColorModifierAnimatedGradient.Colors[0, 0], m_ColorModifierAnimatedGradient.Colors[1, 0], distanceFromPivot / 4f); } else { GLDraw.DrawLine(new Vector2(bgPos.x - distanceFromPivot, bgPos.y + distanceFromPivot / 2f), new Vector2(bgPos.x - distanceFromPivot + 2f * distanceFromPivot * (agentHumanDT.BlackBoard.Health / agentHumanDT.BlackBoard.RealMaxHealth), bgPos.y + distanceFromPivot / 2f), color, distanceFromPivot / 4f); } continue; } GLDraw.DrawLine(new Vector2(bgPos.x - 1.5f * distanceFromPivot, bgPos.y), new Vector2(tgPos.x - 1.5f * distanceFromPivot, tgPos.y), new Color32(32, 32, 32, 255), distanceFromPivot / 4f); if (m_ColorMode == ColorMode.Gradient) { GLDraw.DrawLine(new Vector2(bgPos.x - 1.5f * distanceFromPivot, bgPos.y), new Vector2(tgPos.x - 1.5f * distanceFromPivot, bgPos.y - height * (agentHumanDT.BlackBoard.Health / agentHumanDT.BlackBoard.RealMaxHealth)), m_ColorModifierAnimatedGradient.Colors[0, 0], m_ColorModifierAnimatedGradient.Colors[1, 0], distanceFromPivot / 4f); } else { GLDraw.DrawLine(new Vector2(bgPos.x - 1.5f * distanceFromPivot, bgPos.y), new Vector2(tgPos.x - 1.5f * distanceFromPivot, bgPos.y - height * (agentHumanDT.BlackBoard.Health / agentHumanDT.BlackBoard.RealMaxHealth)), color, distanceFromPivot / 4f); } } } }