Exemple #1
0
    // 采集条出发 真正删除物品
    public void SafeDeleteItem()
    {
        if (m_ItemObjToRemove)
        {
            if (m_MissionID >= 0)
            {
                Tab_MissionBase MissionTab = TableManager.GetMissionBaseByID(m_MissionID, 0);
                if (MissionTab == null)
                {
                    return;
                }
                if (MissionTab.LogicType != (int)TableType.Table_CollectItem)
                {
                    return;
                }
                Tab_MissionCollectItem CItem = TableManager.GetMissionCollectItemByID(MissionTab.LogicID, 0);
                if (CItem == null)
                {
                    LogModule.ErrorLog("Can not find missionCollectItem {0}", MissionTab.LogicID);
                    return;
                }
                GameObject gItemObj = Singleton <ObjManager> .GetInstance().FindOtherGameObj(m_ItemObjToRemove.name);

                if (gItemObj)
                {
                    Obj_OtherGameObj otherGameObj = gItemObj.GetComponent <Obj_OtherGameObj>();
                    if (otherGameObj && otherGameObj.GetIntParamByIndex(0) == CItem.CharModelID)
                    {
                        int nParam = GameManager.gameManager.MissionManager.GetMissionParam(m_MissionID, 0);
                        if (nParam >= CItem.ItemCount)
                        {
                            return;
                        }
                        nParam += 1;
                        GameManager.gameManager.MissionManager.SetMissionParam(m_MissionID, 0, nParam);
                        if (nParam >= CItem.ItemCount)
                        {
                            GameManager.gameManager.MissionManager.SetMissionState(m_MissionID, 2);
                        }

                        // 移除 隐藏处理
                        gItemObj.SetActive(false);
                        m_ItemObjToRemove = null;
                        m_MissionID       = -1;

                        ReSeedItemEvent(GameManager.gameManager.RunningScene, otherGameObj.GetIntParamByIndex(1), otherGameObj.GetIntParamByIndex(2));
                    }
                }
            }
        }
    }
Exemple #2
0
    // 开始从场景中移除物品
    public void RemoveItem(GameObject ItemObj)
    {
        if (ItemObj)
        {
            // 玩家任务检测
            List <int> nMissionIDList = GameManager.gameManager.MissionManager.GetAllMissionID();
            int        nMissionCount  = nMissionIDList.Count;
            if (nMissionCount <= 0)
            {
                return;
            }
            int nBornMonster = 0;
            // 遍历任务
            foreach (int nMissionID in nMissionIDList)
            {
                Tab_MissionBase MissionTab = TableManager.GetMissionBaseByID(nMissionID, 0);
                if (MissionTab == null)
                {
                    continue;
                }
                if (MissionTab.LogicType != (int)TableType.Table_CollectItem)
                {
                    continue;
                }

                // 任务状态 已完成
                if (2 == GameManager.gameManager.MissionManager.GetMissionState(nMissionID))
                {
                    continue;
                }

                Tab_MissionCollectItem CItem = TableManager.GetMissionCollectItemByID(MissionTab.LogicID, 0);
                if (CItem == null)
                {
                    LogModule.ErrorLog("Can not find missionCollectItem {0}", MissionTab.LogicID);
                    continue;
                }

                GameObject gItemObj = Singleton <ObjManager> .GetInstance().FindOtherGameObj(ItemObj.name);

                if (gItemObj)
                {
                    Obj_OtherGameObj otherGameObj = gItemObj.GetComponent <Obj_OtherGameObj>();
                    if (otherGameObj && otherGameObj.GetIntParamByIndex(0) == CItem.CharModelID)
                    {
                        m_MissionID  = nMissionID;
                        nBornMonster = otherGameObj.GetIntParamByIndex(3);
                    }
                    break;
                }
            }

            // 无任务
            if (m_MissionID < 0)
            {
                return;
            }

            if (nBornMonster > 0)
            {
                CG_ASK_COLLECTBORNMONSTER packet = (CG_ASK_COLLECTBORNMONSTER)PacketDistributed.CreatePacket(MessageID.PACKET_CG_ASK_COLLECTBORNMONSTER);
                if (packet != null)
                {
                    packet.Id = nBornMonster;
                    packet.SendPacket();
                }
            }

            m_ItemObjToRemove = ItemObj;
            GameManager.gameManager.SoundManager.PlaySoundEffect(9);        //collect
            // 通知采集条
            UIManager.ShowUI(UIInfo.CollectItemSlider);
        }
    }