Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [System.Serializable]
- public class RadarDotPoints {
- // public float dotSize;
- public Color dotColor;
- public VectorPoints radarDots;
- // [HideInInspector]
- public Vector2[] dotPoints;
- }
- public class UIController : MonoBehaviour {
- public RadarDotPoints stationDot;
- public RadarDotPoints targetDot;
- public RadarDotPoints obstacleDots;
- public RadarDotPoints enemyDots;
- public int numberOfRadarDots;
- void Awake () {
- stationDot.dotPoints = new Vector2[1];
- targetDot.dotPoints = new Vector2[1];
- obstacleDots.dotPoints = new Vector2[numberOfRadarDots];
- enemyDots.dotPoints = new Vector2[numberOfRadarDots];
- }
- void Start () {
- stationDot.radarDots = new VectorPoints ("stationDot", stationDot.dotPoints, stationDot.dotColor, null, radarDotSize * 2);
- targetDot.radarDots = new VectorPoints ("targetDot", targetDot.dotPoints, targetDot.dotColor, null, radarDotSize * 2);
- obstacleDots.radarDots = new VectorPoints ("obstacleDots", obstacleDots.dotPoints, obstacleDots.dotColor, null, radarDotSize);
- enemyDots.radarDots = new VectorPoints ("enemyDots", enemyDots.dotPoints, enemyDots.dotColor, null, radarDotSize);
- StartCoroutine (RadarScan ());
- }
- IEnumerator RadarScan () {
- while (scanning) {
- // Draw Station Dot
- stationDot.dotPoints[0] = SetRadarPosition (stationTransform);
- Vector.DrawPoints(stationDot.radarDots);
- // Draw Current Target Dot
- if (currentTarget) {
- targetDot.dotPoints[0] = SetRadarPosition (currentTarget);
- } else {
- targetDot.dotPoints[0] = new Vector2 (-100, -100);
- }
- Vector.DrawPoints(targetDot.radarDots);
- // Draw Obstacle Dots
- for (int i = 0; i < obstacleDots.dotPoints.Length; i++) {
- obstacleDots.dotPoints[i] = new Vector2 (-100, -100);
- }
- for (int j = 0; j < obstacleObjects.Count; j++) {
- obstacleDots.dotPoints[j] = SetRadarPosition (obstacleObjects[j]);
- }
- Vector.DrawPoints(obstacleDots.radarDots);
- // Draw Enemy Dots
- for (int k = 0; k < enemyDots.dotPoints.Length; k++) {
- enemyDots.dotPoints[k] = new Vector2 (-100, -100);
- }
- for (int l = 0; l < enemyObjects.Count; l++) {
- enemyDots.dotPoints[l] = SetRadarPosition (enemyObjects[l]);
- }
- Vector.DrawPoints(enemyDots.radarDots);
- // Scan every frame - change this for performance reasons
- yield return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement