void ApplyPackDropItem(List <DropItemInfo> itemList)
    {
        //lz-2017.01.03 crash bug 错误 #8002
        if (null == itemList)
        {
            return;
        }
        if (null == GameUI.Instance || null == GameUI.Instance.mMainPlayer)
        {
            return;
        }

        Pathea.SkAliveEntity skEntity = GameUI.Instance.mMainPlayer.GetCmpt <Pathea.SkAliveEntity>();
        if (skEntity == null || null == skEntity.Entity)
        {
            return;
        }

        mDropReq.Clear();
        foreach (DropItemInfo itemInfo in itemList)
        {
            if (null != itemInfo && null != itemInfo.mDropItemObj)
            {
                mDropReq.Add(itemInfo.mDropItemObj.instanceId);
            }
        }
        MapObj[]   mapObjs = new MapObj[1];
        RaycastHit hitInfo;
        int        count = 0;

        while (count++ < 100)
        {
            if (skEntity.Entity)
            {
                Vector3 offsetPos = new Vector3(Random.Range(-2f, 2f), 2f, Random.Range(-2f, 2f));
                if (Physics.Raycast(skEntity.Entity.position + offsetPos, Vector3.down, out hitInfo, 10f, mItemDroplayer))
                {
                    if (!hitInfo.collider.isTrigger && hitInfo.distance < 10f)
                    {
                        mapObjs[0]       = new MapObj();
                        mapObjs[0].pos   = hitInfo.point;
                        mapObjs[0].objID = skEntity.GetId();
                        break;
                    }
                }
            }
        }
        if (mapObjs[0] != null)
        {
            PlayerNetwork.mainPlayer.CreateMapObj((int)DoodadType.DoodadType_Drop, mapObjs);
        }
    }
Exemple #2
0
    public ItemBox AddItemMultiPlay(int id, int opID, Vector3 pos, MapObjNetwork netWork = null)
    {
        ItemBox newBox = CreateItemBox();

        newBox.transform.parent = transform;
        newBox.mID           = id;
        newBox.mPos          = pos;
        newBox.mNetWork      = netWork;
        mItemBox[newBox.mID] = newBox;

        if (null != Pathea.PeCreature.Instance.mainPlayer)
        {
            Pathea.SkAliveEntity sk = GameUI.Instance.mMainPlayer.GetCmpt <Pathea.SkAliveEntity>();
            if (sk != null)
            {
                if (opID == sk.GetId())
                {
                    newBox.InsertItem(mDropReq);
                    mDropReq.Clear();
                }
            }
        }
        return(newBox);
    }