Ejemplo n.º 1
1
    float CalculatePathLength(Vector3 targetPosition)
    {
        // Create a path and set it based on a target position.
        NavMeshPath path = new NavMeshPath();
        if (nav.enabled)
            nav.CalculatePath(targetPosition, path);

        // Create an array of points which is the length of the number of corners in the path + 2.
        Vector3[] allWayPoints = new Vector3[path.corners.Length + 2];

        // The first point is the enemy's position.
        allWayPoints[0] = transform.position;

        // The last point is the target position.
        allWayPoints[allWayPoints.Length - 1] = targetPosition;

        // The points inbetween are the corners of the path.
        for (int i = 0; i < path.corners.Length; i++)
        {
            allWayPoints[i + 1] = path.corners[i];
        }

        // Create a float to store the path length that is by default 0.
        float pathLength = 0;

        // Increment the path length by an amount equal to the distance between each waypoint and the next.
        for (int i = 0; i < allWayPoints.Length - 1; i++)
        {
            pathLength += Vector3.Distance(allWayPoints[i], allWayPoints[i + 1]);
        }
        return pathLength;
    }
        void DoCalculatePath()
        {
            _getNavMeshPathProxy();
            if (_NavMeshPathProxy ==null)
            {
                return;
            }

            NavMeshPath _path = new NavMeshPath();

            bool _found = NavMesh.CalculatePath(sourcePosition.Value,targetPosition.Value,passableMask.Value,_path);

            _NavMeshPathProxy.path = _path;

            resultingPathFound.Value = _found;

            if (_found)
            {
                if ( ! FsmEvent.IsNullOrEmpty(resultingPathFoundEvent) ){
                    Fsm.Event(resultingPathFoundEvent);
                }
            }else
            {
                if (! FsmEvent.IsNullOrEmpty(resultingPathNotFoundEvent) ){
                    Fsm.Event(resultingPathNotFoundEvent);
                }
            }
        }
Ejemplo n.º 3
0
    public override void OnEnter(ref AiParam _param)
    {
        if (_param == null || _param.NavAgent == null)
            return;

        _param.OnAiActionChanged (UnityChan_Ctrl.ActionState.Walk);

        //_param.NavAgent.Resume ();
        Movement (ref _param);

        int searchMax = 30;

        for (var i = 0; i < searchMax; i++)
        {
            Vector3 randomPoint = _param.Owner.transform.position + Random.insideUnitSphere * 3F;
            NavMeshHit hit;
            if (NavMesh.SamplePosition (randomPoint, out hit, 1F, 0xFF)) {

                NavMeshPath path = new NavMeshPath();
                if(_param.NavAgent.CalculatePath(hit.position, path) == true)
                {
                    _param.NavAgent.SetPath(path);
                    return;
                }
            }
        }
    }
Ejemplo n.º 4
0
    float CalculatePathLength(Vector3 targetPosition)
    {
        //To calculate how far the sound can travel - identifies player behind corners
        NavMeshPath path = new NavMeshPath();

        if (nav.enabled)
            nav.CalculatePath(targetPosition, path);

        Vector3[] allWayPoints = new Vector3[path.corners.Length + 2]; //+2 to allow for the enemy and player positions

        allWayPoints[0] = transform.position;
        allWayPoints[allWayPoints.Length - 1] = targetPosition;

        for (int i = 0; i < path.corners.Length; i++)
        {
            allWayPoints[i + 1] = path.corners[i];
        }

        float pathLength = 0f;

        for (int i = 0; i < allWayPoints.Length-1; i++)
        {
            pathLength += Vector3.Distance(allWayPoints[i], allWayPoints[i + 1]);
        }

        return pathLength;
    }
Ejemplo n.º 5
0
		void DrawPath(NavMeshPath path) {
			if (path.corners.Length < 2)
				return;
			switch (path.status) {
			case NavMeshPathStatus.PathComplete:
					c = Color.white;
					break;
			case NavMeshPathStatus.PathInvalid:
					c = Color.red;
					break;
			case NavMeshPathStatus.PathPartial:
					c = Color.yellow;
					break;
			}
					
			Vector3 previousCorner = path.corners[0];
			
			int i = 1;
			while (i < path.corners.Length) {
				Vector3 currentCorner = path.corners[i];
				Debug.DrawLine(previousCorner, currentCorner, c);
				previousCorner = currentCorner;
				i++;
			}
	
	
	
		}
