Пример #1
0
    // 유틸 : 객체 초기화
    static void Initialize(T pInstance)
    {
        if (null == pInstance)
        {
            return;
        }

        // 싱글턴 생성시 Awake에서 호출되고, Instance에서 호출되므로 같으면 무시
        if ((null != m_pInstance) && (m_pInstance == pInstance))
        {
            return;
        }

        // 인스턴스 중복체크
        T pDuplication = SHGameObject.GetDuplication(pInstance);

        if (null != pDuplication)
        {
            m_pInstance = pDuplication;
            SHGameObject.DestoryObject(pInstance.gameObject);
            return;
        }

        m_pInstance = pInstance;
        m_pInstance.SetParent("SHSingletons(Destroy)");
        m_pInstance.OnInitialize();
    }
Пример #2
0
    static void Initialize(T pInstance)
    {
        if (null == pInstance)
        {
            return;
        }

        // 초기화 무시처리 : 싱글턴 생성시 Awake에서 호출되고, Instance Property에 접근하면서 호출될 수 있므로 인스턴스가 같으면 무시
        if (m_pInstance == pInstance)
        {
            return;
        }

        // 인스턴스 중복체크 : 이미 생성된 게임오브젝트가 존재할 수 있으므로 중복체크 후 인스턴스 업데이트 처리
        T pDuplication = SHGameObject.GetDuplication(pInstance);

        if (null != pDuplication)
        {
            UnityEngine.Object.DestroyImmediate(pInstance.gameObject);
            m_pInstance = pDuplication;
            return;
        }

        m_pInstance = pInstance;
        m_pInstance.SetParent("SHSingletons(Destroy)");
        m_pInstance.OnInitialize();
    }
Пример #3
0
 public T Get <T>(
     string strName,
     ePoolReturnType eReturnType   = ePoolReturnType.Disable,
     ePoolDestroyType eDestroyType = ePoolDestroyType.ChangeScene) where T : Component
 {
     return(SHGameObject.GetComponent <T>(Get(strName, eReturnType, eDestroyType)));
 }
Пример #4
0
    void DestroyPanel(SHUIBasePanel pPanel)
    {
        if (null == pPanel)
        {
            return;
        }

        SHGameObject.DestoryObject(pPanel);
    }
Пример #5
0
    public Collider GetCollider()
    {
        if (null == m_pCollider)
        {
            m_pCollider = SHGameObject.GetComponent <Collider>(gameObject);
        }

        return(m_pCollider);
    }
Пример #6
0
 public void Get <T>(string strName,
                     eObjectPoolReturnType eReturnType,
                     eObjectPoolDestroyType eDestroyType,
                     Action <T> pCallback) where T : Component
 {
     Get(strName, eReturnType, eDestroyType, (pObject) =>
     {
         pCallback(SHGameObject.GetComponent <T>(pObject));
     });
 }
Пример #7
0
 void CreateEffectChannel()
 {
     ClearChannel(m_dicEffectChannel);
     m_dicEffectChannel.Clear();
     SHUtils.ForToEnum <eSoundEffectChannel>((eEffectChannel) =>
     {
         var pObject = new GameObject(eEffectChannel.ToString());
         pObject.transform.SetParent(transform);
         m_dicEffectChannel.Add(eEffectChannel, SHGameObject.GetComponent <AudioSource>(pObject));
     });
 }
Пример #8
0
    Transform GetRoot(int iLayer)
    {
        if (false == m_dicRoots.ContainsKey(iLayer))
        {
            var pRoot = SHGameObject.CreateEmptyObject(string.Format("SHObjectPool_{0}", iLayer));
            pRoot.layer = iLayer;
            DontDestroyOnLoad(pRoot);
            m_dicRoots.Add(iLayer, pRoot.transform);
        }

        return(m_dicRoots[iLayer]);
    }
