Example #1
0
 public void AddItemToManager(RandomItemObj rio)
 {
     if (!mRandomItemsDic.ContainsKey(rio.position))
     {
         mRandomItemsDic.Add(rio.position, rio);
     }
 }
Example #2
0
    //public void InitData(object sender, PeCreature.MainPlayerCreatedArg arg)
    //{
    //    if (PeCreature.Instance.mainPlayer != null)
    //    {
    //        playerTrans = PeCreature.Instance.mainPlayer.peTrans;
    //        born_pos = playerTrans.position;
    //        Debug.LogError("born_pos" + born_pos);
    //        start_pos = born_pos;
    //        last_pos = start_pos;
    //        last_time = timeCounter;

    //    }
    //}

    #region RandomItem func
    public void TryGenItem(Vector3 pos, int boxId, System.Random rand = null)
    {
        if (ContainsPos(pos))
        {
            return;
        }
        //--to do:

        //test
        if (PeGameMgr.IsMulti)
        {
            PlayerNetwork.mainPlayer.RPCServer(EPacketType.PT_InGame_RandomItem, pos, boxId);
        }
        else
        {
            //3. new & add
            string             path;
            List <ItemIdCount> itemIdNum = RandomItemDataMgr.GenItemDicByBoxId(boxId, out path, rand);
            if (itemIdNum == null)
            {
                Debug.LogError("boxId error: " + boxId);
                return;
            }
            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);
                }
            }
            if (itemIdNum.Count == 0)
            {
                Debug.LogError("empty boxId:" + boxId);
                return;
            }
            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);
            }
            mRandomItemsDic.Add(pos, rio);
            //if(Application.isEditor)
            //    Debug.Log("<color=yellow>A RandomItem is Added!"+pos+"id:"+ boxId+"path:"+path+" </color>");
        }
    }
Example #3
0
    void RPC_S2C_RandomItemDestroy(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        Vector3       pos   = stream.Read <Vector3>();
        RandomItemObj riObj = RandomItemMgr.Instance.GetRandomItemObj(pos);

        if (riObj == null)
        {
            return;
        }
        riObj.DestroySelf();
    }
Example #4
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>");
        }
    }
Example #5
0
 void RPC_S2C_RandomItemDestroyList(uLink.BitStream stream, uLink.NetworkMessageInfo info)
 {
     Vector3[] posList = stream.Read <Vector3[]>();
     foreach (Vector3 pos in posList)
     {
         RandomItemObj riObj = RandomItemMgr.Instance.GetRandomItemObj(pos);
         if (riObj == null)
         {
             return;
         }
         riObj.DestroySelf();
     }
 }
Example #6
0
    //new fetch
    void RPC_S2C_RandomItemClicked(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        Vector3 pos = stream.Read <Vector3>();

        int[]         itemIdCount = stream.Read <int[]>();
        RandomItemObj riObj       = RandomItemMgr.Instance.GetRandomItemObj(pos);

        if (riObj == null)
        {
            return;
        }
        riObj.ClickedInMultiMode(itemIdCount);
    }
Example #7
0
    public void AddFeces(RandomItemObj rio)
    {
        if (!mRandomItemsDic.ContainsKey(rio.position))
        {
            mRandomItemsDic.Add(rio.position, rio);

            IntVector2 index256 = new IntVector2(Mathf.RoundToInt(rio.position.x) >> 8, Mathf.RoundToInt(rio.position.z) >> 8);
            if (!index256Feces.ContainsKey(index256))
            {
                index256Feces[index256] = new List <RandomItemObj>();
            }
            index256Feces[index256].Add(rio);
        }
    }
Example #8
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);
    }
Example #9
0
    public void AddItmeResult(Vector3 pos, Quaternion rot, int templateId, int[] itemIdNum, string path)
    {
        //3. new & add
        RandomItemObj rio = new RandomItemObj(templateId, pos, rot, itemIdNum, path);

        if (rio.Pos.y > 0)
        {
            AddToAllItems(rio);
            AddToIndex256(rio);
        }
        mRandomItemsDic[rio.position] = rio;
        //if (Application.isEditor)
        //    Debug.Log("<color=yellow>A RandomItem is Added!" + pos + " </color>");
    }