Ejemplo n.º 6
0
    float CalculatePathLength(Vector3 targetPos)
    {
        NavMeshPath path = new NavMeshPath ();

        if(nav.enabled)
        {
            nav.CalculatePath(targetPos, path);
        }

        Vector3 [] waypointsToTarget = new Vector3[path.corners.Length + 2]; //2 for orgin + target.

        waypointsToTarget [0] = transform.position;
        waypointsToTarget [waypointsToTarget.Length - 1] = targetPos;

        for(int i= 0; i<path.corners.Length; i++)
        {
            waypointsToTarget[i+1] = path.corners[i];
        }

        float pathLength = 0;

        for(int i = 0; i < waypointsToTarget.Length -1; i++)
        {
            pathLength += Vector3.Distance(waypointsToTarget[i],waypointsToTarget[i+1]);
        }

        return pathLength;
    }
Ejemplo n.º 7
0
 void Start()
 {
     anim = GetComponent<Animator>();
     anim.SetBool("isWalking", true);
     NavMeshPath path = new NavMeshPath();
     agent.destination = target.position;
 }
        public InteractWithNearestState(NavMeshAgent agent, string tag, GameObject pickup)
        {
            _agent = agent;

            cam = _agent.gameObject.GetComponent<CharacterAnimMovement>();

            _interactGameObject = pickup;

            var interactables = GameObject.FindGameObjectsWithTag(tag);
            if (interactables.Length < 1)
            {
                GameObject.FindGameObjectWithTag("AudioManager").GetComponent<AudioManager>().FemaleNoSoundPlay();
                _state = State.Done;
                return;
            }

            foreach (var i in interactables)
            {
                _interactGameObject = i;
                var dest = i.GetComponent<IInteractable>();
                if(!dest.CanThisBeInteractedWith(pickup)) continue;
                var path = new NavMeshPath();
                agent.CalculatePath(dest.InteractPosition(_agent.transform.position), path);

                if (path.status != NavMeshPathStatus.PathComplete) continue;

                _intaractableGoal = dest;
                break;
            }

            if(_intaractableGoal == null)
                _state = State.Done;
        }
    static void NavMeshPath_status(JSVCall vc)
    {
        UnityEngine.NavMeshPath _this = (UnityEngine.NavMeshPath)vc.csObj;
        var result = _this.status;

        JSApi.setEnum((int)JSApi.SetType.Rval, (int)result);
    }
Ejemplo n.º 10
0
    // Unity's example function..
    public float CalculatePathLength(NavMeshAgent nav, Vector3 targetPosition)
    {
        // Added condition since it was returning impossible values if given same position :P
        if (nav.transform.position == targetPosition)
            return 0;

        // Create a path and set it based on a target position.
        var path = new NavMeshPath();
        if (nav.enabled)
            nav.CalculatePath(targetPosition, path);

        // Create an array of points which is the length of the number of corners in the path + 2.
        var allWayPoints = new Vector3[path.corners.Length + 2];

        // The first point is the player position.
        allWayPoints[0] = player.transform.position;

        // The last point is the enemy position
        allWayPoints[allWayPoints.Length - 1] = targetPosition;

        // The points inbetween are the corners of the path.
        for (var i = 0; i < path.corners.Length; i++)
            allWayPoints[i + 1] = path.corners[i];

        // Create a float to store the path length that is by default 0.
        float pathLength = 0;

        // Increment the path length by an amount equal to the distance between each waypoint and the next.
        for (int i = 0; i < allWayPoints.Length - 1; i++)
        {
            pathLength += Vector3.Distance(allWayPoints[i], allWayPoints[i + 1]);
        }

        return pathLength;
    }
