Advertisement
LittleAngel

Vectrosity Radar Issue

Jul 29th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. [System.Serializable]
  2. public class RadarDotPoints {
  3. // public float dotSize;
  4. public Color dotColor;
  5. public VectorPoints radarDots;
  6. // [HideInInspector]
  7. public Vector2[] dotPoints;
  8. }
  9.  
  10. public class UIController : MonoBehaviour {
  11. public RadarDotPoints stationDot;
  12. public RadarDotPoints targetDot;
  13. public RadarDotPoints obstacleDots;
  14. public RadarDotPoints enemyDots;
  15. public int numberOfRadarDots;
  16.  
  17. void Awake () {
  18. stationDot.dotPoints = new Vector2[1];
  19. targetDot.dotPoints = new Vector2[1];
  20. obstacleDots.dotPoints = new Vector2[numberOfRadarDots];
  21. enemyDots.dotPoints = new Vector2[numberOfRadarDots];
  22. }
  23.  
  24. void Start () {
  25. stationDot.radarDots = new VectorPoints ("stationDot", stationDot.dotPoints, stationDot.dotColor, null, radarDotSize * 2);
  26. targetDot.radarDots = new VectorPoints ("targetDot", targetDot.dotPoints, targetDot.dotColor, null, radarDotSize * 2);
  27. obstacleDots.radarDots = new VectorPoints ("obstacleDots", obstacleDots.dotPoints, obstacleDots.dotColor, null, radarDotSize);
  28. enemyDots.radarDots = new VectorPoints ("enemyDots", enemyDots.dotPoints, enemyDots.dotColor, null, radarDotSize);
  29. StartCoroutine (RadarScan ());
  30. }
  31.  
  32. IEnumerator RadarScan () {
  33. while (scanning) {
  34. // Draw Station Dot
  35. stationDot.dotPoints[0] = SetRadarPosition (stationTransform);
  36. Vector.DrawPoints(stationDot.radarDots);
  37.  
  38. // Draw Current Target Dot
  39. if (currentTarget) {
  40. targetDot.dotPoints[0] = SetRadarPosition (currentTarget);
  41. } else {
  42. targetDot.dotPoints[0] = new Vector2 (-100, -100);
  43. }
  44. Vector.DrawPoints(targetDot.radarDots);
  45.  
  46. // Draw Obstacle Dots
  47. for (int i = 0; i < obstacleDots.dotPoints.Length; i++) {
  48. obstacleDots.dotPoints[i] = new Vector2 (-100, -100);
  49. }
  50. for (int j = 0; j < obstacleObjects.Count; j++) {
  51. obstacleDots.dotPoints[j] = SetRadarPosition (obstacleObjects[j]);
  52. }
  53. Vector.DrawPoints(obstacleDots.radarDots);
  54.  
  55. // Draw Enemy Dots
  56. for (int k = 0; k < enemyDots.dotPoints.Length; k++) {
  57. enemyDots.dotPoints[k] = new Vector2 (-100, -100);
  58. }
  59. for (int l = 0; l < enemyObjects.Count; l++) {
  60. enemyDots.dotPoints[l] = SetRadarPosition (enemyObjects[l]);
  61. }
  62. Vector.DrawPoints(enemyDots.radarDots);
  63.  
  64. // Scan every frame - change this for performance reasons
  65. yield return null;
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement