少年修仙传客户端代码仓库
hch
2025-04-03 c154ac0832fe4379a00d3e1cda700e7d2a7383c7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using vnxbqy.UI;
 
public class DropItemPool
{
    static Dictionary<int, GameObjectPoolManager.GameObjectPool> dropItemPools = new Dictionary<int, GameObjectPoolManager.GameObjectPool>();
 
    public static DropItem RequireDropItem(DropItemType _type)
    {
        GameObjectPoolManager.GameObjectPool pool = null;
        var poolKey = (int)_type;
        if (!dropItemPools.ContainsKey(poolKey))
        {
            var prefab = UILoader.LoadPrefab(StringUtility.Contact("DropItem_Pattern_", (int)_type));
            if (prefab != null)
            {
                pool = GameObjectPoolManager.Instance.RequestPool(prefab);
                dropItemPools[poolKey] = pool;
            }
        }
        else
        {
            pool = dropItemPools[poolKey];
        }
 
        if (pool != null)
        {
            var instance = pool.Request();
            var dropItem = instance.GetComponent<DropItem>();
            dropItem.dropItemType = _type;
            dropItem.SetActive(true);
            return dropItem;
        }
        else
        {
            return null;
        }
 
    }
 
    public static void ReycleDropItem(DropItem _dropItem)
    {
        var dropItemType = _dropItem.dropItemType;
        GameObjectPoolManager.GameObjectPool pool;
        if (dropItemPools.TryGetValue((int)dropItemType, out pool))
        {
            pool.Release(_dropItem.gameObject);
            _dropItem.transform.SetParent(null);
            _dropItem.SetActive(false);
        }
    }
 
 
    static GameObjectPoolManager.GameObjectPool dropItemNamePool;
 
    public static DropItemName RequireDropItemName()
    {
        if (dropItemNamePool == null)
        {
            var prefab = UILoader.LoadPrefab("DropItemName");
            if (prefab != null)
            {
                dropItemNamePool = GameObjectPoolManager.Instance.RequestPool(prefab);
            }
        }
 
        if (dropItemNamePool != null)
        {
            var instance = dropItemNamePool.Request();
            instance.SetActive(true);
            return instance.GetComponent<DropItemName>();
        }
        else
        {
            return null;
        }
    }
 
    public static void ReycleDropItemName(DropItemName _dropItemName)
    {
        if (dropItemNamePool != null)
        {
            dropItemNamePool.Release(_dropItemName.gameObject);
            _dropItemName.transform.SetParent(null);
            _dropItemName.SetActive(false);
        }
    }
 
 
    static GameObjectPoolManager.GameObjectPool dropTracePool;
 
    public static DropItemTrace RequireDropItemTrace()
    {
        if (dropTracePool == null)
        {
            var prefab = UILoader.LoadPrefab("DropItemTrace");
            if (prefab != null)
            {
                dropTracePool = GameObjectPoolManager.Instance.RequestPool(prefab);
            }
        }
 
        if (dropTracePool != null)
        {
            var instance = dropTracePool.Request();
            instance.SetActive(true);
            return instance.GetComponent<DropItemTrace>();
        }
        else
        {
            return null;
        }
    }
 
    public static void ReycleDropItemTrace(DropItemTrace _dropItemTrace)
    {
        if (dropTracePool != null)
        {
            dropTracePool.Release(_dropItemTrace.gameObject);
            _dropItemTrace.transform.SetParent(null);
            _dropItemTrace.SetActive(false);
        }
    }
 
}