|
小图像下载:
效果图:
- @script ExecuteInEditMode()
- public var Enemy_ : Texture; //define enemy texture
- public var Box_:Texture;//define the box texture
- public var Player_:Texture;//define player texture
- public var radarBG : Texture; //small map texture
- public var centerObject : Transform; //chracter position
- 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-55,mapCenter.y-50,128,128),radarBG);
- // 上面的mapCenter.x-32是地圖的x位置,mapCenter.y-32是y位置,64,64是地圖的大小
- DrawBlipsForEnemies();
- DrawBlipsForPlayer();
- DrawBlipsForBox();
- }
- function DrawBlipsForBox(){ //draw box texture in small map
-
- var gos : GameObject[];
- gos = GameObject.FindGameObjectsWithTag("Box");
- var distance = Mathf.Infinity;
- var position = transform.position;
- for (var go : GameObject in gos) {
- drawBlip(go,Box_);
- }
- }
- function DrawBlipsForPlayer(){ //draw player texture in small map
-
- var gos : GameObject[];
- gos = GameObject.FindGameObjectsWithTag("Player");
- var distance = Mathf.Infinity;
- var position = transform.position;
- for (var go : GameObject in gos) {
- drawBlip(go,Player_);
- }
- }
- function DrawBlipsForEnemies(){ //draw enemy texture in small map
-
- var gos : GameObject[];
- gos = GameObject.FindGameObjectsWithTag("Enemy");
- var distance = Mathf.Infinity;
- var position = transform.position;
- for (var go : GameObject in gos) {
- drawBlip(go,Enemy_);
- }
- }
- function drawBlip(go,aTexture){ //draw position in small map
-
- 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,16,16),aTexture);
- }
- }
复制代码 注意: box 为宝箱 enemy为敌人 palyer为玩家
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
评分
-
查看全部评分
|