public void ResetRagdoll()
    {
        m_Alpha          = PEUtil.GetCmpt <StandardAlphaAnimator>(transform);
        m_Renderers      = PEUtil.GetCmpts <Renderer>(transform);
        m_Colliders      = PEUtil.GetCmpts <Collider>(transform);
        slaveRigidBodies = PEUtil.GetCmpts <Rigidbody>(transform);
        if (0 < slaveRigidBodies.Length)
        {
            ragdollRootBone = slaveRigidBodies[0].transform;
        }

        animFollow = GetComponent <AnimFollow_AF>();
        if (null != animFollow)
        {
            master = animFollow.master;
        }
        if (null != master)
        {
            masterRootBone = PETools.PEUtil.GetChild(master.transform, ragdollRootBone.name);
            anim           = PEUtil.GetCmpt <Animator>(master.transform);
        }
        if (m_RagdollEffect == null)
        {
            m_RagdollEffect = gameObject.AddComponent <PERagdollEffect>();
        }

        if (m_RagdollEffect != null)
        {
            m_RagdollEffect.ResetRagdoll();
        }
    }
Exemplo n.º 2
0
    public static EludePoint GetEludePoint(Vector3 pos, Vector3 targetPos)
    {
        EludePoint point  = null;
        float      minDis = 128.0f * 128.0f;

        for (int i = 0; i < s_Points.Count; i++)
        {
            if (s_Points[i].Dirty)
            {
                continue;
            }

            if (!s_Points[i].CanElude(targetPos))
            {
                continue;
            }

            float curDis = PEUtil.SqrMagnitudeH(pos, s_Points[i].Position);
            if (curDis < minDis)
            {
                minDis = curDis;
                point  = s_Points[i];
            }
        }

        return(point);
    }
Exemplo n.º 3
0
    bool CalculateVelocitySky(ref Vector3 velocity)
    {
        Vector3 _velocity = velocity;

        if (_velocity.sqrMagnitude > 0.01f * 0.01f)
        {
            _velocity = _velocity.normalized * Time.deltaTime * m_Motor.maxForwardSpeed * 10.0f;
            Vector3 _nextPosition = m_Entity.peTrans.position + _velocity;

            float height;
            if (PEUtil.GetWaterSurfaceHeight(_nextPosition, out height))
            {
                if (velocity.y < -PETools.PEMath.Epsilon)
                {
                    velocity.y = 0.0f;
                }

                if (m_Rigidbody.velocity.y < -PETools.PEMath.Epsilon)
                {
                    velocity.y = -m_Rigidbody.velocity.y;
                }
            }
        }

        return(true);
    }