Ejemplo n.º 11
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hitinfo;

           // LayerMask mask = 1 << LayerMask.NameToLayer("GroundLayer");

            bool isCollider = Physics.Raycast(ray, out hitinfo);
           
            if (isCollider && hitinfo.collider.tag == Tags.player)
            {
                cur_Role = hitinfo.collider.transform.parent.GetComponent<DBaseFightRole>();               
            }
            if (isCollider && hitinfo.collider.tag == Tags.ground && cur_Role != null)
            {
                NavMeshPath path = new NavMeshPath();
                cur_Role.agent.enabled = true;
                cur_Role.agent.CalculatePath(hitinfo.point, path);
                if (path.corners.Length >= 2)
                {
                    cur_Role.gotoDestination(hitinfo.point);
                   
                }
                cur_Role = null;
            }
        }
    }
Ejemplo n.º 12
0
//draw lines using navmesh
void DrawLinesWithNavigation()
{

if(useOwnNavSystem == false)
{
int testId2 = 0;
int testIdPlus2 = 1;


List<Vector3> waypointVector3 = new List<Vector3>();


while(testId2 < waypointList.Length)
{

if(testIdPlus2 >= waypointList.Length)
{
testIdPlus2 = 0;
}
		
NavMeshPath pathMain = new NavMeshPath();

NavMesh.CalculatePath(waypointList[testId2].transform.position, waypointList[testIdPlus2].transform.position, -1, pathMain);


int testId3 = 0;

while(testId3 < pathMain.corners.Length)
{
waypointVector3.Add(pathMain.corners[testId3]);
testId3 += 1;
}

testId2 += 1;
testIdPlus2 += 1;
}


//draw the lines

int testId = 0;
int testIdPlus = 1;

while(testId < waypointVector3.Count)
{

if(testIdPlus >= waypointVector3.Count)
{
testIdPlus = 0;
}

Gizmos.color = Color.magenta;
Gizmos.DrawLine(waypointVector3[testId], waypointVector3[testIdPlus]);

testId += 1;
testIdPlus += 1;
}
}

}
 // Use this for initialization
 void Start()
 {
     destination = transform.position;
     path = new NavMeshPath();
     CalcPath();
     rigidBody = GetComponent<Rigidbody>();
 }
Ejemplo n.º 14
0
 static public int constructor(IntPtr l)
 {
     UnityEngine.NavMeshPath o;
     o = new UnityEngine.NavMeshPath();
     pushObject(l, o);
     return(1);
 }
Ejemplo n.º 15
0
    // this is used for finding how long a sound has to travel
    float CalculatePathLength(Vector3 targetPosition)
    {
        NavMeshPath path = new NavMeshPath();
        if (nav.enabled)
            nav.CalculatePath(targetPosition, path);

        Vector3[] allWayPoints = new Vector3[path.corners.Length + 2];

        //first point in array should be the enemy's posiotn

        allWayPoints[0] = transform.position;
        allWayPoints[allWayPoints.Length - 1] = targetPosition;

        for (int i = 0; i < path.corners.Length; i ++) {
            allWayPoints[i + 1] = path.corners[i];

        }

        float pathLength = 0;

        for (int i = 0; i < allWayPoints.Length - 1; i++) {
            pathLength += Vector3.Distance(allWayPoints[i], allWayPoints[i + 1]);

        }
        return pathLength;
    }
Ejemplo n.º 16
0
        //returns the nearest portal of a container, based on the position
        static Vector3? FindNearest(Transform parent, Vector3 pos)
        {
            //initialize variables
            NavMeshPath path = new NavMeshPath();
            Vector3? nearest = null;
            float distance = Mathf.Infinity;

            //don't continue if the parent does not exist
            if (!portals.ContainsKey(parent)) return null;

            //loop over portals of this portal container,
            //find the shortest NavMesh path to a portal
            for (int i = 0; i < portals[parent].Count; i++)
            {
                Vector3 portal = portals[parent][i].position;
                float length = Mathf.Infinity;
                //let Unity calculate the path and set length, if valid
                if (NavMesh.CalculatePath(pos, portal, -1, path)
                    && path.status == NavMeshPathStatus.PathComplete)
                    length = PathLength(path);

                if (length < distance)
                {
                    distance = length;
                    nearest = portal;
                }
            }

            return nearest;
        }
Ejemplo n.º 17
0
 public virtual void Awake()
 {
     nav = GetComponent<NavMeshAgent> ();
     vision = GetComponent<Vision> ();
     player = GameObject.FindGameObjectWithTag ("Player").transform;
     path = new NavMeshPath ();
 }