Пример #9
0
    void SetStickSlot(eStickType eType, SHUIWidget_Stick pStick, SHUIWidget_ItemSlot pSlot)
    {
        if ((null == pStick) || (null == pSlot))
        {
            return;
        }

        SHGameObject.SetParent(pStick.GetGameObject(), pSlot.GetGameObject());
        pStick.Initialize(eType);
        pStick.SetLocalPosition(Vector3.zero);
        pStick.SetLocalScale(Vector3.one);
        pStick.SetActive(true);
    }
Пример #10
0
    // public bool     m_bIsDeleteWithDamage = true;               // 데미지와 함께 죽을것인가?

    GameObject CreateEffect(string strPrefabName)
    {
        var pEffect = Single.ObjectPool.Get(strPrefabName);

        if (null == pEffect)
        {
            Debug.LogErrorFormat("SHDamageObject::CreateEffect - Not Found Prefab : {0}", strPrefabName);
            return(null);
        }

        SHGameObject.SetParent(pEffect, Single.Engine.GetGameObject());

        return(pEffect);
    }
Пример #11
0
    public void Initialize(bool bIsActive)
    {
        if (eObjectDestoryType.Never == m_eDestroyType)
        {
            SHGameObject.SetParent(transform, Single.UI.GetRootToGlobal());
        }
        else
        {
            SHGameObject.SetParent(transform, Single.UI.GetRootToScene());
        }

        SetLocalScale(Vector3.one);
        SetActive(bIsActive);
    }
Пример #12
0
    private Animation GetAnimation(GameObject pObject = null)
    {
        if (null != m_pAnim)
        {
            return(m_pAnim);
        }

        if (null == pObject)
        {
            pObject = gameObject;
        }

        return(m_pAnim = SHGameObject.GetComponent <Animation>(pObject));
    }
Пример #13
0
    void SetMonsterSlot(eMonsterType eType, SHUIWidget_Monster pMonster, SHUIWidget_ItemSlot pSlot)
    {
        if ((null == pMonster) || (null == pSlot))
        {
            return;
        }

        SHGameObject.SetParent(pMonster.GetGameObject(), pSlot.GetGameObject());
        pMonster.Initialize(eType, 0.5f, 0.0f, 0.0f);
        pMonster.SetLocalPosition(Vector3.zero);
        pMonster.SetLocalScale(Vector3.one);
        pMonster.StopMoveTween();
        pMonster.SetActive(true);
    }
Пример #14
0
    private SHUIWidget_Monster CreateMonster(eMonsterType eType, float fFactor, float fStartPosY)
    {
        var pMonster = Single.ObjectPool.Get <SHUIWidget_Monster>(SHHard.GetMonsterName(eType));

        if (null == pMonster)
        {
            return(null);
        }

        SHGameObject.SetParent(pMonster.transform, Single.UI.GetRootToScene());
        Single.ObjectPool.SetStartTransform(pMonster.gameObject);
        pMonster.SetActive(true);
        pMonster.Initialize(eType, fFactor, Single.Balance.GetMonsterSpeed(), fStartPosY);
        return(pMonster);
    }
Пример #15
0
    public static T GetInstance()
    {
        lock (m_pLocker)
        {
            if (null == m_pInstance)
            {
                if (null == (m_pInstance = SHGameObject.FindObjectOfType <T>()))
                {
                    Initialize(SHGameObject.CreateEmptyObject(typeof(T).ToString()).AddComponent <T>());
                }
            }

            return(m_pInstance);
        }
    }
    // 유틸 : 타켓 오브젝트 생성
    GameObject CreateTargetObject(string strFileName)
    {
        if (false == m_dicTargetObject.ContainsKey(strFileName))
        {
            GameObject pObject = Single.Resource.GetGameObject(strFileName);
            if (null == pObject)
            {
                return(null);
            }

            SHGameObject.SetParent(pObject, gameObject);
            m_dicTargetObject.Add(strFileName, pObject);
        }

        return(m_dicTargetObject[strFileName]);
    }
