Example #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);
                }
            }
        }
    }
    void OnMonsterDeath(SkEntity cur, SkEntity caster)
    {
        if (_data.m_mustByPlayer == true && caster is Pathea.Projectile.SkProjectile)
        {
            GameObject go = ((Pathea.Projectile.SkProjectile)caster).Caster();
            if (go != null)
            {
                CommonCmpt cc = go.GetComponent <CommonCmpt>();
                if (cc != null && cc.entityProto.proto != EEntityProto.Player)
                {
                    return;
                }
            }
        }
        SkAliveEntity skAlive = cur as SkAliveEntity;

        if (skAlive != null && _data != null)
        {
            CommonCmpt cc = skAlive.Entity.commonCmpt;
            if (cc == null)
            {
                return;
            }

            int  protoId = cc.entityProto.protoId;
            bool bFin    = true;
            for (int m = 0; m < _data.m_MonsterList.Count; m++)
            {
                int      idx     = _idxTarId * 10 + m;
                string   tmp     = PlayerMission.MissionFlagMonster + idx;
                string   value   = playerMission.GetQuestVariable(MissionId, tmp);
                string[] tmplist = value.Split('_');
                if (tmplist.Length < 2)
                {
                    Debug.LogError("[TaskMonsterKill]:Wrong Quest Var:" + value);
                }
                int num = tmplist.Length >= 2 ? Convert.ToInt32(tmplist[1]) : 0;
                if (_data.m_MonsterList[m].npcs.Contains(protoId))
                {
                    num  += 1;
                    value = tmplist[0] + "_" + num.ToString();
                    playerMission.ModifyQuestVariable(MissionId, tmp, value);
                }
                if (num < _data.m_MonsterList[m].type)
                {
                    bFin = false;
                }
            }

            if (bFin)
            {
                MissionManager.Instance.CompleteTarget(TargetId, MissionId, true);
            }
        }
    }
Example #3
0
            public static bool IsInvincible(this PeEntity entity)
            {
                CommonCmpt c = entity.GetCmpt <CommonCmpt>();

                if (c == null)
                {
                    return(false);
                }

                return(c.invincible);
            }
Example #4
0
            public static void SetInvincible(this PeEntity entity, bool value)
            {
                CommonCmpt c = entity.GetCmpt <CommonCmpt>();

                if (c == null)
                {
                    return;
                }

                c.invincible = value;
            }
Example #5
0
            public static void ExtSetSex(this PeEntity entity, PeSex sex)
            {
                CommonCmpt info = entity.GetCmpt <CommonCmpt>();

                if (null == info)
                {
                    return;
                }

                info.sex = sex;
            }
Example #6
0
            public static PeSex ExtGetSex(this PeEntity entity)
            {
                CommonCmpt info = entity.GetCmpt <CommonCmpt>();

                if (null == info)
                {
                    return(PeSex.Max);
                }

                return(info.sex);
            }
Example #7
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);
            }
        }
    }
 void GetEntityCmpt()
 {
     if (player != GameUI.Instance.mMainPlayer)
     {
         player        = GameUI.Instance.mMainPlayer;
         viewCmpt      = player.biologyViewCmpt;
         commonCmpt    = player.commonCmpt;
         equipmentCmpt = player.equipmentCmpt;
         //packageCmpt = player.GetCmpt<PlayerPackageCmpt>();
         entityInfoCmpt  = player.enityInfoCmpt;
         playerArmorCmpt = player.GetCmpt <WhiteCat.PlayerArmorCmpt>();
     }
 }
Example #9
0
            public static object GetUserData(this PeEntity entity)
            {
                if (entity == null)
                {
                    return(null);
                }
                CommonCmpt c = entity.GetCmpt <CommonCmpt>();

                if (c == null)
                {
                    return(null);
                }

                return(c.userData);
            }
Example #10
0
            public static bool IsRandomNpc(this PeEntity entity)
            {
                if (entity == null)
                {
                    return(false);
                }
                CommonCmpt c = entity.GetCmpt <CommonCmpt>();

                if (c == null)
                {
                    return(false);
                }

                return(c.entityProto.proto == EEntityProto.RandomNpc);
            }
Example #11
0
    void GetServentCmpt()
    {
        if (leaderCmpt != null)
        {
            NpcCmpt cmpt = leaderCmpt.GetServant((int)mCurrentIndex);
            if (cmpt != null && cmpt != npcCmpt)
            {
                viewCmpt    = cmpt.Entity.biologyViewCmpt;
                commonCmpt  = cmpt.Entity.commonCmpt;
                packageCmpt = cmpt.GetComponent <NpcPackageCmpt>();
                GetNpcPakgeSlotList();
                entityInfoCmpt = cmpt.Entity.enityInfoCmpt;

                // register changeEvent
                if (equipmentCmpt != null)
                {
                    equipmentCmpt.changeEventor.Unsubscribe(EquipmentChangeEvent);
                }
                equipmentCmpt = cmpt.Entity.equipmentCmpt;
                equipmentCmpt.changeEventor.Subscribe(EquipmentChangeEvent);
            }
            npcCmpt = cmpt;
            CheckWhtherCanGet();
            servant = (npcCmpt != null) ? npcCmpt.Entity : null;
        }
        else
        {
            npcCmpt = null;
            CheckWhtherCanGet();
        }

        if (npcCmpt == null)
        {
            viewCmpt       = null;
            commonCmpt     = null;
            equipmentCmpt  = null;
            packageCmpt    = null;
            entityInfoCmpt = null;

            mInteractionPackage = null;
            mPrivatePakge       = null;

            mSprSex.spriteName = "null";
            ClearEqList();
            ClearNpcPackage();
        }
        mEqTex.enabled = (npcCmpt != null);
    }
