// ========================================================================== //

    /* public - [Do] Function
     * 외부 객체가 호출(For External class call)*/

    public GameObject DoPop(GameObject pObjectCopyTarget, bool bActive = true)
    {
        int iID = pObjectCopyTarget.GetHashCode();

        if (_mapUnUsed.ContainsKey(iID) == false)
        {
            _mapUsed.Add(iID, new LinkedList <GameObject>());
            _mapUnUsed.Add(iID, new LinkedList <GameObject>());
        }

        GameObject pObjectUnUsed = null;

        if (_mapUnUsed[iID].Count != 0)
        {
            pObjectUnUsed = _mapUnUsed[iID].First.Value;
            _mapUnUsed[iID].RemoveFirst();
        }
        else
        {
            pObjectUnUsed = Instantiate(pObjectCopyTarget);
            pObjectUnUsed.transform.SetParent(transform);

            CCompoEventTrigger pEventTrigger = pObjectUnUsed.AddComponent <CCompoEventTrigger>();
            pEventTrigger.p_eInputType = CCompoEventTrigger.EInputType.OnDisable;
            pEventTrigger.p_Event_IncludeThisObject += DoPush;

            _mapAllInstance.Add(pObjectUnUsed, iID);
        }

        _mapUsed[iID].AddLast(pObjectUnUsed);
        pObjectUnUsed.SetActive(bActive);
        return(pObjectUnUsed);
    }
Exemplo n.º 2
0
    public GameObject DoPop(GameObject pObjectCopyTarget, Vector3 vecPos, bool bAutoReturn_OnDisable = true)
    {
        if (pObjectCopyTarget == null)
        {
            return(null);
        }

        int iID = pObjectCopyTarget.GetHashCode();

        if (_mapUnUsed.ContainsKey(iID) == false)
        {
            _mapUsed.Add(iID, new LinkedList <GameObject>());
            _mapUnUsed.Add(iID, new LinkedList <GameObject>());
            _mapLayerBackup.Add(iID, pObjectCopyTarget.layer);
        }

        GameObject pObjectUnUsed = null;

        if (_mapUnUsed[iID].Count != 0)
        {
            pObjectUnUsed = _mapUnUsed[iID].First.Value;
            _mapUnUsed[iID].RemoveFirst();
        }
        else
        {
            pObjectUnUsed      = Instantiate(pObjectCopyTarget);
            pObjectUnUsed.name = string.Format("{0}_{1}", pObjectCopyTarget.name, _mapUnUsed[iID].Count + _mapUsed[iID].Count);
            pObjectUnUsed.transform.SetParent(transform);

            CCompoEventTrigger pEventTrigger = pObjectUnUsed.AddComponent <CCompoEventTrigger>();
            // pEventTrigger.p_bIsDebuging = true;
            pEventTrigger.p_eConditionType           = CCompoEventTrigger.EConditionTypeFlags.OnDisable;
            pEventTrigger.p_Event_IncludeThisObject += DoPush;

            _mapAllInstance.Add(pObjectUnUsed, iID);
        }

        if (p_bIsDebug)
        {
            Debug.Log("Pooling Simple Pop - " + pObjectUnUsed.name, this);
        }

        CCompoEventTrigger pEventTrigger_AutoReturn = pObjectUnUsed.GetComponent <CCompoEventTrigger>();

        if (bAutoReturn_OnDisable)
        {
            pEventTrigger_AutoReturn.p_eConditionType = CCompoEventTrigger.EConditionTypeFlags.OnDisable;
        }
        else
        {
            pEventTrigger_AutoReturn.p_eConditionType = CCompoEventTrigger.EConditionTypeFlags.None;
        }

        pObjectUnUsed.transform.position = vecPos;
        pObjectUnUsed.SetActive(true);
        pObjectUnUsed.layer = _mapLayerBackup[iID];
        _mapUsed[iID].AddLast(pObjectUnUsed);
        return(pObjectUnUsed);
    }
Exemplo n.º 3
0
    public void EventSetDragDropItem()
    {
        _pSprite_Item.gameObject.AddComponent <UIDragDropItem>();
        CCompoEventTrigger pEventTrigger = _pSprite_Item.gameObject.AddComponent <CCompoEventTrigger>();

        pEventTrigger.p_eInputType_Main = CCompoEventTrigger.EInputType.OnPress;
        pEventTrigger.p_OnPress        += OnPress;

        NGUITools.AddWidgetCollider(_pSprite_Item.gameObject);
        _pColliderItem = _pSprite_Item.GetComponent <Collider>();
    }
