コード例 #1
0
 private AgentRemote Create(ListUpgrade type)
 {
     AgentPrefabs.TryGetValue(type.GetHashCode(), out AgentRemote res);
     if (res == null)
     {
         return(null);
     }
     return(Instantiate(res, Container));
 }
コード例 #2
0
 public void Release(ListUpgrade type, AgentRemote agent)
 {
     if (AgentPools.TryGetValue(type.GetHashCode(), out Pooling <AgentRemote> pool))
     {
         pool.Release(agent);
     }
     else
     {
         CreatePool(type).Release(agent);
     }
 }
コード例 #3
0
 public AgentRemote GetItem(ListUpgrade type)
 {
     if (AgentPools.TryGetValue(type.GetHashCode(), out Pooling <AgentRemote> pool))
     {
         return(pool.GetItem());
     }
     else
     {
         return(CreatePool(type).GetItem());
     }
 }
コード例 #4
0
    private Pooling <AgentRemote> CreatePool(ListUpgrade type)
    {
        int hashCode = type.GetHashCode();

        AgentPools[hashCode] = new Pooling <AgentRemote>(
            delegate(int insId)
        {
            return(CreatePoolingItem(insId, type));
        });

        return(AgentPools[hashCode]);
    }