예제 #1
0
    public void AddRareItmeResult(Vector3 pos, Quaternion rot, int templateId, int[] itemIdNum, string path)
    {
        //3. new & add
        RandomItemObj rio = new RandomItemObj(templateId, pos, rot, itemIdNum, path);

        rio.AddRareProto(DunItemId.UNFINISHED_ISO, 1);
        mRandomItemsDic[rio.position] = rio;
        if (Application.isEditor)
        {
            Debug.LogError("<color=yellow>A Rare RandomItem is Added!" + pos + " </color>");
        }
    }
예제 #2
0
    public void TryGenRareItem(Vector3 pos, int boxId, System.Random rand = null, List <ItemIdCount> specifiedItems = null)
    {
        if (ContainsPos(pos))
        {
            return;
        }

        string             path;
        List <ItemIdCount> itemIdNum = RandomItemDataMgr.GenItemDicByBoxId(boxId, out path, rand);

        if (itemIdNum == null)
        {
            Debug.LogError("boxId error: " + boxId);
            itemIdNum.Add(new ItemIdCount(1, 1));
        }
        if (specifiedItems != null)
        {
            itemIdNum.AddRange(specifiedItems);
        }
        List <ItemIdCount> invalidList = itemIdNum.FindAll(it => it.protoId <= 0 || it.count <= 0 || ItemAsset.ItemProto.Mgr.Instance.Get(it.protoId) == null);

        if (invalidList != null && invalidList.Count > 0)
        {
            foreach (ItemIdCount idcount in invalidList)
            {
                Debug.LogError("randomItem error:" + idcount.protoId + " " + idcount.count);
                itemIdNum.Remove(idcount);
            }
        }

        int[] items = new int[itemIdNum.Count * 2];
        int   index = 0;

        foreach (ItemIdCount item in itemIdNum)
        {
            items[index++] = item.protoId;
            items[index++] = item.count;
        }

        RandomItemObj rio = new RandomItemObj(boxId, pos, items, path);

        if (pos.y >= 0)
        {
            AddToAllItems(rio);
            AddToIndex256(rio);
        }
        rio.AddRareProto(DunItemId.UNFINISHED_ISO, 5);
        mRandomItemsDic.Add(pos, rio);
        RandomDungenMgrData.AddRareItem(rio);
    }