void Start() { if (MB == null) { MB = transform.gameObject.GetComponent <MeshBoard>(); } }
// Update is called once per frame void Update() { Collider[] cList = Physics.OverlapBox(boy.position, boy.GetComponent <BoxCollider>().bounds.extents, Quaternion.identity, LayerMask.GetMask(LayerName.NavMesh)); //判断是否在navmesh中 if (cList != null && cList.Length != 0) { inNavmesh = true; mb = cList[0].transform.parent.GetComponentInChildren <MeshBoard>(); } else { inNavmesh = false; mb = null; } if (inNavmesh) { //寻路 a = boy.transform.position + Vector3.up * 0.5f; b = cat.transform.position + Vector3.up * 0.3f; mb.Init(); pathList = mb.FindPath(a, b); //计算方向:上下左右 direction = pathList[1] - pathList[0]; } }
public void Init( MeshBoard meshboard, int index ) { meshBoard = meshboard; Index = index; CONTENTCODE = TileContent.Empty; SetColor( Color.white ); }
public void Init(MeshBoard meshboard, int index) { meshBoard = meshboard; Index = index; CONTENTCODE = TileContent.Empty; SetColor(Color.white); }
private Tile GenerateTile(int _x, int _y) { Transform e = MeshBoard.Instantiate(meshBoard.MESH) as Transform; e.position = new Vector3(_x - (MeshBoard.WIDTH / 2), -.8f, _y - (MeshBoard.HEIGHT / 2)); Tile tile = e.GetComponent <Tile>(); tile.Init(meshBoard, _y + _x * MeshBoard.HEIGHT); return(tile); }
// Vector3 nPos) public void Init() { meshboard = Camera.main.GetComponent<MeshBoard>(); location = transform; location.position = to3D( new Point( 0,7 ) ); wayPoint = to3D( meshboard.GetNextPoint( to2D() ) ); location.LookAt( wayPoint ); location.gameObject.active = true; location.GetChild(0).gameObject.active = true; move = true; }
public void Init() // Vector3 nPos) { meshboard = Camera.main.GetComponent <MeshBoard>(); location = transform; location.position = to3D(new Point(0, 7)); wayPoint = to3D(meshboard.GetNextPoint(to2D())); location.LookAt(wayPoint); location.gameObject.active = true; location.GetChild(0).gameObject.active = true; move = true; }
public GridManager( MeshBoard meshboard, int typ ) { meshBoard = meshboard; InitMovements( typ ); }
public GridManager(MeshBoard meshboard, int typ) { meshBoard = meshboard; InitMovements(typ); }
void Start() { if( MB == null ) MB = transform.gameObject.GetComponent<MeshBoard>(); }
void OnEnable() { mb = (MeshBoard)target; }
public NavPathCalculator(MeshBoard mb) { this.mb = mb; }