Esempio n. 1
0
        public bool NearEntityModel(Vector3 pos, float radius, int playerID, bool isDeath, PeEntity exclude = null)
        {
            int   n         = m_Entities.Count;
            float sqrRadius = radius * radius;

            for (int i = 0; i < n; i++)
            {
                PeEntity entity = m_Entities[i];
                if (entity == null || (entity.Equals(exclude)) || !entity.hasView || entity.IsDeath() != isDeath)
                {
                    continue;
                }

                if (NpcRobotDb.Instance != null && entity.Id == NpcRobotDb.Instance.mID)
                {
                    continue;
                }

                int pid = (int)entity.GetAttribute(AttribType.DefaultPlayerID);
                if (PETools.PEUtil.SqrMagnitudeH(entity.position, pos) <= sqrRadius && ForceSetting.Instance.AllyPlayer(playerID, pid))
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 2
0
        public void ActivateEffect(PeEntity peEntity)
        {
            if (peEntity.HPPercent <= m_hpPercent && !peEntity.IsDeath())
            {
                if (m_effect == null && m_Request == null)
                {
                    m_Request             = EffectBuilder.Instance.Register(m_effectID, null, peEntity.tr);
                    m_Request.SpawnEvent += OnSpawned;
                    m_auCtrl              = AudioManager.instance.Create(peEntity.position, m_AudioID, null, true, false);
                }

                if (m_effect != null && !m_effect.activeSelf)
                {
                    m_effect.SetActive(true);

                    if (m_auCtrl != null)
                    {
                        m_auCtrl.PlayAudio(2.0f);
                    }
                }
            }
            else
            {
                if (m_effect != null && m_effect.activeSelf)
                {
                    m_effect.SetActive(false);

                    if (m_auCtrl != null)
                    {
                        m_auCtrl.StopAudio(2.0f);
                    }
                }
            }
        }
Esempio n. 3
0
        public List <PeEntity> GetEntitiesFriendly(Vector3 pos, float radius, int playerID, int protoID, bool isDeath, PeEntity exclude = null)
        {
            m_Tmp.Clear();

            int n = m_Entities.Count;

            for (int i = 0; i < n; i++)
            {
                PeEntity entity = m_Entities[i];

                if (entity == null || (entity.Equals(exclude)) || entity.IsDeath() != isDeath)
                {
                    continue;
                }

                int pid1 = playerID;
                int pid2 = (int)entity.GetAttribute(AttribType.DefaultPlayerID);
                if (pid1 == pid2 && (pid1 != 4 || protoID == entity.ProtoID))
                {
                    if (PETools.PEUtil.SqrMagnitudeH(entity.position, pos) <= radius * radius)
                    {
                        m_Tmp.Add(m_Entities[i]);
                    }
                }
            }

            return(m_Tmp);
        }
Esempio n. 4
0
    protected virtual void Update()
    {
        if (null == m_ParentTrans)
        {
            GameObject.Destroy(gameObject);
            return;
        }

        bool activeState = m_ParentTrans.gameObject.activeInHierarchy;

        if (null != m_Entity)
        {
            activeState = activeState && !m_Entity.IsDeath();
        }
        if (activeState != gameObject.activeSelf)
        {
            gameObject.SetActive(activeState);
        }

        Vector3 updateDir = m_ParentTrans.position - ((m_UpdatePos != Vector3.zero)?m_UpdatePos:m_ParentTrans.position);

        m_UpdatePos        = m_ParentTrans.position;
        transform.position = m_LateUpdatePos + updateDir;
        transform.rotation = m_LateUpdateRot;
    }
Esempio n. 5
0
        public List <PeEntity> GetEntities(Vector3 pos, float radius, int playerID, bool isDeath, PeEntity exclude = null)
        {
            m_Tmp.Clear();

            int n = m_Entities.Count;

            for (int i = 0; i < n; i++)
            {
                PeEntity entity = m_Entities[i];

                if (entity == null || (entity.Equals(exclude)) || entity.IsDeath() != isDeath)
                {
                    continue;
                }

                int pid = (int)entity.GetAttribute(AttribType.DefaultPlayerID);
                if ((PETools.PEUtil.SqrMagnitudeH(entity.position, pos) <= radius * radius && ForceSetting.Instance.AllyPlayer(playerID, pid)) ||
                    PETools.PEUtil.CanCordialReputation(playerID, pid)
                    )
                {
                    m_Tmp.Add(m_Entities[i]);
                }
            }

            return(m_Tmp);
        }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        if (Application.isEditor)
        {
            //UpdateTest();
        }

        //lz-2016.11.03 有数据的情况下保证每一帧都有显示有效数据
        m_CurFrameHasShow = false;
        while (!m_CurFrameHasShow && null != m_HPEventData) //lz-2016.11.07 有可能会变空
        {
            HPChangeEventData data = m_HPEventData.Pop();
            //lz-2016.11.03 因为这里是用栈处理的,只显示最新的,如果堆积超时的就不要了
            if (null == data || Time.realtimeSinceStartup - data.m_AddTime >= m_DataOutTime)
            {
                m_CurFrameHasShow = true;
            }
            else
            {
                if (null != data.m_Transfrom && null != data.m_Self)
                {
                    Pathea.PeEntity entity = data.m_Self.GetComponent <Pathea.PeEntity>();
                    //lz-2016.11.03 entity没有死,并且Transfrom还存在的时候才显示HPChange效果
                    if (null != entity && !entity.IsDeath())
                    {
                        if (ShowHPChange(data.m_HPChange, data.m_Transfrom.position, data.m_Proto))
                        {
                            m_CurFrameHasShow = true;
                        }
                    }
                }
            }
        }
    }
Esempio n. 7
0
        bool Match(PeEntity entity, Vector3 pos, float radius, int playerID, bool isDeath, PeEntity exclude = null)
        {
            if (entity == null || (entity.Equals(exclude)) || entity.IsDeath() != isDeath)
            {
                return(false);
            }

            int pid = (int)entity.GetAttribute(AttribType.DefaultPlayerID);

            if (ForceSetting.Instance.AllyPlayer(playerID, pid) &&
                PETools.PEUtil.SqrMagnitudeH(entity.position, pos) <= radius * radius)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 8
0
        public List <PeEntity> GetEntities(Vector3 pos, float radius, bool isDeath)
        {
            m_Tmp.Clear();

            int n = m_Entities.Count;

            for (int i = 0; i < n; i++)
            {
                PeEntity entity    = m_Entities[i];
                float    maxRadius = radius + entity.maxRadius;
                if (entity != null &&
                    entity.IsDeath() == isDeath &&
                    PEUtil.SqrMagnitudeH(entity.position, pos) <= maxRadius * maxRadius)
                {
                    m_Tmp.Add(m_Entities[i]);
                }
            }

            return(m_Tmp);
        }
Esempio n. 9
0
        bool MatchFriendly(PeEntity entity, Vector3 pos, float radius, int playerID, int prototID, bool isDeath, PeEntity exclude = null)
        {
            if (entity == null || (entity.Equals(exclude)) || entity.IsDeath() != isDeath)
            {
                return(false);
            }

            int pid1 = playerID;
            int pid2 = (int)entity.GetAttribute(AttribType.DefaultPlayerID);

            if (pid1 == pid2 && (pid1 != 4 || prototID == entity.ProtoID))
            {
                if (PETools.PEUtil.SqrMagnitudeH(entity.position, pos) <= radius * radius)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 10
0
        void OnHitCollider(Collider other)
        {
            if (null == m_SkEntity)
            {
                return;
            }

            if (null != m_PEEntity && m_PEEntity.IsDeath())
            {
                return;
            }

            SkEntity hitEntity = other.gameObject.GetComponentInParent <SkEntity>();

            bool isTerrain = PETools.PEUtil.IsVoxelOrBlock45(hitEntity);

            if (null == hitEntity || m_HitEntitys.Contains(hitEntity) || (!isTerrain && !PETools.PEUtil.CanDamage(m_SkEntity, hitEntity)))
            {
                return;
            }
            m_HitEntitys.Add(hitEntity);

            PECapsuleHitResult result = null;
            bool  getpos = false;
            float minDis = 100f;

            PECapsuleHitResult findResult;

            for (int i = 0; i < attackParts.Length; i++)
            {
                if (!attackParts[i].capsule.enable)
                {
                    continue;
                }
                if (attackParts[i].capsule.GetClosestPos(other.transform.position, out findResult))
                {
                    result = findResult;
                    result.selfAttackForm = attackParts[i].attackForm;
                    result.hitTrans       = other.transform;
                    result.damageScale    = 1f;
                    return;
                }
                else if (findResult.distance < minDis)
                {
                    minDis                = findResult.distance;
                    result                = findResult;
                    result.hitTrans       = other.transform;
                    result.selfAttackForm = attackParts[i].attackForm;
                    result.damageScale    = 1f;
                    getpos                = true;
                }
            }

            if (getpos)
            {
                m_SkEntity.CollisionCheck(result);

                if (null != onHitSkEntity)
                {
                    onHitSkEntity(hitEntity);
                }
            }
        }
Esempio n. 11
0
 bool Match(PeEntity entity, Vector3 pos, float radius, bool isDeath)
 {
     if (entity != null)
     {
         return(PETools.PEUtil.SqrMagnitudeH(entity.position, pos) <= (radius + entity.maxRadius) * (radius + entity.maxRadius) && entity.IsDeath() == isDeath);
     }
     else
     {
         return(false);
     }
 }