Ejemplo 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);
                }
            }
        }
    }
Ejemplo n.º 2
0
        BehaveResult Tick(Tree sender)
        {
            if (bReached && Time.time - m_Data.startLootTime > m_Data.lootTime)
            {
                mLootEntity = null;
                bReached    = false;
                EndAction(PEActionType.Leisure);
            }

            if (!bReached && mLootEntity == null)
            {
                if (!Enemy.IsNullOrInvalid(attackEnemy))
                {
                    return(BehaveResult.Failure);
                }

                List <PeEntity> entities = LootItemDropPeEntity.GetEntities(position, m_Data.LootRadius);
                if (entities.Count > 0)
                {
                    mLootEntity = LootItemDropPeEntity.GetLootEntity(position, m_Data.LootRadius);
                    mItemDrop   = mLootEntity.GetComponent <ItemDropPeEntity>();
                    if (mItemDrop == null || !mItemDrop.NpcCanFetchAll(entity.NpcCmpt.NpcPackage))
                    {
                        return(BehaveResult.Failure);
                    }

                    LootItemDropPeEntity.RemovePeEntity(mLootEntity);
                }
                else
                {
                    return(BehaveResult.Failure);
                }
            }

            if (!bReached)
            {
                if (IsReached(position, mLootEntity.peTrans.position, false, 1.0f) || Stucking())
                {
                    StopMove();
                    FaceDirection(mLootEntity.peTrans.position - position);

                    PEActionParamS param = PEActionParamS.param;
                    param.str = "Gather";
                    DoAction(PEActionType.Leisure, param);
                    mItemDrop.NpcFetchAll(entity.NpcCmpt.NpcPackage);
                    m_Data.startLootTime = Time.time;
                    bReached             = true;
                }
                else
                {
                    MoveToPosition(mLootEntity.peTrans.position, SpeedState.Run);
                }
            }

            return(BehaveResult.Running);
        }
Ejemplo n.º 3
0
    void OnEntityDestroy(SkEntity entity)
    {
        PeEntity peEntity = entity.GetComponent <PeEntity>();

        if (peEntity != null)
        {
            LootItemDropPeEntity.RemovePeEntity(peEntity);
            PeCreature.Instance.Destory(peEntity.Id);
        }
    }