using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
public class node{
public int x;
public int y;
public int z;
}
public node Qnode(node nodepoint)
{
public node aa;
aa.x=Math.Floor(nodepoint.x/W)*W+W/2;
aa.y=Math.Floor(nodepoint.y/W)*W+W/2;
aa.z=Math.Floor(nodepoint.z/W)*W+W/2;
return aa;
}
//beginpoint
//targetpoint
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 100)) {
Debug.DrawLine (ray.origin, hit.point);
}
node beginpoint; //开始坐标
beginpoint.x=transform.position.x;
beginpoint.y=transform.position.y;
beginpoint.y=transform.position.z;
beginnode=qnode(beginpoint); //开始节点
node targetpoint; //目标坐标
targetpoint.x=hit.point[0];
targetpoint.y=hit.point[1];
targetpoint.z=hit.point[2];
targetnode=targetpoint; //结束节点
public int H()
{
int h,xh,yh,zh;
xh=(Math.Abs(targetnode.x-beginnode.x))/W*10;
yh=(Math.Abs(targetnode.y-beginnode.y))/W*10;
zh=(Math.Abs(targetnode.z-beginnode.z))/W*10;
h=xh+yh+zh;
return h;
}
public static int[] costs = new int[9] {14,10,14,10,10,14,10,14,20};
public int[] openlist;