Ejemplo n.º 1
0
 public bool ReturnRSS(int id)
 {
     if (Resources.ContainsKey(id))
     {
         RssPooling.Release(Resources[id]);
         //Debugger.Log("Released " + id);
         return(Resources.Remove(id));
     }
     else
     {
         //Debugger.Log("release failure: " + id);
         return(false);
     }
 }
Ejemplo n.º 2
0
    private IEnumerator StartCreateRssWaiting()
    {
        AJPHelper.Operation oper = RSSPositionTable.Operation;
        while (!oper.IsDone)
        {
            yield return(null);
        }

        //if (!treeInited)
        //{
        //    int rssCount = RSSPositionTable.Count;
        //    for (int iter = 0; iter < rssCount; iter++)
        //    {
        //        rssPositionTree.Insert
        //            (RSSPositionTable.ReadOnlyRows[iter].Position.Parse3Int().ToClientPosition());
        //    }
        //    treeInited = true;
        //}

        if (!treeInited)
        {
            rssPositionTree.AsyncCreateTree(GetRssPositionEnumerable());
            while (!rssPositionTree.IsAsyncCreateComplete)
            {
                yield return(null);
            }
            treeInited = true;
            Debugger.Log("quad tree inited");
        }

        isCreateComplete = false;
        int count = WaitForCreate.Count;

        //int i = count - 1;

        while (WaitForCreate.Count > 0 && !isCreateComplete)
        {
            Vector3Int      pos     = WaitForCreate[WaitForCreate.Count - 1].ToSerPosition();
            RSS_PositionRow rssData = RSSPositionTable.GetRssAt(pos);
            if (rssData != null &&
                !Resources.ContainsKey(rssData.ID))
            {
                /// Using pool object for natural resource
                NaturalResource rs = RssPooling.GetItem();
                rs.gameObject.name = "Resource" + rssData.RssType.ToString() + rssData.ID;

                Vector3 worldPos = MapIns.CellToWorld(rssData.Position.Parse3Int().ToClientPosition());
                rs.SetResourceData(rssData, Flag.Owner, worldPos);
                Resources[rssData.ID] = rs;
                rs.gameObject.SetActive(true);

                //Debugger.Log("Created " + rssData.ID);
            }

            WaitForCreate.RemoveAt(WaitForCreate.Count - 1);
            //i--;
            yield return(null);
        }
        isCreateComplete = true;
        yield break;
    }