Exemplo n.º 1
0
        public GameObject ObtainObject(int iResid)
        {
            if (m_ObjectPool.ContainsKey(iResid))
            {
                GameObjectPool objpool = (GameObjectPool)m_ObjectPool[iResid];

                return(objpool.ObtainPrefabInstance());
            }

            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 生成掉落
        /// </summary>
        /// <param name="dropPos"></param>
        /// <param name="dropItem"></param>
        private void GenerateDropItem(Vector3 dropPos, string dropEft, int quality, ref DropItemInfo dropItem)
        {
            GameObjectPool objPool       = null;
            GameObject     qualityEftObj = null;

            dropItem.dropEft = dropEft;
            if (m_itemEftPoolDict.ContainsKey(dropEft))
            {
                dropItem.dropType = DROP_TYPE.DROPTYPE_COMMON;
                objPool           = m_itemEftPoolDict[dropEft];

                if (QualitEftDict.ContainsKey(quality))
                {
                    qualityEftObj = CoreEntry.gGameObjPoolMgr.Instantiate(QualitEftDict[quality]);
                }
            }
            else
            {
                dropItem.dropType = DROP_TYPE.DROPTYPE_GOLD;
                objPool           = m_moneyEftObjectPool;
            }

            GameObject obj = null;

            if (objPool != null)
            {
                obj = objPool.ObtainPrefabInstance();
                if (obj == null)
                {
                    return;
                }
                dropItem.dropItemObj       = obj;
                dropItem.dropItem          = obj.GetComponent <DropItem>();
                obj.transform.position     = dropPos;
                dropItem.dropQualityEftObj = qualityEftObj;

                if (null != qualityEftObj)
                {
                    qualityEftObj.transform.SetParent(obj.transform);
                    qualityEftObj.transform.localPosition = Vector3.zero;
                    qualityEftObj.transform.localScale    = Vector3.one;
                    qualityEftObj.transform.localRotation = Quaternion.identity;
                }
            }
        }