Exemplo n.º 4
0
    void GetIKs(Transform root)
    {
        if (m_IKs == null && root != null)
        {
            m_IKs = new AimIK[0];

            Transform ikTrans = PEUtil.GetChild(root, "GrounderIK");
            if (ikTrans != null)
            {
                for (int i = 0; i < ikBones.Length; i++)
                {
                    Transform tr = PEUtil.GetChild(ikTrans, ikBones[i]);
                    if (tr != null)
                    {
                        AimIK ik = tr.GetComponent <AimIK>();
                        if (ik != null)
                        {
                            System.Array.Resize(ref m_IKs, m_IKs.Length + 1);
                            m_IKs[m_IKs.Length - 1] = ik;
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 5
0
    public void Reset()
    {
        transform.position = Vector3.zero;
        transform.rotation = Quaternion.identity;

        m_Bounds.SetMinMax(Vector3.zero, Vector3.zero);
        Renderer[] renders = PEUtil.GetCmpts <Renderer>(transform);
        for (int i = 0; i < renders.Length; ++i)
        {
            m_Bounds.Encapsulate(renders[i].bounds);
        }

        Collider[] colliders = PEUtil.GetCmpts <Collider>(transform);
        for (int i = 0; i < colliders.Length; ++i)
        {
            m_Bounds.Encapsulate(colliders[i].bounds);
        }

        ItemDraggingBase draggingBase = GetComponent <ItemDraggingBase>();

        if (null != draggingBase)
        {
            draggingBase.itemBounds = this;
        }
    }
Exemplo n.º 6
0
    void ActivateCombatIK(string data)
    {
        string[] args = PEUtil.ToArrayString(data, '|');

        string[] datas = PETools.PEUtil.ToArrayString(args[1], ',');
        foreach (string item in datas)
        {
            Transform tr = PETools.PEUtil.GetChild(transform, item);
            if (tr != null)
            {
                CCDIK ik = tr.GetComponent <CCDIK>();

                if (ik != null)
                {
                    IKData ikData = m_IKDataList.Find(ret => ret.ik == ik);
                    if (ikData == null)
                    {
                        IKData newIKData = new IKData();
                        newIKData.ik     = ik;
                        newIKData.limit  = newIKData.ik.GetComponent <IKCombatLimit>();
                        newIKData.target = GetIKTransform();
                        newIKData.curve  = args[0];

                        //newIKData.ik.solver.target = GetIKTransform(GetTarget());
                        //newIKData.ik.solver.SetIKPosition(GetIKPosition(newIKData));

                        m_IKDataList.Add(newIKData);
                    }
                }
            }
        }
    }
Exemplo n.º 7
0
        public Transform GetChild(string boneName)
        {
            if (string.IsNullOrEmpty(boneName) || "0" == boneName)
            {
                return(null);
            }

            Transform child;
            int       nameHash = boneName.GetHashCode();

            if (m_TransDic.ContainsKey(nameHash))
            {
                child = m_TransDic[nameHash];
                if (null != child)
                {
                    return(child);
                }
            }

            if (null != biologyViewCmpt && null != biologyViewCmpt.modelTrans)
            {
                child = PEUtil.GetChild(biologyViewCmpt.modelTrans, boneName);
            }
            else
            {
                child = PEUtil.GetChild(transform, boneName);
            }
            if (null != child)
            {
                m_TransDic[nameHash] = child;
            }
            return(child);
        }
Exemplo n.º 8
0
        Vector3 GetLocalPos(Enemy e, AttackMode attack)
        {
            if (!PEUtil.IsBlocked(e.entity, e.entityTarget) && !Stucking() && !PEUtil.IsNpcsuperposition(e.entity, e))
            {
                m_Local = Vector3.zero;
            }
            else
            {
                if (m_Local == Vector3.zero || PEUtil.IsBlocked(e.entityTarget, GetLocalCenterPos()) || PEUtil.IsNpcsuperposition(GetLocalCenterPos(), e))
                {
                    Vector3 local = Vector3.zero;
                    float   ra    = e.entityTarget.bounds.extents.x > e.entityTarget.bounds.extents.z ? e.entityTarget.bounds.extents.x : e.entityTarget.bounds.extents.z;
                    for (int i = 0; i < 5; i++)
                    {
                        Vector3 pos       = PEUtil.GetRandomPositionOnGround(e.position, attack.minRange + ra, attack.maxRange + ra);
                        Vector3 offCenter = pos + Vector3.up * entity.maxHeight * 0.5f;

                        if (!PEUtil.IsBlocked(e.entityTarget, offCenter) && !PEUtil.IsNpcsuperposition(offCenter, e))
                        {
                            local = pos - e.position;
                            break;
                        }
                    }

                    m_Local = local;
                }
            }

            return(m_Local);
        }
Exemplo n.º 9
0
    internal override void Init(Animator animator)
    {
        base.Init(animator);

        for (int i = 0; i < m_Attacks.Length; i++)
        {
            m_Attacks[i].triggers = new PEAttackTrigger[m_Attacks[i].bones.Length];
            for (int j = 0; j < m_Attacks[i].bones.Length; j++)
            {
                Transform tr = PEUtil.GetChild(animator.transform, m_Attacks[i].bones[j]);
                if (tr != null)
                {
                    PEAttackTrigger attackTrigger = tr.GetComponent <PEAttackTrigger>();
                    if (null != attackTrigger)
                    {
                        m_Attacks[i].triggers[j] = attackTrigger;
                    }
                    else
                    {
                        Debug.LogError("Can't find PEAttackTrigger:" + m_Attacks[i].bones[j]);
                    }
                }
                else
                {
                    Debug.LogError("Can't find bone:" + m_Attacks[i].bones[j]);
                }
            }
        }
    }
Exemplo n.º 10
0
        Vector3 GetPatrolPosition(Tree sender)
        {
            BehaveGroup group = sender.ActiveAgent as BehaveGroup;

            if (group == null || group.Leader == null)
            {
                return(Vector3.zero);
            }

            PeTrans tr  = group.Leader.GetComponent <PeTrans>();
            Vector3 pos = tr.position;

            if (m_Data.field == (int)MovementField.water)
            {
                return(PEUtil.GetRandomPositionInWater(pos, tr.trans.forward, m_Data.minRadius, m_Data.maxRadius, m_Data.minHeight, m_Data.maxHeight, -135.0f, 135.0f));
            }
            else if (m_Data.field == (int)MovementField.Sky)
            {
                if (group.Leader.IsFly)
                {
                    return(PEUtil.GetRandomPositionInSky(pos, tr.trans.forward, m_Data.minRadius, m_Data.maxRadius, m_Data.minHeight, m_Data.maxHeight, -135.0f, 135.0f));
                }
                else
                {
                    return(PEUtil.GetRandomPositionOnGround(pos, tr.trans.forward, m_Data.minRadius, m_Data.maxRadius, -135.0f, 135.0f));
                }
            }
            else
            {
                return(PEUtil.GetRandomPositionOnGround(pos, tr.trans.forward, m_Data.minRadius, m_Data.maxRadius, -135.0f, 135.0f));
            }
        }
Exemplo n.º 11
0
        void CalculateDestination()
        {
            m_CurMoveDestination = m_MoveDestination;

            if (m_CurMoveDestination != Vector3.zero && m_Motor != null)
            {
                float sqrDis = PEUtil.SqrMagnitude(m_Motor.transform.position, m_CurMoveDestination, m_Motor.gravity < PETools.PEMath.Epsilon);

                Enemy enemy = m_target != null?m_target.GetAttackEnemy() : null;

                if (enemy != null && PEUtil.SqrMagnitude(m_CurMoveDestination, enemy.position, false) < 0.25f * 0.25f)
                {
                    if (m_Motor.gravity < PETools.PEMath.Epsilon)
                    {
                        sqrDis = enemy.SqrDistance;
                    }
                    else
                    {
                        sqrDis = enemy.SqrDistanceXZ;
                    }
                }

                if (sqrDis < 0.1f * 0.1f)
                {
                    m_CurMoveDestination = Vector3.zero;
                }
            }
        }
Exemplo n.º 12
0
        bool CalculateVelocityWater(ref Vector3 velocity)
        {
            if (velocity.sqrMagnitude > 0.01f * 0.01f)
            {
                float   maxSpeed = m_MotionMove.motor.maxForwardSpeed;
                Vector3 pos      = m_Trans.trans.TransformPoint(m_Trans.bound.center) - Vector3.up * m_Trans.bound.extents.y;
                Vector3 v        = pos + Vector3.up * (m_Trans.bound.size.y + 0.5f) + Vector3.up * Time.deltaTime * maxSpeed * 5;
                if (!PEUtil.CheckPositionUnderWater(v))
                {
                    if (velocity.y > PETools.PEMath.Epsilon)
                    {
                        velocity.y = 0.0f;
                    }

                    Vector3 movement = new Vector3(velocity.x, 0.0f, velocity.z);
                    if (movement.sqrMagnitude > 0.01f * 0.01f)
                    {
                        Vector3 dir      = movement.normalized * maxSpeed * Time.deltaTime * 5.0f;
                        float   distance = Mathf.Max(m_Trans.bound.extents.x, m_Trans.bound.extents.z) + dir.magnitude + 1.0f;
                        if (Physics.Raycast(pos, dir, distance, GameConfig.GroundLayer))
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Exemplo n.º 13
0
        BehaveResult Tick(Tree sender)
        {
            BehaveGroup group = sender.ActiveAgent as BehaveGroup;

            if (group == null || group.Leader == null)
            {
                return(BehaveResult.Failure);
            }

            if (group.EscapeEnemy == null)
            {
                return(BehaveResult.Failure);
            }

            if (m_CurEscapeposition == Vector3.zero ||
                PEUtil.SqrMagnitudeH(group.Leader.position, m_CurEscapeposition) < 1.0f * 1.0f ||
                Time.time - m_LastRandomTime > 10.0f)
            {
                m_LastRandomTime = Time.time;

                PeTrans tr = group.Leader.GetComponent <PeTrans>();
                m_CurEscapeposition = GetEscapePosition(group, tr.position, tr.position - group.EscapeEnemy.position, 25.0f, 35.0f);
                if (m_CurEscapeposition == Vector3.zero)
                {
                    return(BehaveResult.Failure);
                }
                else
                {
                    group.MoveToPosition(m_CurEscapeposition, SpeedState.Run);
                }
            }

            return(BehaveResult.Running);
        }
Exemplo n.º 14
0
    public void ResetRagdoll()
    {
        //PECollision[] cols = PEUtil.GetAllCmpts<PECollision>(transform);
        //for (int n = 0; n < cols.Length; n++)
        //    GameObject.DestroyImmediate(cols[n], true);

        m_Rigibodys = PEUtil.GetCmpts <Rigidbody>(transform);
        if (m_Rigibodys != null && m_Rigibodys.Length > 0)
        {
            m_Collisions = new PECollision[m_Rigibodys.Length];
            for (int i = 0; i < m_Rigibodys.Length; i++)
            {
                PECollision[] cols = m_Rigibodys[i].gameObject.GetComponents <PECollision>();
                for (int j = 0; j < cols.Length; j++)
                {
                    if (m_Collisions[i] == null)
                    {
                        m_Collisions[i] = cols[j];
                    }
                    else
                    {
                        GameObject.DestroyImmediate(cols[j], true);
                    }
                }

                if (m_Collisions[i] == null)
                {
                    m_Collisions[i] = m_Rigibodys[i].gameObject.AddComponent <PECollision>();
                }
            }
        }
    }
Exemplo n.º 15
0
        BehaveResult Tick(Tree sender)
        {
            if (!GetData <Data>(sender, ref m_Data))
            {
                return(BehaveResult.Failure);
            }

            if (GetBool("Chatting"))
            {
                return(BehaveResult.Running);
            }

            if (entity.Chat == null)
            {
                return(BehaveResult.Success);
            }

            if (!Enemy.IsNullOrInvalid(attackEnemy))
            {
                return(BehaveResult.Failure);
            }

            if (Time.time - m_Data.m_StartTime > m_Data.m_Time)
            {
                return(BehaveResult.Success);
            }

            if (PEUtil.MagnitudeH(position, entity.Chat.position) > radius + entity.Chat.maxRadius + m_Data.chatRadius)
            {
                MoveToPosition(entity.Chat.position, SpeedState.Walk);
            }
            else
            {
                MoveToPosition(Vector3.zero);

                if (!PEUtil.IsScopeAngle(entity.Chat.position - position, transform.forward, Vector3.up, -15.0f, 15.0f))
                {
                    FaceDirection(entity.Chat.position - position);
                }
                else
                {
                    FaceDirection(Vector3.zero);

                    if (Time.time - m_Data.m_LastChatTime > m_Data.m_ChatTime)
                    {
                        if (m_Data.chats.Length > 0)
                        {
                            SetBool(m_Data.chats[Random.Range(0, m_Data.chats.Length)], true);
                        }

                        m_Data.m_LastChatTime = Time.time;
                        m_Data.m_ChatTime     = Random.Range(m_Data.minChatTime, m_Data.maxChatTime);
                    }
                }
            }

            return(BehaveResult.Running);
        }
Exemplo n.º 16
0
        Vector3 GetAttackPos()
        {
            if (field == MovementField.Sky)
            {
                return(PEUtil.GetRandomPositionInSky(m_Data.followEntity.position, m_Data.followEntity.position - attackEnemy.centerPos, m_Data.minR, m_Data.maxR, m_Data.minH, m_Data.maxH, -60.0f, 60.0f));
            }

            return(position);
        }
Exemplo n.º 17
0
        Vector3 GetAroundPos(Vector3 targetPos)
        {
            if (field == MovementField.Sky)
            {
                return(PEUtil.GetRandomFollowPosInSky(targetPos, transform.position - targetPos, m_Data.minR, m_Data.maxR, m_Data.minH, m_Data.maxH, -60.0f, 60.0f));
            }

            return(position + m_LocalPos);
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
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);
     }
 }
Exemplo n.º 20
0
 bool Match(PeEntity entity, Vector3 pos, float radius)
 {
     if (entity != null)
     {
         return(PEUtil.SqrMagnitudeH(entity.position, pos) <= (radius + entity.maxRadius) * (radius + entity.maxRadius));
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 21
0
        bool CanAttack(IWeapon weapon, int index)
        {
            AttackMode[] modes = weapon.GetAttackMode();
            if (index < 0 || index >= modes.Length)
            {
                return(false);
            }

            AttackMode mode = modes[index];

            return(mode.ignoreTerrain || !PEUtil.IsBlocked(entity, selectattackEnemy.entityTarget));
        }
Exemplo n.º 22
0
 void OnBorderEnter(IntVector2 node)
 {
     if (m_Obj != null)
     {
         Vector3 pos;
         if (PEUtil.GetFixedPosition(LODOctreeMan.self.GetNodes(node), transform.position, out pos))
         {
             m_Obj.transform.position = pos;
             m_Obj.SetActive(true);
         }
     }
 }
Exemplo n.º 23
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);
    }
Exemplo n.º 24
0
            public bool isReached(Vector3 pos, Transform target)
            {
                float sqrDistanceH = PEUtil.SqrMagnitudeH(pos, target.position + m_Anchor);

                if (sqrDistanceH < 1.0f * 1.0f)
                {
                    m_Reached    = true;
                    m_Calculated = false;
                }

                return(m_Reached);
            }
Exemplo n.º 25
0
        BehaveResult Tick(Tree sender)
        {
            if (spawnPosition == Vector3.zero)
            {
                return(BehaveResult.Failure);
            }

            if (!Enemy.IsNullOrInvalid(attackEnemy))
            {
                return(BehaveResult.Success);
            }

            float d = 0.0f;

            if (gravity > PETools.PEMath.Epsilon)
            {
                d = PEUtil.SqrMagnitudeH(position, spawnPosition);
            }
            else
            {
                d = PEUtil.SqrMagnitude(position, spawnPosition);
            }

            if (d > 1f * 1f)
            {
                if (Stucking(3.0f))
                {
                    SetPosition(spawnPosition);
                }
                else
                {
                    MoveToPosition(spawnPosition, SpeedState.Run);
                }

                return(BehaveResult.Running);
            }
            else
            {
                MoveToPosition(Vector3.zero);

                if (PEUtil.AngleH(transform.forward, spawnForward) > 5.0f)
                {
                    FaceDirection(spawnForward);
                    return(BehaveResult.Running);
                }
                else
                {
                    FaceDirection(Vector3.zero);
                    return(BehaveResult.Success);
                }
            }
        }
Exemplo n.º 26
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);
     }
 }
Exemplo n.º 27
0
        BehaveResult Tick(Tree sender)
        {
            if (!GetData <Data>(sender, ref m_Data))
            {
                return(BehaveResult.Failure);
            }

            if (entity.Treat == null || entity.Treat.IsDeath() || !entity.Treat.hasView)
            {
                return(BehaveResult.Failure);
            }

            if (!entity.Treat.IsSeriousInjury)
            {
                return(BehaveResult.Success);
            }

            //Vector3 targetPos = entity.Treat.position + entity.Treat.tr.right * (radius + entity.Treat.maxRadius + 1.0f);
            Vector3 targetPos = entity.Treat.position;

            if (PEUtil.SqrMagnitudeH(position, targetPos) > 2f * 2f)
            {
                MoveToPosition(targetPos, SpeedState.Run);
            }
            else
            {
                MoveToPosition(Vector3.zero);

                Vector3 v1 = Vector3.ProjectOnPlane(entity.Treat.position - position, Vector3.up);
                Vector3 v2 = Vector3.ProjectOnPlane(transform.forward, Vector3.up);
                if (Vector3.Angle(v1, v2) > 5.0f)
                {
                    FaceDirection(v1);
                }
                else
                {
                    FaceDirection(Vector3.zero);

                    if (!m_Treat)
                    {
                        m_Treat = true;

                        entity.Treat.StopSkill(30100326);
                        SetBool(m_Data.anim, true);
                        StartSkill(entity.Treat, m_Data.skillId);
                    }
                }
            }

            return(BehaveResult.Running);
        }
Exemplo n.º 28
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);
        }
Exemplo n.º 29
0
 Vector3 GetAroundPos()
 {
     if (field == MovementField.Sky)
     {
         return(PEUtil.GetRandomFollowPosInSky(m_Data.followEntity.position, transform.position - m_Data.followEntity.position, m_Data.minRange, m_Data.maxRange, m_Data.minHeight, m_Data.maxHeight, -90.0f, 90.0f));
     }
     else if (field == MovementField.water)
     {
         return(PEUtil.GetRandomPositionInWater(m_Data.followEntity.position, transform.position - m_Data.followEntity.position, m_Data.minRange, m_Data.maxRange, m_Data.minHeight, m_Data.maxHeight, -90.0f, 90.0f));
     }
     else
     {
         return(PEUtil.GetRandomPositionOnGround(m_Data.followEntity.position, transform.position - m_Data.followEntity.position, m_Data.minRange, m_Data.maxRange, -90.0f, 90.0f));
     }
 }
Exemplo n.º 30
0
        public static Color32 GetAttributeColor(XmlElement e, string name)
        {
            if (e != null && !string.IsNullOrEmpty(name) && e.HasAttribute(name))
            {
                try
                {
                    return(PEUtil.ToColor32(e.GetAttribute(name), ','));
                }
                catch (System.Exception ex)
                {
                    Debug.LogWarning(ex);
                }
            }

            return(new Color32(0, 0, 0, 0));
        }