Exemplo n.º 4
0
    //=============================== [1. Start Public] ===============================//
    #region Public

    protected override void Start()
    {
        if (_bPlayOnEnable)
        {
            CCompoEventTrigger pEventTrigger = gameObject.AddComponent <CCompoEventTrigger>();
            pEventTrigger.DoAddEvent_Main(DoPlayTween_Forward_0);
            pEventTrigger.p_eInputType_Main = CCompoEventTrigger.EInputType.OnEnable;
        }

        ResetToBeginning();
        _iLastPlayIndex = _iDefaultPlayIndex;
    }
Exemplo n.º 5
0
    public void DoSetEquipment(Transform pTransEquipmentModel)
    {
        pTransEquipmentModel.parent = transform;
        pTransEquipmentModel.DoResetTransform();

        CCompoEventTrigger pTrigger = pTransEquipmentModel.GetComponent <CCompoEventTrigger>();

        if (pTrigger == null)
        {
            return;
        }

        //pTrigger.p_OnTriggerEnter += EventOnAttackTarget;
        _pColliderWeapon         = pTrigger.GetComponent <Collider>();
        _pColliderWeapon.enabled = false;
    }
Exemplo n.º 6
0
    static private void ProcInitManagerPooling(List <GameObject> listObject)
    {
        System.Type pType_Enum   = typeof(ENUM_Resource_Name);
        System.Type pType_Class  = typeof(Class_Resource);
        string      strEnumName  = pType_Enum.Name;
        string      strClassName = pType_Class.Name;

        if (listObject.Count == 0)
        {
            Debug.Log("Init Fail. Please Check Resources Path " + strEnumName);
            return;
        }

        _bIsInit = true;
        if (_pObjectManager == null)
        {
            _pObjectManager = new GameObject(string.Format("ManagerPool_{0}_{1}", strEnumName, strClassName));
            _pTransManager  = _pObjectManager.transform;
            CCompoEventTrigger pTrigger = _pObjectManager.AddComponent <CCompoEventTrigger>();
            pTrigger.p_eInputType_Main = CCompoEventTrigger.EInputType.OnDestroy;
            pTrigger.DoAddEvent_Main(DoReleaseSingleton);
        }

        for (int i = 0; i < listObject.Count; i++)
        {
            ENUM_Resource_Name eResourceName = default(ENUM_Resource_Name);
            try
            {
                eResourceName = (ENUM_Resource_Name)System.Enum.Parse(pType_Enum, listObject[i].name);
            }
            catch
            {
                try
                {
                    eResourceName = (ENUM_Resource_Name)((object)listObject[i].name);
                }
                catch
                {
                    Debug.Log("Error Pooling : " + listObject[i].name);
                }
                if (pType_Enum.IsEnum)
                {
                    Debug.Log(string.Format("{0} is not in Enum {1}", listObject[i].name, strEnumName));
                }
            }

            if (_mapResourceOrigin.ContainsKey(eResourceName))
            {
                continue;
            }

            GameObject     pObjectOrigin   = listObject[i].gameObject;
            Class_Resource pResourceOrigin = pObjectOrigin.GetComponent <Class_Resource>();
            //if (pResourceOrigin == null)
            //	pResourceOrigin = pObjectOrigin.AddComponent<Class_Resource>();

            GameObject pObjectCopy = Object.Instantiate(listObject[i].gameObject);
            pObjectCopy.SetActive(false);
            Class_Resource pResource = pObjectCopy.GetComponent <Class_Resource>();
            if (pResource == null)
            {
                pResource = pObjectCopy.AddComponent <Class_Resource>();
            }

            if (_queuePoolingDisable.ContainsKey(eResourceName) == false)
            {
                _queuePoolingDisable.Add(eResourceName, new Queue <Class_Resource>());
                _mapResourcePoolingCount.Add(eResourceName, 0);
            }

            //if (p_EVENT_OnMakeResource != null)
            //	p_EVENT_OnMakeResource(eResourceName, pResource);

            _mapResourceOrigin.Add(eResourceName, pResourceOrigin);
            _mapResourceOriginCopy.Add(eResourceName, pResource);
            //ProcSetChild( eResourceName, pResource );

            pResource.name = string.Format("{0}(Origin)", eResourceName);
            Transform pTransMake = pResource.transform;
            pTransMake.SetParent(_pTransManager);
            pTransMake.DoResetTransform();
        }
    }