Example #10
0
 public void AddToAllItems(RandomItemObj rio)
 {
     if (!allRandomItems.ContainsKey(rio.boxId))
     {
         allRandomItems.Add(rio.boxId, new List <RandomItemObj> ()
         {
             rio
         });
     }
     else
     {
         allRandomItems[rio.boxId].Add(rio);
     }
 }
Example #11
0
    void RPC_S2C_RandomIsoObj(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        Vector3       rioPos        = stream.Read <Vector3>();
        int           objInstanceId = stream.Read <int>();
        RandomItemObj rio           = RandomItemMgr.Instance.GetRandomItemObj(rioPos);

        if (rio != null)
        {
            rio.AddRareInstance(objInstanceId);
            if (Application.isEditor)
            {
                Debug.LogError("<color=yellow>A Rare RandomItem is Ready!" + rioPos + " </color>");
            }
        }
    }
Example #12
0
    void RPC_S2C_RandomItemFetchAll(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        Vector3       pos   = stream.Read <Vector3>();
        RandomItemObj riObj = RandomItemMgr.Instance.GetRandomItemObj(pos);

        if (riObj == null)
        {
            return;
        }
        riObj.TryFetchAll();
        if (GameUI.Instance.mItemGet != null)
        {
            GameUI.Instance.mItemGet.Reflash();
        }
    }
Example #13
0
    public void AddToIndex256(RandomItemObj rio)
    {
        IntVector2 index256 = new IntVector2(Mathf.RoundToInt(rio.position.x) >> 8, Mathf.RoundToInt(rio.position.z) >> 8);

        if (!index256Items.ContainsKey(index256))
        {
            index256Items.Add(index256, new List <RandomItemObj>()
            {
                rio
            });
        }
        else
        {
            index256Items[index256].Add(rio);
        }
    }
 public void CheckDestroyObj()
 {
     if (_itemList.Count <= 0)
     {
         if (gameObject != null)
         {
             RandomItemObj rio = RandomItemMgr.Instance.GetRandomItemObj(genPos);
             if (rio != null)
             {
                 RandomItemMgr.Instance.RemoveRandomItemObj(rio);
                 SceneMan.RemoveSceneObj(rio);
             }
             GameObject.Destroy(gameObject);
         }
     }
 }
Example #15
0
 void DestroySelf()
 {
     if (gameObject != null)
     {
         RandomItemObj rio = RandomItemMgr.Instance.GetRandomItemObj(genPos);
         if (rio != null)
         {
             if (rio.type == RandomObjType.MonsterFeces)
             {
                 Pathea.Effect.EffectBuilder.Instance.Register(EffectId.PICK_FECES, null, transform.position, Quaternion.identity);
             }
             RandomItemMgr.Instance.RemoveRandomItemObj(rio);
             SceneMan.RemoveSceneObj(rio);
         }
         GameObject.Destroy(gameObject);
     }
 }
Example #16
0
    public void RemoveRandomItemObj(RandomItemObj riObj)
    {
        if (allRandomItems.ContainsKey(riObj.boxId))
        {
            allRandomItems[riObj.boxId].Remove(riObj);
        }

        IntVector2 index256 = new IntVector2(Mathf.RoundToInt(riObj.Pos.x) >> 8, Mathf.RoundToInt(riObj.Pos.z) >> 8);

        if (index256Items.ContainsKey(index256))
        {
            index256Items[index256].Remove(riObj);
        }

        if (index256Feces.ContainsKey(index256))
        {
            index256Feces[index256].Remove(riObj);
        }
        mRandomItemsDic.Remove(riObj.Pos);
    }
 public static void AddRareItem(RandomItemObj rio)
 {
     rareRandomItem.Add(rio);
 }