Example #12
0
        void OnMouseClickEntity(object sender, EntityMgr.RMouseClickEntityEvent e)
        {
            if (e.entity == null)
            {
                return;
            }

            CommonCmpt cc = e.entity.commonCmpt;

            if (cc != null && cc.entityProto.proto == EEntityProto.Npc)
            {
                if (GameUI.Instance.mNpcDialog.dialogInterpreter.SetNpoEntity(e.entity))
                {
                    GameUI.Instance.mNpcDialog.Show();
                }
            }
        }
Example #13
0
            public static void SetUserData(this PeEntity entity, object obj)
            {
                if (entity == null)
                {
                    return;
                }
                CommonCmpt c = entity.GetCmpt <CommonCmpt>();

                if (c == null)
                {
                    return;
                }


                c.userData = obj;
                CompatibleMissionData(entity);
            }
 public virtual void OnMonsterCreated(PeEntity e)
 {
     if (e != null)
     {
         CommonCmpt cc = e.GetCmpt <CommonCmpt>();
         if (cc != null)
         {
             cc.TDObj = gameObject;
             cc.TDpos = gameObject.transform.position;
         }
         SkAliveEntity sae = e.GetCmpt <SkAliveEntity>();
         if (sae != null)
         {
             sae.deathEvent += (t, c) => OnMonsterDeath(e);
             sae.SetAttribute(AttribType.DefaultPlayerID, MonsterBeaconPlayerID);
             sae.SetAttribute(AttribType.CampID, MonsterBeaconCampID);
             LodCmpt lc = e.lodCmpt;
             if (e.lodCmpt != null && PeGameMgr.IsSingle && isSweep)
             {
                 e.lodCmpt.onDestroyView = (p) => OnMonsterEdge(lc);
             }
         }
     }
 }
Example #15
0
    public void RequestCreateLootItem(PeEntity entity)
    {
        if (null == entity)
        {
            return;
        }
        if (PeGameMgr.IsMulti)
        {
            return;
        }

        CommonCmpt common = entity.commonCmpt;

        if (common != null)
        {
            List <ItemSample> items = ItemDropData.GetDropItems(common.ItemDropId);
            if (common.entityProto.proto == EEntityProto.Monster)
            {
                if (items == null)
                {
                    items = GetSpecialItem.MonsterItemAdd(common.entityProto.protoId);
                }
                else
                {
                    items.AddRange(GetSpecialItem.MonsterItemAdd(common.entityProto.protoId));                       //特殊道具添加
                }
            }
            if (items != null)
            {
                for (int i = 0; i < items.Count; ++i)
                {
                    AddLootItem(entity.position, items[i].protoId, items[i].stackCount);
                }
            }
        }
    }
Example #16
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);
//				}
            }
        }
    }
Example #17
0
        public void Update()
        {
            if (!m_Valid || Time.time - m_StartTime <= m_DelayTime)
            {
                return;
            }

            m_BoundsUpdated = false;

            CheckCasterAlive();

            if (m_Trajectory != null)
            {
                Vector3    moveVector = m_Trajectory.Track(Time.deltaTime);
                Quaternion rotation   = m_Trajectory.Rotate(Time.deltaTime);

                RaycastHit         hitInfo;
                Transform          hitTrans;
                PECapsuleHitResult hitResult;
                bool useHitResult;
                if (GetRaycastInfo(transform.position, moveVector, out hitInfo, out hitTrans, out hitResult, out useHitResult, GameConfig.ProjectileDamageLayer))
                {
                    if (!m_Explode)
                    {
                        if (!m_Trajectory.rayCast)
                        {
                            moveVector = hitInfo.point - transform.position;
                            if (useHitResult && hitResult.hitTrans != null)
                            {
                                Hit(hitResult);
                            }
                            else
                            {
                                Hit(hitInfo.point, hitInfo.normal, hitTrans);
                            }
                        }

                        if (!m_Trigger)
                        {
                            m_Valid = false;
                        }
                    }
                    else if (m_ExplodeRadius < PETools.PEMath.Epsilon)
                    {
                        Explode();
                        Delete();
                    }
                }

                transform.position     += moveVector;
                transform.rotation      = rotation;
                m_Trajectory.moveVector = moveVector;
            }
            else
            {
                if (m_Explode && m_ExplodeRadius > PETools.PEMath.Epsilon)
                {
                    Collider[] colliders = Physics.OverlapSphere(transform.position, m_ExplodeRadius);
                    for (int i = 0; i < colliders.Length; i++)
                    {
                        CommonCmpt com = colliders[i].GetComponentInParent <CommonCmpt>();
                        if (com != null && com.isPlayerOrNpc)
                        {
                            Explode();
                            Delete();
                            break;
                        }
                    }
                }
            }
        }