예제 #1
0
        Vector3 GetFixedPosition(Vector3 pos1, Vector3 direction1, Vector3 pos2, Vector3 direction2, float height)
        {
            Vector3 pos         = pos1;
            Vector3 newPosition = PEUtil.GetRandomPosition(pos1 + m_Data.Anchor, direction1, m_Data.firRadius, m_Data.sndRadius - 0.5f, -90.0f, 90.0f);

            if (PEUtil.CheckPositionNearCliff(newPosition))
            {
                pos         = pos2;
                newPosition = PEUtil.GetRandomPosition(pos2 + m_Data.Anchor, direction2, m_Data.firRadius, m_Data.sndRadius - 0.5f, -90.0f, 90.0f);
            }

            RaycastHit hitInfo;
            Ray        ray = new Ray(pos, Vector3.up);

            //Target in the hole
            if (Physics.Raycast(ray, out hitInfo, 128.0f, PEConfig.GroundedLayer))
            {
                ray = new Ray(newPosition, Vector3.up);
                if (Physics.Raycast(ray, out hitInfo, 128.0f, PEConfig.GroundedLayer))
                {
                    //hole in water
                    if (PEUtil.CheckPositionUnderWater(hitInfo.point - Vector3.up))
                    {
                        return(newPosition);
                    }
                    else
                    {
                        ray = new Ray(newPosition, Vector3.down);
                        if (Physics.Raycast(ray, out hitInfo, 128.0f, PEConfig.GroundedLayer))
                        {
                            return(hitInfo.point + Vector3.up);
                        }
                    }
                }
                else
                {
                    return(Vector3.zero);
                }
            }
            else
            {
                //Target not in the hole
                Ray rayStart = new Ray(newPosition + 128.0f * Vector3.up, -Vector3.up);
                if (Physics.Raycast(rayStart, out hitInfo, 256.0f, PEConfig.GroundedLayer))
                {
                    if (PEUtil.CheckPositionUnderWater(hitInfo.point))
                    {
                        return(newPosition);
                    }
                    else
                    {
                        return(hitInfo.point + Vector3.up);
                    }
                }
            }
            return(Vector3.zero);
        }
예제 #2
0
 public void CalculateAvoidAnchor(Vector3 pos, Vector3 center, Vector3 dir)
 {
     if (!m_Calculated)
     {
         m_Reached    = false;
         m_Calculated = true;
         //Vector3 v = Vector3.ProjectOnPlane(pos - center, Vector3.up);
         m_Anchor = PEUtil.GetRandomPosition(Vector3.zero, dir, firRadius, sndRadius, -90.0f, 90.0f);
         m_Anchor = new Vector3(m_Anchor.x, 0.0f, m_Anchor.z);
     }
 }
예제 #3
0
    public static Vector3 GetRandomPosition(Vector3 pos, int level)
    {
        for (int i = 0; i < allShileds.Count; i++)
        {
            if (allShileds[i].Inside(pos) && allShileds[i].Difference(level) >= 2)
            {
                return(PEUtil.GetRandomPosition(allShileds[i].Pos, pos - allShileds[i].Pos, allShileds[i].m_Radius * 1.2f, allShileds[i].m_Radius * 1.5f, -75.0f, 75.0f));
            }
        }

        return(Vector3.zero);
    }
예제 #4
0
 public void CalculateAnchor(Vector3 pos, Vector3 center, Vector3 dir)
 {
     if (!m_Calculated)
     {
         m_Reached    = false;
         m_Calculated = true;
         //Vector3 v = Vector3.ProjectOnPlane(pos - center, Vector3.up);
         bool  _IsInSpSence = Pathea.PeGameMgr.IsAdventure && RandomDungenMgr.Instance != null && RandomDungenMgrData.dungeonBaseData != null;
         float angle        = _IsInSpSence ? 20.0f : 90.0f;
         m_Anchor = PEUtil.GetRandomPosition(Vector3.zero, dir, firRadius, sndRadius, -angle, angle);
         m_Anchor = new Vector3(m_Anchor.x, 0.0f, m_Anchor.z);
     }
 }
예제 #5
0
        Vector3 GetPatrolPosition(Vector3 center, Vector3 direction, float minRadius, float maxRadius)
        {
            if (AstarPath.active != null)            //PEUtil.IsInAstarGrid(position))
            {
                Pathfinding.RandomPath path = Pathfinding.RandomPath.Construct(position, (int)Random.Range(minRadius, maxRadius) * 100, OnPathComplete);
                path.spread      = 40000;
                path.aimStrength = 1f;
                path.aim         = PEUtil.GetRandomPosition(position, direction, minRadius, maxRadius, -75.0f, 75.0f);
                AstarPath.StartPath(path);

                return(Vector3.zero);
            }
            return(Vector3.zero);
        }
예제 #6
0
        Vector3 GetRetreatPos(Vector3 TargetPos, Transform selfTrans, float minr, float maxr)
        {
            Vector3 selfPos = selfTrans.position;
            Vector3 dir     = (selfPos - TargetPos).normalized;
            Vector3 retreat = PEUtil.GetRandomPosition(selfTrans.position, dir, minr, maxr, -90.0f, 90.0f);

            if (PEUtil.CheckPositionUnderWater(retreat) || PEUtil.CheckPositionInSky(retreat))
            {
                dir     = Random.value > 0.5 ? selfTrans.right : -selfTrans.right;
                retreat = selfPos + dir * 20.0f;
            }

//			Vector3 newpos;
//			if(AiUtil.GetNearNodePosWalkable(retreat,out newpos))
//			{
//				return newpos;
//			}
            return(retreat);
        }
예제 #7
0
 Vector3 GetPutItemPostion()
 {
     return(PEUtil.GetRandomPosition(GetMasterPosition(NpcMaster), 3.0f, 5.0f));
 }
예제 #8
0
 Vector3 GetPosition()
 {
     return(PEUtil.GetRandomPosition(GetMasterPosition(NpcMaster), 3.0f, 5.0f) + Vector3.up * 2.0f);
 }
예제 #9
0
 //float WORKTIME = 300.0f;
 Vector3 GetMovePosition()
 {
     return(PEUtil.GetRandomPosition(position, 1024.0f, 2048.0f));
 }