- 最后登录
- 2018-6-29
- 注册时间
- 2011-7-1
- 阅读权限
- 20
- 积分
- 359
- 纳金币
- 335582
- 精华
- 0
|
public var blip : Texture; //代表角色
public var blip_other : Texture;//敌人
public var radarBG : Texture; //地图背景图片
public var centerObject : Transform; //角色位置
public var mapscale = 0.6; //地图缩放
public var mapCenter = Vector2(50,50); //地图中心
function OnGUI () {
bX=centerObject.position.x * mapScale;
bY=centerObject.position.z * mapScale;
//bX=centerObject.transform.position.x * mapScale;
//bY=centerObject.transform.position.z * mapScale;
GUI.DrawTexture(Rect(mapCenter.x -50,mapCenter.y - 50,100,100),radarBG);
GUI.DrawTexture(Rect(mapCenter.x,mapCenter.y,4,4),blip);
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 + 90 - centerObject.eulerAngles.y;
bX=dist*Mathf.Cos(deltay * Mathf.Deg2Rad);
bY=dist*Mathf.Sin(deltay * Mathf.Deg2Rad);
bX=bX*mapScale*7;
bY=bY*mapScale*7;
if(dist<=20){ //20以内的敌人显示
GUI.DrawTexture(Rect(mapCenter.x+bX,mapCenter.y+bY,4,4),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_other);
}
}
|
|