Esempio n. 1
0
    void OnEntityPickup(SkEntity entity)
    {
        CommonCmpt common = entity.GetComponent <CommonCmpt>();

        if (common != null)
        {
            if (common.entityProto.proto == EEntityProto.RandomNpc || common.entityProto.proto == EEntityProto.Npc)
            {
                if (!ServantLeaderCmpt.Instance.ContainsServant(common.GetComponent <NpcCmpt>()))
                {
                    DestroyEntity(entity);
                }
            }
            else             //if (common.entityProto.proto == EEntityProto.Monster)
            {
                DestroyEntity(entity);

                PeEntity Pentity = entity.GetComponent <PeEntity>();
                if (Pentity != null)
                {
                    LootItemDropPeEntity.RemovePeEntity(Pentity);
                }
            }
        }
    }
Esempio n. 2
0
    IEnumerator NpcRevive(SkEntity entity, float delayTime)
    {
        if (Pathea.PeGameMgr.IsMulti)
        {
            yield break;
        }

        PeEntity peentity = entity.GetComponent <PeEntity>();

        if (peentity == null)
        {
            yield break;
        }

        EntityInfoCmpt InfoCmpt = peentity.enityInfoCmpt;

        InfoCmpt.SetDelaytime(Time.time, delayTime);

        PESkEntity skentity = peentity.peSkEntity;

        yield return(new WaitForSeconds(delayTime));

        if (entity != null && skentity != null && skentity.isDead)
        {
            MotionMgrCmpt motion = entity.GetComponent <MotionMgrCmpt>();
            if (motion != null)
            {
                while (true)
                {
                    if (null == peentity || null == motion)
                    {
                        yield break;
                    }
                    //在复活中被任务设置成不能复活 ReviveTime = -1
                    if (peentity.NpcCmpt.ReviveTime < 0)
                    {
                        break;
                    }

                    PEActionParamB param = PEActionParamB.param;
                    param.b = false;
                    if (motion.DoAction(PEActionType.Revive, param))
                    {
                        entity.SetAttribute((int)AttribType.Hp, entity.GetAttribute((int)AttribType.HpMax) * 0.8f);
                        break;
                    }
                    else
                    {
                        yield return(new WaitForSeconds(1));
                    }
                }
            }
        }
    }
Esempio n. 3
0
        protected virtual void Hit(Vector3 pos, Vector3 normal, Transform hitTrans)
        {
            PlayEffectHit(pos, normal);

            if (!m_Trigger)
            {
                Delete();
            }

            if (hitTrans != null)
            {
                SkEntity skEntity = hitTrans.GetComponentInParent <SkEntity>();
                if (null == skEntity)
                {
                    return;
                }
                PeEntity entity = skEntity.GetComponent <PeEntity>();
                if (null != skEntity && (null == entity || entity.canInjured))
                {
                    PECapsuleHitResult hitResult = new PECapsuleHitResult();
                    hitResult.selfTrans   = transform;
                    hitResult.hitPos      = pos;
                    hitResult.hitDir      = -normal;
                    hitResult.hitTrans    = hitTrans;
                    hitResult.damageScale = 1f;
                    CastSkill(skEntity, hitResult);
                }
            }
        }
Esempio n. 4
0
        protected virtual void Hit(PECapsuleHitResult hitResult, SkEntity skEntity = null)
        {
            PlayEffectHit(hitResult.hitPos, -hitResult.hitDir);

            if (!m_Trigger)
            {
                Delete();
            }

            if (hitResult.hitTrans != null)
            {
                if (null == skEntity)
                {
                    skEntity = hitResult.hitTrans.GetComponentInParent <SkEntity>();
                }
                if (null == skEntity)
                {
                    return;
                }
                PeEntity entity = skEntity.GetComponent <PeEntity>();
                if (null == entity || entity.canInjured)
                {
                    CastSkill(skEntity, hitResult);
                }
            }
        }
