static public int constructor(IntPtr l) {
		try {
			UnityEngine.NavMeshHit o;
			o=new UnityEngine.NavMeshHit();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
 static public int set_normal(IntPtr l)
 {
     UnityEngine.NavMeshHit o = (UnityEngine.NavMeshHit)checkSelf(l);
     UnityEngine.Vector3    v;
     checkType(l, 2, out v);
     o.normal = v;
     setBack(l, o);
     return(0);
 }
    static public int set_mask(IntPtr l)
    {
        UnityEngine.NavMeshHit o = (UnityEngine.NavMeshHit)checkSelf(l);
        int v;

        checkType(l, 2, out v);
        o.mask = v;
        setBack(l, o);
        return(0);
    }
    static public int set_distance(IntPtr l)
    {
        UnityEngine.NavMeshHit o = (UnityEngine.NavMeshHit)checkSelf(l);
        float v;

        checkType(l, 2, out v);
        o.distance = v;
        setBack(l, o);
        return(0);
    }
    static public int set_hit(IntPtr l)
    {
        UnityEngine.NavMeshHit o = (UnityEngine.NavMeshHit)checkSelf(l);
        bool v;

        checkType(l, 2, out v);
        o.hit = v;
        setBack(l, o);
        return(0);
    }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.NavMeshHit o;
         o=new UnityEngine.NavMeshHit();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.NavMeshHit o;
         o = new UnityEngine.NavMeshHit();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Example #8
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.NavMeshHit o;
         o = new UnityEngine.NavMeshHit();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        public override Vector3[] GetPointsArray(Vector3 startPosition, Vector3 targetPosition, AC.Char _char = null)
        {
            NavMeshHit hit = new NavMeshHit();
            NavMeshPath _path = new NavMeshPath();

            if (!NavMesh.CalculatePath (startPosition, targetPosition, -1, _path))
            {
                // Could not find path with current vectors
                float maxDistance = 0.001f;

                for (maxDistance = 0.001f; maxDistance < 1f; maxDistance += 0.05f)
                {
                    if (NavMesh.SamplePosition (startPosition, out hit, maxDistance, -1))
                    {
                        startPosition = hit.position;
                        break;
                    }
                }

                for (maxDistance = 0.001f; maxDistance < 1f; maxDistance += 0.05f)
                {
                    if (NavMesh.SamplePosition (targetPosition, out hit, maxDistance, -1))
                    {
                        targetPosition = hit.position;
                        break;
                    }
                }

                NavMesh.CalculatePath (startPosition, targetPosition, -1, _path);
            }

            List<Vector3> pointArray = new List<Vector3>();
            foreach (Vector3 corner in _path.corners)
            {
                pointArray.Add (corner);
            }
            if (pointArray.Count > 1 && pointArray[0].x == startPosition.x && pointArray[0].z == startPosition.z)
            {
                pointArray.RemoveAt (0);
            }
            else if (pointArray.Count == 0)
            {
                pointArray.Clear ();
                pointArray.Add (targetPosition);
            }

            return (pointArray.ToArray ());
        }
 static void NavMeshHit_mask(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.NavMeshHit _this = (UnityEngine.NavMeshHit)vc.csObj;
         var result = _this.mask;
         JSApi.setInt32((int)JSApi.SetType.Rval, (System.Int32)(result));
     }
     else
     {
         System.Int32           arg0  = (System.Int32)JSApi.getInt32((int)JSApi.GetType.Arg);
         UnityEngine.NavMeshHit _this = (UnityEngine.NavMeshHit)vc.csObj;
         _this.mask = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
 static void NavMeshHit_distance(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.NavMeshHit _this = (UnityEngine.NavMeshHit)vc.csObj;
         var result = _this.distance;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single          arg0  = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.NavMeshHit _this = (UnityEngine.NavMeshHit)vc.csObj;
         _this.distance = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
 static void NavMeshHit_hit(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.NavMeshHit _this = (UnityEngine.NavMeshHit)vc.csObj;
         var result = _this.hit;
         JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
     }
     else
     {
         System.Boolean         arg0  = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
         UnityEngine.NavMeshHit _this = (UnityEngine.NavMeshHit)vc.csObj;
         _this.hit = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
 static void NavMeshHit_normal(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.NavMeshHit _this = (UnityEngine.NavMeshHit)vc.csObj;
         var result = _this.normal;
         JSApi.setVector3S((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.Vector3    arg0  = (UnityEngine.Vector3)JSApi.getVector3S((int)JSApi.GetType.Arg);
         UnityEngine.NavMeshHit _this = (UnityEngine.NavMeshHit)vc.csObj;
         _this.normal = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
Example #14
0
 private bool CastRayToWorld(out Vector3 target)
 {
     Ray theRay = Camera.main.ScreenPointToRay(new Vector3(Camera.main.pixelWidth/2f, Camera.main.pixelHeight/2f, 0f));
     //		Ray theRay = Camera.main.ScreenPointToRay(Input.mousePosition);
     Debug.DrawRay (theRay.origin, theRay.direction);
     RaycastHit hit = new RaycastHit ();
     bool didRayHit = Physics.Raycast (theRay, out hit);
     NavMeshHit meshHit = new NavMeshHit();
     target = Vector3.zero;
     if (didRayHit == false) {
         return false;
     }
     NavMesh.SamplePosition (hit.point, out meshHit, 1f, NavMesh.AllAreas);
     target = meshHit.position;
     return true;
 }
Example #15
0
    public void WalkToRandomTarget()
    {
        // TODO(jrgfogh): Make this configurable.
        var radius = 30.0f;
        var hit = new NavMeshHit();

        while (!hit.hit)
        {
            var randomDirection = Random.insideUnitSphere * radius;
            randomDirection += transform.position;

            NavMesh.SamplePosition(randomDirection, out hit, radius, 1);
        }

        _agent.destination = hit.position;
    }
Example #16
0
    void OnEnable()
    {
        NavMeshHit hit = new NavMeshHit();
        if (NavMesh.SamplePosition(transform.position, out hit, 100, 1)) {
            transform.position = hit.position;
            navMeshAgent = GetComponent<NavMeshAgent> ();
            navMeshAgent.enabled = true;
        } else {
            Debug.Log("shit");
        }

        flying = false;
        EnemyManager.instance.OnBuff += Buff;
        target = Player.instance.positionController.transform;

        attackManager = GetComponent<AttackManager> ();
        attackManager.collisionDetection.OnDeath += RemoveEvents;
        AreaEnemySpawner.instance.OnStateChange += RemoveEvents;
        EnemyManager.instance.NotifyNewEnemy (attackManager);
        Buff ();
        state = Roaming;
    }
Example #17
0
    public bool canReach(Label target)
    {
        if(nav.enabled) {
            //Debug.Log("got here");
            NavMeshPath path = new NavMeshPath ();

            nav.CalculatePath(target.transform.position, path);
            List<Vector3> corners = new List<Vector3>(path.corners);
            corners.Add(target.transform.position);
            for(int i = 0; i < corners.Count-1; i++) {
                //Debug.Log("in the loop");
                NavMeshHit hit = new NavMeshHit();

                if (NavMesh.Raycast(corners[i], corners[i+1], out hit, NavMesh.AllAreas)) {
                    //Debug.Log("Raycast hit mask: " + hit.mask);
                    return false;
                }
            }
            return true;
        } else {
            return false;
        }
    }
 public bool FindClosestEdge(out NavMeshHit hit);
Example #19
0
 private Vector3 GetPointAlongPath(float distance = 0.01f)
 {
     NavMeshHit hit = new NavMeshHit(){position = MoveTarget};
     PathAgent.SamplePathPosition(NavMesh.AllAreas, distance, out hit);
     //Debug.DrawLine(transform.position, hit.position, Color.red, 0.5f);
     //Debug.Log("LINE");
     return hit.position;
 }
Example #20
0
 public bool SamplePathPosition(int areaMask, float maxDistance, out NavMeshHit hit)
 {
     throw new NotImplementedException("なにこれ");
 }
Example #21
0
 private static extern bool INTERNAL_CALL_Raycast(ref Vector3 sourcePosition, ref Vector3 targetPosition, out NavMeshHit hit, int areaMask);
Example #22
0
 private static extern bool INTERNAL_CALL_Raycast(NavMeshAgent self, ref Vector3 targetPosition, out NavMeshHit hit);
 public bool SamplePathPosition(int areaMask, float maxDistance, out NavMeshHit hit);
Example #24
0
 private static extern bool INTERNAL_CALL_SamplePosition(ref Vector3 sourcePosition, out NavMeshHit hit, float maxDistance, int areaMask);
Example #25
0
 public static bool Raycast(Vector3 sourcePosition, Vector3 targetPosition, out NavMeshHit hit, int areaMask)
 {
     return(INTERNAL_CALL_Raycast(ref sourcePosition, ref targetPosition, out hit, areaMask));
 }
Example #26
0
    /// <summary>
    /// Creates a path with randomized corners in it
    /// to give a navagent a non-perfect path
    /// </summary>
    /// <param name="_path"></param>
    public void GeneratePath(NavMeshPath _path)
    {
        Vector3[] corners = _path.corners;

        //A new path which is made up of the corners of the path
        //we use this to add in extra nodes that didn't exist, so we can then offset 
        //their position
        List<Vector3> _extendedPath = new List<Vector3>();
        for (int i = 1; i < corners.Length; ++i)
        {
            Vector3 a = corners[i - 1];
            Vector3 b = corners[i];
            _extendedPath.Add(a);

            //Those extra corners we add into the path
            int intermediatePoints = (int)UnityEngine.Random.Range(0, maxIntermediatePoints);

            for (int j = 0; j < intermediatePoints; ++j)
            {
                Vector3 intermediate = Vector3.Lerp(a, b, (float)i / (float)intermediatePoints);
                _extendedPath.Add(intermediate);
            }
        }
        _extendedPath.Add(corners[corners.Length - 1]);

        this.myProperties.newPath = new Queue<Vector3>();

        for (int i = 0; i < _extendedPath.Count; ++i)
        {
            //pick one based off of enum
            //Makes the path not-perfect by adding in randomized corners in the path
            Vector3 noisyPoint = (UnityEngine.Random.insideUnitSphere * noiseOffset) + _extendedPath[i];
                                                
            /*   TODO: use Animation Curves
            Vector3 noisyPoint = new Vector3
                 (
                 this.myProperties.mySeek.curve.Evaluate(this.myProperties.mySeek.curveTime)+ _extendedPath[i].x,
                 this.myProperties.myAgent.transform.position.y,
                 this.myProperties.mySeek.curve.Evaluate(this.myProperties.mySeek.curveTime) + _extendedPath[i].z
                 );
            */

            NavMeshHit hit = new NavMeshHit();

            //checks to see if the corner is in a proper nav area
            if (NavMesh.SamplePosition(noisyPoint, out hit, 10, 1))
            {
                this.myProperties.newPath.Enqueue(hit.position);  //if it is, put it in the queue
            }
        }
    }
Example #27
0
    // Update is called once per frame
    void Update()
    {
        if(PlayerPrefs.GetInt("Level") == 1)
        {
        // Blood splatter effect
        if(overlayToggle == true)
        {
            so[0].enabled = true;
            so[1].enabled = true;

            overlayTimer -= Time.deltaTime;
            if(overlayTimer <= 0.0f)
            {
                overlayTimer = 0.5f;
                overlayToggle = false;
                so[0].enabled = false;
                so[1].enabled = false;
            }
        }

        Vector3 ePos = nav.transform.position;
        Vector3 sPos = gameObject.transform.position;
        Vector3 flowDir = new Vector3(0,0,0);
        float distance = 0;

        NavMeshHit hit =  new NavMeshHit();

        objSpawnPos = obstacleNavObj.transform.position
            + new Vector3(UnityEngine.Random.Range(-0.25f, 0.25f), UnityEngine.Random.Range(-0.5f, 6.0f), 0.0f);

        obstacleTimer -= Time.deltaTime;
        bubbleParticleSpawnTimer -= Time.deltaTime;
        powerUpSpawnTimer -=Time.deltaTime;

        if(powerUpSpawnTimer <= 0.0f)
        {
            powerUpSpawnTimer = UnityEngine.Random.Range(15.0f, 20.0f);

            if(obstacleNavObj.remainingDistance >= 5.0f)
                InstantiatePowerUps();
        }

        if(obstacleTimer <= 0.0f)
        {
            // Easy
            if(globalObj.branchDiff == 0)
                obstacleTimer = UnityEngine.Random.Range(0.5f, 2.0f);

            // Hard
            else if(globalObj.branchDiff == 1)
                obstacleTimer = UnityEngine.Random.Range(0.5f, 1.0f);

            if(obstacleNavObj.remainingDistance >= 5.0f)
                InstantiateObstacles();
        }

        if(bubbleParticleSpawnTimer <= 0)
        {
            float theta = UnityEngine.Random.Range(0.0f, 360.0f);
            Vector3 bubbleParticleOffset = new Vector3((float)(4.0f*Math.Sin(theta)), UnityEngine.Random.Range(1.0f, 6.0f), (float)(4.0f*Math.Cos(theta)));
            Instantiate(bubbleParticles, obstacleNavObj.transform.position + bubbleParticleOffset, Quaternion.identity);
            bubbleParticleSpawnTimer =  Constants.BUBBLE_PARTICLE_SPAWN_TIMER;
        }

        grindTimer += Time.deltaTime;

        if(grindTimer > 0.1f)
        {
            playGrindSound = false;
            audioScript.audio4.Stop();
        }

        //vel.Normalize();
        float dist = navObj.remainingDistance;
        bool hasReached = false;

        if (Vector3.Distance(navObj.transform.position,navObj.destination) <= 10.0f)
             hasReached = true;

        //Debug.Log(hasReached);
        if(!hasReached)
        {
            flowDir = (ePos - sPos);

            // Offset the Y by 4 units to center the vector in the scene
            flowDir.y += 4.0f;

            distance = flowDir.magnitude * 0.7f;
            flowDir.Normalize();
            gameObject.rigidbody.velocity = -flowDir * distance;
        }
        else
            gameObject.rigidbody.velocity = gameObject.transform.forward*0.75f;
        }
    }
Example #28
0
 private static extern bool INTERNAL_CALL_SamplePosition(ref Vector3 sourcePosition, out NavMeshHit hit, float maxDistance, int areaMask);
Example #29
0
 private static extern bool INTERNAL_CALL_FindClosestEdge(ref Vector3 sourcePosition, out NavMeshHit hit, int areaMask);
 public bool Raycast(Vector3 targetPosition, out NavMeshHit hit)
 {
   return NavMeshAgent.INTERNAL_CALL_Raycast(this, ref targetPosition, out hit);
 }
 private static extern bool INTERNAL_CALL_Raycast(NavMeshAgent self, ref Vector3 targetPosition, out NavMeshHit hit);
Example #32
0
 private static extern bool INTERNAL_CALL_Raycast(ref Vector3 sourcePosition, ref Vector3 targetPosition, out NavMeshHit hit, int areaMask);
Example #33
0
 public extern bool FindClosestEdge(out NavMeshHit hit);
Example #34
0
 private static extern bool INTERNAL_CALL_FindClosestEdge(ref Vector3 sourcePosition, out NavMeshHit hit, int areaMask);
Example #35
0
 public extern bool SamplePathPosition(int areaMask, float maxDistance, out NavMeshHit hit);
 static int _CreateNavMeshHit(IntPtr L)
 {
     LuaScriptMgr.CheckArgsCount(L, 0);
     NavMeshHit obj = new NavMeshHit();
     LuaScriptMgr.PushValue(L, obj);
     return 1;
 }
Example #37
0
 public bool Raycast(Vector3 targetPosition, out NavMeshHit hit)
 {
     return(INTERNAL_CALL_Raycast(this, ref targetPosition, out hit));
 }
 static public int get_hit(IntPtr l)
 {
     UnityEngine.NavMeshHit o = (UnityEngine.NavMeshHit)checkSelf(l);
     pushValue(l, o.hit);
     return(1);
 }
Example #39
0
 public bool FindClosestEdge(out NavMeshHit hit)
 {
     throw new NotImplementedException("なにこれ");
 }
Example #40
0
 private static bool INTERNAL_CALL_SamplePosition(ref Vector3 sourcePosition, out NavMeshHit hit, float maxDistance, int areaMask)
 {
     throw new NotImplementedException("なにこれ");
 }
Example #41
0
 private static bool INTERNAL_CALL_Raycast(NavMeshAgent self, ref Vector3 targetPosition, out NavMeshHit hit)
 {
     throw new NotImplementedException("なにこれ");
 }
Example #42
0
 public bool Raycast(Vector3 targetPosition, out NavMeshHit hit)
 {
     return this.navAgent.Raycast(targetPosition, out hit);
 }
Example #43
0
 private static bool INTERNAL_CALL_Raycast(ref Vector3 sourcePosition, ref Vector3 targetPosition, out NavMeshHit hit, int areaMask)
 {
     throw new NotImplementedException("なにこれ");
 }
Example #44
0
 private static bool GetGroundInfoNavMesh(Vector3 startPos, out NavMeshHit hit, float maxVariationFallback, int acceptMask)
 {
     Vector3 vector3 = new Vector3();
     Vector3 vector31 = new Vector3();
     int num = ~acceptMask;
     float single = startPos.x;
     float single1 = single;
     vector3.x = single;
     vector31.x = single1;
     float single2 = startPos.z;
     single1 = single2;
     vector3.z = single2;
     vector31.z = single1;
     for (int i = 0; i < (int)TransformHelpers.upHeightTests.Length; i++)
     {
         vector3.y = startPos.y + TransformHelpers.upHeightTests[i].x;
         vector31.y = startPos.y + TransformHelpers.upHeightTests[i].y;
         if (NavMesh.Raycast(vector3, vector31, out hit, num))
         {
             return true;
         }
     }
     if (NavMesh.SamplePosition(startPos, out hit, maxVariationFallback, acceptMask))
     {
         return true;
     }
     return false;
 }
Example #45
0
 public static bool Raycast(Vector3 sourcePosition, Vector3 targetPosition, out NavMeshHit hit, int areaMask)
 {
   return NavMesh.INTERNAL_CALL_Raycast(ref sourcePosition, ref targetPosition, out hit, areaMask);
 }
Example #46
0
 public static bool FindClosestEdge(Vector3 sourcePosition, out NavMeshHit hit, int areaMask)
 {
     return(INTERNAL_CALL_FindClosestEdge(ref sourcePosition, out hit, areaMask));
 }
Example #47
0
 public static bool FindClosestEdge(Vector3 sourcePosition, out NavMeshHit hit, int areaMask)
 {
   return NavMesh.INTERNAL_CALL_FindClosestEdge(ref sourcePosition, out hit, areaMask);
 }
Example #48
0
 private static bool INTERNAL_CALL_FindClosestEdge(ref Vector3 sourcePosition, out NavMeshHit hit, int areaMask)
 {
     throw new NotImplementedException("なにこれ");
 }
Example #49
0
 public static bool SamplePosition(Vector3 sourcePosition, out NavMeshHit hit, float maxDistance, int areaMask)
 {
   return NavMesh.INTERNAL_CALL_SamplePosition(ref sourcePosition, out hit, maxDistance, areaMask);
 }
Example #50
0
 public static bool SamplePosition(Vector3 sourcePosition, out NavMeshHit hit, float maxDistance, int areaMask)
 {
     return(INTERNAL_CALL_SamplePosition(ref sourcePosition, out hit, maxDistance, areaMask));
 }