Ejemplo n.º 18
0
    void Update()
    {
        /*if (oldpos != transform.position) {
            oldpos = newpos;
            newpos = transform.position;
        } else {
            anim.SetBool("isWalking", false);
        }*/

        if (Input.touchCount == 1)
        {
            Vector3 moveTo = GetPositionTouch();

            //player.SetDestination(moveTo);
            //anim.SetBool("isWalking", true);

            NavMeshPath path = new NavMeshPath();
            GetComponent<NavMeshAgent>().CalculatePath(moveTo, path);

            //Debug.Log(path.status);

            if (path.status == NavMeshPathStatus.PathComplete)
            {
                TouchIndicator(moveTo);
                player.SetDestination(moveTo);
                anim.SetBool("isWalking", true);
            }
        }

        //Debug.Log (player.remainingDistance);

        if (player.remainingDistance == 0) {
            anim.SetBool("isWalking", false);
        }
    }
Ejemplo n.º 19
0
    private float CalculatePathLength(Vector3 targetPosition)
    {
        NavMeshPath path = new NavMeshPath();

        if (nav.enabled)
        {
            nav.CalculatePath(targetPosition, path);
        }

        Vector3[] allWayPoints = new Vector3[path.corners.Length + 2];
        allWayPoints[0] = transform.position;
        allWayPoints[allWayPoints.Length - 1] = targetPosition;

        for (int i = 0; i < path.corners.Length; i++)
        {
            allWayPoints[i + 1] = path.corners[i];
        }

        float pathLength = 0f;

        for (int i = 0; i < allWayPoints.Length - 1; i++)
        {
            pathLength += Vector3.Distance(allWayPoints[i], allWayPoints[i + 1]);
        }

        return pathLength;
    }
Ejemplo n.º 20
0
    public void findNextDestination()
    {
        NavMeshPath path = new NavMeshPath();
        int indexTargetChosen = -1;
        bool found = false;
        int count = 0;
        if (getNumberOfTargetsOff() > 0)
        {
            while (!found && count < 99)
            {
                indexTargetChosen = Random.Range(0, targets.Length);
                if (!targets[indexTargetChosen].isOn)
                {
                    m_Agent.CalculatePath(targets[indexTargetChosen].transform.position, path);
                    if (path.status == NavMeshPathStatus.PathComplete)
                    {
                        found = true;
                    }
                }
                count++;
            }
        }

        if (found)
        {
            Vector3 destination = targets[indexTargetChosen].transform.position;
            m_Agent.destination = new Vector3(destination.x, transform.position.y, destination.z);
        }
    }
 private void CalculatePath(Vector3 apos, Vector3 bpos, NavMeshPath path)
 {
     NavMesh.CalculatePath(apos, bpos, 1, path);
     //NavMeshHit h;
     //NavMeshHit h2;
     //if (NavMesh.SamplePosition(apos, out h, 50, 1) && NavMesh.SamplePosition(bpos, out h2, 50, 1))
     //    NavMesh.CalculatePath(h.position, h2.position, 1, path);
 }
Ejemplo n.º 22
0
 // Use this for initialization
 void Start()
 {
     navAgent = transform.GetComponent<NavMeshAgent>();
     characterController = transform.GetComponent<CharacterController>();
     characterController.center = new Vector3(0, 1, 0);
     path = new NavMeshPath();
     GetComponent<Animator>().applyRootMotion = false;
 }
Ejemplo n.º 23
0
Archivo: AgentX.cs Proyecto: s76/testAI
    void Awake()
    {
        arounds = new Collider[0];

        agent = GetComponent<NavMeshAgent> ();
        path  = new NavMeshPath();
        core = GetComponent<UnitCore> ();
    }
Ejemplo n.º 24
0
 // Use this for initialization
 void Start()
 {
     pathj1 = new NavMeshPath ();
     pathj2 = new NavMeshPath ();
     picks = new GameObject[]{p1, p2, p3, p4, p5};
     distancesJ1 = new string[5];
     distancesJ2 = new string[5];
 }
    // Use this for initialization
    void Start()
    {
        meshAnim = GetComponentInChildren<Animator>();
        agent = GetComponent<NavMeshAgent>();
        path = new NavMeshPath();
        agent.SetPath(path);

    }