Esempio n. 5
0
        void OnDamage(SkEntity entity, float damage)
        {
            if (null == Entity.peSkEntity || null == entity)
            {
                return;
            }

            PeEntity peEntity = entity.GetComponent <PeEntity>();

            if (peEntity == Entity)
            {
                return;
            }

            float tansDis  = peEntity.IsBoss ? 128f : 64f;
            int   playerID = (int)Entity.peSkEntity.GetAttribute((int)AttribType.DefaultPlayerID);

            bool canTrans = false;

            if (GameConfig.IsMultiClient)
            {
                if (ForceSetting.Instance.GetForceType(playerID) == EPlayerType.Human)
                {
                    canTrans = true;
                }

                int tarPlayerId = (int)peEntity.GetAttribute(AttribType.DefaultPlayerID);
                if (ForceSetting.Instance.GetForceType(tarPlayerId) == EPlayerType.Human)
                {
                    List <PeEntity> entities = EntityMgr.Instance.GetEntities(peEntity.position, tansDis, tarPlayerId, false, peEntity);
                    for (int i = 0; i < entities.Count; i++)
                    {
                        if (!entities[i].Equals(Entity) && entities[i].target != null)
                        {
                            entities[i].target.TransferHatred(Entity, damage);
                        }
                    }
                }
            }
            else
            {
                if (ForceSetting.Instance.GetForceID(playerID) == 1)
                {
                    canTrans = true;
                }
            }

            if (canTrans)
            {
                List <PeEntity> entities = EntityMgr.Instance.GetEntities(Entity.peTrans.position, tansDis, playerID, false, Entity);
                for (int i = 0; i < entities.Count; i++)
                {
                    if (!entities[i].Equals(Entity) && entities[i].target != null)
                    {
                        entities[i].target.TransferHatred(peEntity, damage);
                    }
                }
            }
        }
 void OnOwnerAttack(SkEntity enemy, float value)
 {
     if (enemy is SkAliveEntity && !enemy.Equals(null))
     {
         _ownerAttackEntity = enemy as SkAliveEntity;
         _ownerAttackView   = enemy.GetComponent <ViewCmpt>();
     }
 }
Esempio n. 7
0
        void OnAttack(SkEntity skEntity, float damage)
        {
            PeEntity tarEntity = skEntity.GetComponent <PeEntity>();

            if (tarEntity != null && tarEntity != Entity)
            {
                NpcHatreTargets.Instance.TryAddInTarget(Entity, tarEntity, damage);
            }
        }
 void OnOwnerHpReduce(SkEntity enemy, float value)
 {
     enemy = PETools.PEUtil.GetCaster(enemy);
     if (enemy is SkAliveEntity && !enemy.Equals(null))
     {
         _attackOwnerEntity = enemy as SkAliveEntity;
         _attackOwnerView   = enemy.GetComponent <ViewCmpt>();
     }
 }
Esempio n. 9
0
    void OnEntityDestroy(SkEntity entity)
    {
        PeEntity peEntity = entity.GetComponent <PeEntity>();

        if (peEntity != null)
        {
            LootItemDropPeEntity.RemovePeEntity(peEntity);
            PeCreature.Instance.Destory(peEntity.Id);
        }
    }
Esempio n. 10
0
    void OnEntityRevive(SkEntity entity)
    {
        CommonCmpt common = entity.GetComponent <CommonCmpt>();

        if (common != null)
        {
            if (common.entityProto.proto == EEntityProto.Npc || common.entityProto.proto == EEntityProto.RandomNpc)
            {
                ReviveEntity(entity, 0.0f);
            }
        }
    }
