小地图
来源:互联网 发布:数据魔方的作用 编辑:程序博客网 时间:2024/05/02 03:21
- @script ExecuteInEditMode()
- public var blip : Texture;
- public var radarBG : Texture;
- public var centerObject : Transform;
- public var mapScale = 0.3;
- public var mapCenter = Vector2(50,50);
- function OnGUI () {
-
- bX=centerObject.transform.position.x * mapScale;
- bY=centerObject.transform.position.z * mapScale;
-
- bX=centerObject.transform.position.x * mapScale;
- bY=centerObject.transform.position.z * mapScale;
-
- GUI.DrawTexture(Rect(mapCenter.x-32,mapCenter.y-32,64,64),radarBG);
-
- DrawBlipsForEnemies();
- }
- function DrawBlipsForCows(){
-
- var gos : GameObject[];
- gos = GameObject.FindGameObjectsWithTag("Cow");
- var distance = Mathf.Infinity;
- var position = transform.position;
- for (var go : GameObject in gos) {
- drawBlip(go,blip);
- }
- }
- function drawBlip(go,aTexture){
-
- centerPos=centerObject.position;
- extPos=go.transform.position;
-
- dist=Vector3.Distance(centerPos,extPos);
-
- dx=centerPos.x-extPos.x;
- dz=centerPos.z-extPos.z;
-
- deltay=Mathf.Atan2(dx,dz)*Mathf.Rad2Deg - 270 - centerObject.eulerAngles.y;
-
- bX=dist*Mathf.Cos(deltay * Mathf.Deg2Rad);
- bY=dist*Mathf.Sin(deltay * Mathf.Deg2Rad);
-
- bX=bX*mapScale;
- bY=bY*mapScale;
-
- if(dist<=200){
- GUI.DrawTexture(Rect(mapCenter.x+bX,mapCenter.y+bY,2,2),aTexture);
- }
- }
- function DrawBlipsForEnemies(){
-
- var gos : GameObject[];
- gos = GameObject.FindGameObjectsWithTag("Enemy");
- var distance = Mathf.Infinity;
- var position = transform.position;
- for (var go : GameObject in gos) {
- drawBlip(go,blip);
- }
- }