Ejemplo n.º 26
0
 // Use this for initialization
 public void SetPath(NavMeshPath newPath, GameObject g)
 {
     path = newPath;
     playerObject = g;
     //transform.forward = g.transform.forward;
     //transform.eulerAngles = g.transform.eulerAngles;
     pathSet = true;
 }
Ejemplo n.º 27
0
 void Start()
 {
     m_CalculatedPath = new NavMeshPath();
     //enable finding for path/leader formation positions
     StartCoroutine(CheckObjFound());
     //enable making a path if the above coroutine finds an object to goto
     StartCoroutine(NavGetPath());
 }
Ejemplo n.º 28
0
 protected virtual void Awake()
 {
     if (this.navMeshAgent == null)
     {
         Debug.LogError("NO NAVMESHAGENT assigned to " + this);
     }
     this.currentPath = null;
 }
    private void UpdateBot()
    {
        NavMeshPath path = new NavMeshPath();

        //NavMesh.Raycast(_Player.pos + Vector3.up * 50, Vector3.down * 1000, out h, 0);
        if (KeyDebug(KeyCode.Q) || (_Game.dif >= Dif.Normal || isDebug) && (distToPl > 200) && Time.time - botSpawnTime > (isDebug ? .1f : _Game.hard ? 1 : 5))
        {

            botSpawnTime = Time.time;
            Spawn sp = _Game.spawns.Where(a => a != botSpawnUsed && (a.pos - _Player.pos).magnitude < 200 && inFrontInvisible(a.pos)).OrderBy(a => (a.pos - pos).magnitude).FirstOrDefault();
            if (sp != null)
            {
                botSpawnUsed = sp;
                pos = sp.pos;
                //transform.up = Vector3.up;

                CalculatePath(pos, _Player.pos, path);
                if (path.corners.Length > 1)
                    transform.forward = path.corners[1] - path.corners[0];
                rigidbody.angularVelocity = rigidbody.velocity = Vector3.zero;
                StartCoroutine(AddMethod(new WaitForFixedUpdate(), delegate { rigidbody.velocity = transform.forward * 13; }));
            }
        }
        CalculatePath(pos, _Player.pos, path);
        var c = path.corners;
        for (int i = 0; i < c.Length - 1; i += 2)
            Debug.DrawLine(c[i], c[i + 1], Color.red);
        bool havePath = path.corners.Length > 1;
        if (averVel < 1 && Time.time - goBackTime > 5)
            goBackTime = Time.time;

        averVel = Mathf.Lerp(averVel, rigidbody.velocity.magnitude, rigidbody.velocity.magnitude > averVel ? 1 : Time.deltaTime * 1);

        var goback = Time.time - goBackTime < 2;
        if (havePath)
        {
            Vector3 nextPosition = path.corners[1];
            Vector3 dir = (nextPosition - pos);
            int next = new System.Random(viewId).Next(5, 15);
            if (path.corners.Length == 2 && distToPl < next)
                dir = ((_Player.pos + _Player.rigidbody.velocity) - pos);
            dir = ZeroY(dir).normalized;

            Debug.DrawRay(pos, dir, Color.blue);
            float dot = Vector3.Dot(dir, transform.right);
            bool behind = Vector3.Dot(dir, transform.forward) < 0;
            var f = Mathf.Abs(dot) < 0.1f && !behind;
            var rotLeft = dot < 0;
            if (goback)
                rotLeft = !rotLeft;
            SetKey((int)KeyCode.A, rotLeft && !f);
            SetKey((int)KeyCode.D, !rotLeft && !f);
            nitroDown = f && _Game.dif == Dif.Hard;
            SetKey((int)KeyCode.Space, behind && velm > 10);
        }
        SetKey((int)KeyCode.S, havePath && goback);
        SetKey((int)KeyCode.W, havePath && !goback);
    }
Ejemplo n.º 30
0
		public static float GetPathLength (NavMeshPath path, Vector3 you)
		{
			float length = 0;
			for (int i = -1; i < path.corners.Length-1; i++) {
				length += Vector3.Distance (((i == -1) ? you : path.corners [i]), path.corners [i + 1]);
			}
			length = (length == 0) ? Mathf.Infinity : length;
			return length;
		}