Esempio n. 11
0
    private void ProcDigB45s(SkEntity caster)
    {
        SkInst      inst       = SkRuntimeInfo.Current as SkInst;
        IDigTerrain digTerrain = caster as IDigTerrain;
        IntVector4  digPos     = null;

        if (null == digTerrain || (digPos = digTerrain.digPosType) == IntVector4.Zero || (inst != null && !(inst._target is Block45Man)))
        {
            return;
        }

        float damage = caster.GetAttribute((int)AttribType.Atk);
        float radius = caster.GetAttribute((int)AttribType.ResRange);
        float height = caster.GetAttribute((int)AttribType.ResRange);
        //		float resourceBonus = caster.GetAttribute((int)AttribType.ResBouns);
        //		bool returnResource = digPos.w == 1;

        PeEntity entity = caster != null?caster.GetComponent <PeEntity>() : null;

        if (entity != null && entity.monster != null)
        {
            radius = entity.bounds.extents.x + 1;
            height = entity.bounds.extents.y + 1;
        }

        if (null != inst && null != inst._colInfo)
        {
            int effecID = 0;
            if (radius < 3)
            {
                effecID = 258;
            }
            else if (radius < 5f)
            {
                effecID = 259;
            }
            else
            {
                effecID = 260;
            }
            Pathea.Effect.EffectBuilder.Instance.Register(effecID, null, inst._colInfo.hitPos, Quaternion.identity);
        }

        if (!GameConfig.IsMultiMode)
        {
            List <B45Block> removeList = new List <B45Block>();
            DigTerrainManager.DigBlock45(digPos.ToIntVector3(), damage * 0.2f, radius, height, ref removeList, false);
        }
        else
        {
            /// TODO : code for multiplayer
        }
    }
Esempio n. 12
0
 void Start()
 {
     for (int i = 0; i < attackParts.Length; i++)
     {
         attackParts[i].Init();
     }
     m_SkEntity = GetComponentInParent <SkEntity>();
     if (null != m_SkEntity)
     {
         m_PEEntity = m_SkEntity.GetComponent <PeEntity>();
     }
     active = false;
 }
Esempio n. 13
0
        void OnSkillTarget(SkEntity caster)
        {
            if (null == Entity.peSkEntity || null == caster)
            {
                return;
            }

            int playerID = (int)Entity.peSkEntity.GetAttribute((int)AttribType.DefaultPlayerID);
            //SkEntity Ca_entity = PETools.PEUtil.GetCaster(caster);
            PeEntity peEntity = caster.GetComponent <PeEntity>();

            if (peEntity == Entity)
            {
                return;
            }

            float tansDis  = peEntity.IsBoss ? 128f : 64f;
            bool  canTrans = false;

            if (GameConfig.IsMultiClient)
            {
                if (ForceSetting.Instance.GetForceType(playerID) == EPlayerType.Human)
                {
                    canTrans = true;
                }
            }
            else
            {
                if (ForceSetting.Instance.GetForceID(playerID) == 1)
                {
                    canTrans = true;
                }
            }

            if (canTrans)
            {
                List <PeEntity> entities = EntityMgr.Instance.GetEntities(Entity.peTrans.position, tansDis, playerID, false, Entity);
                for (int i = 0; i < entities.Count; i++)
                {
                    if (entities[i] == null)
                    {
                        continue;
                    }

                    if (!entities[i].Equals(Entity) && entities[i].target != null)
                    {
                        entities[i].target.OnTargetSkill(peEntity.skEntity);
                    }
                }
            }
        }
Esempio n. 14
0
        void OnDamage(SkEntity entity, float damage)
        {
            if (null == m_Skill || null == entity)
            {
                return;
            }

            PeEntity peEntity = entity.GetComponent <PeEntity>();

            if (peEntity == Entity)
            {
                return;
            }

            TransferHared(peEntity, damage);
        }
Esempio n. 15
0
        void OnDamage(SkEntity entity, float damage)
        {
            if (null == Entity.peSkEntity || null == entity)
            {
                return;
            }

            PeEntity peEntity = entity.GetComponent <PeEntity>();

            if (peEntity == Entity)
            {
                return;
            }

            NpcHatreTargets.Instance.TryAddInTarget(Entity, peEntity, damage, true);
        }
Esempio n. 16
0
    IEnumerator DestroyEnumerator(SkEntity entity, float delayTime, float fadeoutTime = 3.0f)
    {
        yield return(new WaitForSeconds(delayTime));

        if (entity != null)
        {
            ViewCmpt view = entity.GetComponent <ViewCmpt>();

            if (view != null)
            {
                if (view is BiologyViewCmpt)
                {
                    (view as BiologyViewCmpt).Fadeout(fadeoutTime);
                    yield return(new WaitForSeconds(fadeoutTime));
                }
            }

            if (entity != null)
            {
                GameObject.Destroy(entity.gameObject);
                PeEventGlobal.Instance.DestroyEvent.Invoke(entity);
            }
        }
    }