Пример #17
0
    private SHUIWidget_Stick CreateStick()
    {
        m_pStick = Single.ObjectPool.Get <SHUIWidget_Stick>(
            SHHard.GetStickName(GetStickType()));
        if (null == m_pStick)
        {
            return(null);
        }

        SHGameObject.SetParent(m_pStick.transform, Single.UI.GetRootToScene());
        Single.ObjectPool.SetStartTransform(m_pStick.gameObject);
        m_pStick.SetActive(true);
        m_pStick.Initialize(GetStickType());

        return(m_pStick);
    }
Пример #18
0
    // 유틸 : 객체 중복체크
    public static T GetDuplication <T>(T pInstance) where T : UnityEngine.Object
    {
        var pList = SHGameObject.FindObjectsOfType <T>();

        if (null == pList)
        {
            return(null);
        }

        for (int iLoop = 0; iLoop < pList.Length; ++iLoop)
        {
            if (pInstance.GetInstanceID() != pList[iLoop].GetInstanceID())
            {
                return(pList[iLoop]);
            }
        }

        return(null);
    }
Пример #19
0
    void SetupEffectTransform(GameObject pEffect, SHDamageEffectInfo pEffectInfo)
    {
        if ((null == pEffect) || (null == pEffectInfo))
        {
            return;
        }

        Vector3 vLocalPosition = pEffectInfo.m_vStaticStartPosition;

        if (true == pEffectInfo.m_bIsTraceDamage)
        {
            SHGameObject.SetParent(pEffect, GetGameObject());
            vLocalPosition = Vector3.zero;
        }
        else if (true == pEffectInfo.m_bIsStartPosToDamage)
        {
            vLocalPosition = GetPosition();
        }

        pEffect.transform.localPosition = (vLocalPosition + pEffectInfo.m_vPositionOffset);
    }
Пример #20
0
    void SetupTransform()
    {
        var vLocalPosition = m_pInfo.m_vStaticStartPosition;
        var pParentObject  = Single.UI.GetRootToScene();

        if (null != GetWho())
        {
            if (true == m_pInfo.m_bIsTraceToCreator)
            {
                pParentObject  = GetWho().GetTransform();
                vLocalPosition = Vector3.zero;
            }
            else if (true == m_pInfo.m_bIsStartPosToCreator)
            {
                vLocalPosition = GetWho().GetLocalPosition();
            }
        }

        SHGameObject.SetParent(GetTransform(), pParentObject);
        SetStartTransform();
        SetLocalPosition(vLocalPosition + m_pInfo.m_vPositionOffset);
    }
Пример #21
0
 private void OnChangeToCrash(params object[] pArgs)
 {
     SHGameObject.SetParent(gameObject, ((SHUIWidget_Monster)pArgs[0]).gameObject);
 }
Пример #22
0
 // 후처리
 static void PostProcessor()
 {
     SHGameObject.DestoryObject(GameObject.Find("SHSingletons(Destroy)"));
     SHGameObject.DestoryObject(GameObject.Find("SHSingletons(DontDestroy)"));
 }
Пример #23
0
 // 유틸 : 싱글턴 부모설정
 GameObject SetParent(string strRootName)
 {
     return(SHGameObject.SetParent(gameObject, strRootName));
 }
Пример #24
0
 // 인터페이스 : 명시적으로 싱글턴 제거
 public void DoDestroy()
 {
     SHGameObject.DestoryObject(gameObject);
 }
Пример #25
0
 // 인터페이스 : 빈 게임오브젝트를 생성하고 컴퍼넌트를 추가한뒤 얻어낸다.
 public T GetCreateComponent <T>(string strName) where T : Component
 {
     return(SHGameObject.GetComponent <T>(SHGameObject.CreateEmptyObject(strName)));
 }
Пример #26
0
 public override void OnInitialize()
 {
     SetDontDestroy();
     Single.Scene.AddEventToChangeScene(OnEventToChangeScene);
     SHGameObject.SetParent(Single.Resource.GetGameObject("UIRoot_Global"), gameObject);
 }