Ejemplo n.º 31
0
 void Start()
 {
     agent = GetComponent<NavMeshAgent>();
     NavMeshPath path = new NavMeshPath();
     agent.CalculatePath(target.position, path);
     if (path.status == NavMeshPathStatus.PathPartial)
     {
     }
 }
Ejemplo n.º 32
0
    // Use this for initialization
    void Start()
    {
        if (player == null)
            player = GameObject.Find("unitychan");
        spiderDie = false;

        agent = transform.GetComponent<NavMeshAgent>();
        path = new NavMeshPath();
    }
        public void DeserializeBeforeRef(UABUnpacker unpacker, UABField field, ref object value, List <ISerializer> serializers)
        {
            var data = new Data();

            unpacker.Deserialize(data, field.fields, serializers);
                        #if UNITY_5_5_OR_NEWER
            value = new UnityEngine.AI.NavMeshPath();
                        #else
            value = new UnityEngine.NavMeshPath();
                        #endif
        }
Ejemplo n.º 34
0
 static public int get_corners(IntPtr l)
 {
     try {
         UnityEngine.NavMeshPath self = (UnityEngine.NavMeshPath)checkSelf(l);
         pushValue(l, self.corners);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Ejemplo n.º 35
0
 static public int get_status(IntPtr l)
 {
     try {
         UnityEngine.NavMeshPath self = (UnityEngine.NavMeshPath)checkSelf(l);
         pushEnum(l, (int)self.status);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int ClearCorners(IntPtr l)
 {
     try {
         UnityEngine.NavMeshPath self = (UnityEngine.NavMeshPath)checkSelf(l);
         self.ClearCorners();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 37
0
 static public int ClearCorners(IntPtr l)
 {
     try {
         UnityEngine.NavMeshPath self = (UnityEngine.NavMeshPath)checkSelf(l);
         self.ClearCorners();
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int get_status(IntPtr l)
 {
     try {
         UnityEngine.NavMeshPath self = (UnityEngine.NavMeshPath)checkSelf(l);
         pushValue(l, true);
         pushEnum(l, (int)self.status);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
    static bool NavMeshAgent_SetPath__NavMeshPath(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 1)
        {
            UnityEngine.NavMeshPath arg0 = (UnityEngine.NavMeshPath)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(((UnityEngine.NavMeshAgent)vc.csObj).SetPath(arg0)));
        }

        return(true);
    }
    static bool NavMeshAgent_CalculatePath__Vector3__NavMeshPath(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 2)
        {
            UnityEngine.Vector3     arg0 = (UnityEngine.Vector3)JSApi.getVector3S((int)JSApi.GetType.Arg);
            UnityEngine.NavMeshPath arg1 = (UnityEngine.NavMeshPath)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(((UnityEngine.NavMeshAgent)vc.csObj).CalculatePath(arg0, arg1)));
        }

        return(true);
    }
Ejemplo n.º 41
0
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.NavMeshPath o;
     if (matchType(l, 1))
     {
         o = new UnityEngine.NavMeshPath();
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
Ejemplo n.º 42
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.NavMeshPath o;
         o = new UnityEngine.NavMeshPath();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.NavMeshPath o;
         o = new UnityEngine.NavMeshPath();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
// fields

// properties
    static void NavMeshPath_corners(JSVCall vc)
    {
        UnityEngine.NavMeshPath _this = (UnityEngine.NavMeshPath)vc.csObj;
        var result = _this.corners;
        var arrRet = result;

        for (int i = 0; arrRet != null && i < arrRet.Length; i++)
        {
            JSApi.setVector3S((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]);
            JSApi.moveSaveID2Arr(i);
        }
        JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true);
    }
Ejemplo n.º 45
0
 static public int GetCornersNonAlloc(IntPtr l)
 {
     try {
         UnityEngine.NavMeshPath self = (UnityEngine.NavMeshPath)checkSelf(l);
         UnityEngine.Vector3[]   a1;
         checkType(l, 2, out a1);
         var ret = self.GetCornersNonAlloc(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int GetCornersNonAlloc(IntPtr l)
 {
     try {
         UnityEngine.NavMeshPath self = (UnityEngine.NavMeshPath)checkSelf(l);
         UnityEngine.Vector3[]   a1;
         checkType(l, 2, out a1);
         var ret = self.GetCornersNonAlloc(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 47
0
// methods

    static bool NavMesh_CalculatePath__Vector3__Vector3__Int32__NavMeshPath(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 4)
        {
            UnityEngine.Vector3     arg0 = (UnityEngine.Vector3)JSApi.getVector3S((int)JSApi.GetType.Arg);
            UnityEngine.Vector3     arg1 = (UnityEngine.Vector3)JSApi.getVector3S((int)JSApi.GetType.Arg);
            System.Int32            arg2 = (System.Int32)JSApi.getInt32((int)JSApi.GetType.Arg);
            UnityEngine.NavMeshPath arg3 = (UnityEngine.NavMeshPath)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(UnityEngine.NavMesh.CalculatePath(arg0, arg1, arg2, arg3)));
        }

        return(true);
    }
 static void NavMeshAgent_path(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.NavMeshAgent _this = (UnityEngine.NavMeshAgent)vc.csObj;
         var result = _this.path;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.NavMeshPath  arg0  = (UnityEngine.NavMeshPath)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.NavMeshAgent _this = (UnityEngine.NavMeshAgent)vc.csObj;
         _this.path = arg0;
     }
 }
Ejemplo n.º 49
0
 static int SetPath(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.NavMeshAgent obj  = (UnityEngine.NavMeshAgent)ToLua.CheckObject(L, 1, typeof(UnityEngine.NavMeshAgent));
         UnityEngine.NavMeshPath  arg0 = (UnityEngine.NavMeshPath)ToLua.CheckObject(L, 2, typeof(UnityEngine.NavMeshPath));
         bool o = obj.SetPath(arg0);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 50
0
    static int set_path(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.NavMeshAgent obj  = (UnityEngine.NavMeshAgent)o;
            UnityEngine.NavMeshPath  arg0 = (UnityEngine.NavMeshPath)ToLua.CheckObject(L, 2, typeof(UnityEngine.NavMeshPath));
            obj.path = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index path on a nil value" : e.Message));
        }
    }
Ejemplo n.º 51
0
 static int CalculatePath(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         UnityEngine.NavMeshAgent obj  = (UnityEngine.NavMeshAgent)ToLua.CheckObject(L, 1, typeof(UnityEngine.NavMeshAgent));
         UnityEngine.Vector3      arg0 = ToLua.ToVector3(L, 2);
         UnityEngine.NavMeshPath  arg1 = (UnityEngine.NavMeshPath)ToLua.CheckObject(L, 3, typeof(UnityEngine.NavMeshPath));
         bool o = obj.CalculatePath(arg0, arg1);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 52
0
    static int get_path(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.NavMeshAgent obj = (UnityEngine.NavMeshAgent)o;
            UnityEngine.NavMeshPath  ret = obj.path;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index path on a nil value" : e.Message));
        }
    }
Ejemplo n.º 53
0
 private static extern bool INTERNAL_CALL_CalculatePathInternal(ref Vector3 sourcePosition, ref Vector3 targetPosition, int areaMask, NavMeshPath path);
Ejemplo n.º 54
0
 internal static bool CalculatePathInternal(Vector3 sourcePosition, Vector3 targetPosition, int areaMask, NavMeshPath path)
 {
     return(INTERNAL_CALL_CalculatePathInternal(ref sourcePosition, ref targetPosition, areaMask, path));
 }
Ejemplo n.º 55
0
 static public int get_corners(IntPtr l)
 {
     UnityEngine.NavMeshPath o = (UnityEngine.NavMeshPath)checkSelf(l);
     pushValue(l, o.corners);
     return(1);
 }
Ejemplo n.º 56
0
 static public int get_status(IntPtr l)
 {
     UnityEngine.NavMeshPath o = (UnityEngine.NavMeshPath)checkSelf(l);
     pushEnum(l, (int)o.status);
     return(1);
 }
Ejemplo n.º 57
0
 public static bool CalculatePath(Vector3 sourcePosition, Vector3 targetPosition, int areaMask, NavMeshPath path)
 {
     path.ClearCorners();
     return(CalculatePathInternal(sourcePosition, targetPosition, areaMask, path));
 }