|
|
|
@ -1,6 +1,7 @@ |
|
|
|
using System; |
|
|
|
using System.Collections; |
|
|
|
using System.Collections.Generic; |
|
|
|
using Unity.VisualScripting; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine.UI; |
|
|
|
using UnityEngine.UIElements; |
|
|
|
@ -96,39 +97,38 @@ public class getNodeTools |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public static void checkListPass(List<MapUnity> mapUnityList) |
|
|
|
public static void checkListPass(List<MapUnity> mapUnityList, MapUnity mapUnity) |
|
|
|
{ |
|
|
|
|
|
|
|
for (int i = 0; i < mapUnityList.Count; i++) |
|
|
|
for (int i = mapUnityList.Count - 1; i >= 0; i--) |
|
|
|
{ |
|
|
|
if (!checkNodePass(mapUnityList[i])) |
|
|
|
if (!checkNodePass(mapUnityList[i], mapUnity)) |
|
|
|
{ |
|
|
|
mapUnityList.RemoveAt(i); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public static bool checkNodePass(MapUnity mapUnity) |
|
|
|
public static bool checkNodePass(MapUnity mapUnity, MapUnity centerMapUnity) |
|
|
|
{ |
|
|
|
LayerMask layerMask=new LayerMask(); |
|
|
|
int blockLayer = LayerMask.NameToLayer("Block"); |
|
|
|
layerMask |= (1 << blockLayer); |
|
|
|
bool canPass=true; |
|
|
|
//MapUnity playerOnNode = GameManager.Instance.playerOn.transform.GetComponent<MapUnity>();
|
|
|
|
var playerOnNode=GameManager.Instance.player; |
|
|
|
float distance = Vector3.Distance(playerOnNode.transform.position, mapUnity.transform.position); |
|
|
|
Vector3 dir = mapUnity.transform.position - playerOnNode.transform.position; |
|
|
|
Ray ray = new Ray(playerOnNode.transform.position, dir); |
|
|
|
//var playerOnNode=GameManager.Instance.player;
|
|
|
|
float distance = Vector3.Distance(centerMapUnity.transform.position, mapUnity.transform.position); |
|
|
|
Vector3 dir = mapUnity.transform.position - centerMapUnity.transform.position; |
|
|
|
Ray ray = new Ray(centerMapUnity.transform.position, dir); |
|
|
|
if (Physics.Raycast(ray, out RaycastHit raycastHit, distance, layerMask.value)) |
|
|
|
{ |
|
|
|
canPass = false; |
|
|
|
} |
|
|
|
/* if (!canPass) |
|
|
|
{*/ |
|
|
|
Debug.Log("¾àÀëÊÇ" + distance + ",½á¹ûÊÇ:" + canPass+",½Ç¶ÈÊÇ:"+dir); |
|
|
|
//}
|
|
|
|
if (mapUnity.locationX==1&& mapUnity.locationY==5) |
|
|
|
{ |
|
|
|
Debug.Log("距离是" + distance + ",结果是:" + canPass + ",角度是:" + dir + " " + layerMask.value + "ray是" + ray + "X是:" + mapUnity.locationX + "Y是:" + mapUnity.locationY); |
|
|
|
} |
|
|
|
return canPass; |
|
|
|
|
|
|
|
} |
|
|
|
|