Ejemplo n.º 1
0
        public virtual TDataView CreateViewInstance(ShotData data, Transform parent)
        {
            GameObject obj      = (GameObject)GameObject.Instantiate(prefab, parent, false);
            TDataView  dataView = obj.GetComponent <TDataView>();

            activeViewList.Add(dataView);
            dataView.BindDataToView(data);
            dataView.OnCreate();
            return(dataView);
        }
Ejemplo n.º 2
0
 public bool HasActiveView(ShotData data)
 {
     for (int i = 0; i < activeViewList.Count; ++i)
     {
         if (activeViewList[i].data == data)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
 public TDataView TryGetActiveView(ShotData data)
 {
     for (int i = 0; i < activeViewList.Count; ++i)
     {
         if (activeViewList[i].data == data)
         {
             return(activeViewList[i]);
         }
     }
     return(null);
 }
Ejemplo n.º 4
0
        public virtual TDataView DePoolDataView(ShotData data)
        {
            //Error!!! Should not happen, but sometimes can; return a null to tell the list to get a new view
            if (pool.Peek() != null && pool.Peek().data != null)
            {
                TDataView badView = pool.Dequeue();
                GameObject.Destroy(badView.gameObject);
                return(null);
            }

            TDataView dataView = pool.Dequeue();

            activeViewList.Add(dataView);
            dataView.BindDataToView(data);
            dataView.OnDePool();
            return(dataView);
        }
Ejemplo n.º 5
0
        public virtual void EnPoolDataView(ShotData data)
        {
            TDataView dataView = TryGetActiveView(data);

            //don't allow pooling of null data
            if (dataView == null)
            {
                activeViewList.Remove(dataView);
                return;
            }

            //the user's pooling strategy might request that the object be destroyed
            dataView = (TDataView)dataView.OnEnPool();
            if (dataView != null)
            {
                pool.Enqueue(dataView);
                dataView.ClearView();
            }

            activeViewList.Remove(dataView);
        }
Ejemplo n.º 6
0
 protected virtual bool Equals(ShotData other)
 {
     return(string.Equals(shotData, other.shotData));
 }