Esempio n. 17
0
        void OnAttack(SkEntity skEntity, float damage)
        {
            PeEntity tarEntity = skEntity.GetComponent <PeEntity>();

            TransferHared(tarEntity, damage);
        }
Esempio n. 18
0
    void OnEntityDeath(SkEntity entity, SkEntity caster)
    {
        CommonCmpt common = entity.GetComponent <CommonCmpt>();

        if (common != null)
        {
            if (common.entityProto.proto == EEntityProto.Doodad)
            {
                DestroyEntity(entity, 30.0f);
            }

            if (common.entityProto.proto == EEntityProto.Monster)
            {
                MonsterHandbookData.AddMhByKilledMonsterID(common.entityProto.protoId);
                if (common.GetComponent <TowerCmpt>() == null)
                {
                    float    reviveTime = 10;
                    PeEntity mon        = entity.GetComponent <PeEntity>();
                    if (mon != null)
                    {
                        if (StroyManager.Instance != null)
                        {
                            if (StroyManager.Instance.m_RecordKillMons.Count != 0)
                            {
                                foreach (var item in StroyManager.Instance.m_RecordKillMons.Values)
                                {
                                    if (item.type == KillMons.Type.fixedId && SceneEntityCreatorArchiver.Instance.GetEntityByFixedSpId(item.monId) == mon)
                                    {
                                        reviveTime = (item.reviveTime == 0 ? reviveTime : item.reviveTime);
                                        break;
                                    }
                                    else if (item.type == KillMons.Type.protoTypeId && Vector3.Distance(mon.position, item.center) <= item.radius &&
                                             (item.monId == -999 ? true : common.entityProto.protoId == item.monId))
                                    {
                                        reviveTime = (item.reviveTime == 0 ? reviveTime : item.reviveTime);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    DestroyEntity(entity, reviveTime);
                }
            }

            NpcCmpt npc = entity.GetComponent <NpcCmpt>();
            if (common.entityProto.proto == EEntityProto.Npc)
            {
                if (GameUI.Instance != null)
                {
                    if (GameUI.Instance.mNpcWnd.IsOpen() && GameUI.Instance.mNpcWnd.m_CurSelNpc.commonCmpt == common)
                    {
                        GameUI.Instance.mNpcWnd.Hide();
                    }
                }
                if (npc != null && npc.Type != ENpcType.Follower && npc.ReviveTime > 0)
                {
                    ReviveEntity(entity, 10.0f);
                }
                if (npc.ReviveTime <= 0)
                {
                    PeEntity npcentity = npc.GetComponent <PeEntity>();
                    if (MissionManager.Instance != null && MissionManager.Instance.m_PlayerMission != null)
                    {
                        MissionManager.Instance.m_PlayerMission.SetMissionState(npcentity, NpcMissionState.Max);
                    }

                    NpcMissionData missionData = npcentity.GetUserData() as NpcMissionData;
                    if (missionData != null)
                    {
                        missionData.m_MissionList.Clear();
                    }
                }
            }
            else if (common.entityProto.proto == EEntityProto.RandomNpc)
            {
                if (npc != null && !npc.IsServant)
                {
                    if (npc.ReviveTime > 0)
                    {
                        if (PeGameMgr.IsMultiStory)
                        {
                            if (entity._net is AiAdNpcNetwork)
                            {
                                int tempid            = ((AiAdNpcNetwork)(entity._net)).ExternId;
                                RandomNpcDb.Item item = RandomNpcDb.Get(tempid);
                                if (item != null)
                                {
                                    if (item.reviveTime != -1)
                                    {
                                        ReviveEntity(entity, item.reviveTime);
                                    }
                                }
                            }
                        }
                        else
                        {
                            ReviveEntity(entity, npc.ReviveTime);
                        }
                    }
                }

                //follower revive
//				if (npc != null && npc.IsServant)
//				{
//					ReviveEntity(entity, npc.ReviveTime + npc.FollowerReviceTime);
//				}
            }
        }
    }