示例#1
0
 private void BuildContent(JsonMap? jsonMap)
 {
     foreach (var cell in manager)
     {
         Content content = null;
         switch (cell.Content)
         {
             case ContentType.Coockie:
                 content = GameObject.Instantiate(coockiePrototype).GetComponent<Content>();
                 break;
             case ContentType.Drug:
                 content = GameObject.Instantiate(drugPrototype).GetComponent<Content>();
                 break;
             case ContentType.Cherry:
                 content = GameObject.Instantiate(cherryPrototype).GetComponent<Content>();
                 if (jsonMap.HasValue)
                     ((Cherry)content).Initialize(jsonMap.Value.Cherry);
                 else
                     ((Cherry)content).Initialize();
                 break;
         }
         if (content)
         {
             content.SubscribeMapManager(manager.OnContentChanged);
             content.transform.position = cell.Center;
         }
     }
 }
示例#2
0
        private void BuildMap(JsonMap? jsonMap)
        {
            MapInterpritator mapIr = new MapInterpritator();
            var mxCell = mapIr.LoadMapFromFile(Environment.CurrentDirectory + GameManager.DEFAULT_MAP_PATH);

            ContentType[,] mxContent;
            if (jsonMap == null)
                mxContent = mapIr.LoadContentFromFile(Environment.CurrentDirectory + GameManager.DEFAULT_CONTETNT_PATH);
            else
                mxContent = mapIr.LoadContentFromStringList(jsonMap.Value.ContentLines);

            manager = new GameMap(mxCell, mxContent);
            BuildMapByFerr2D(mxCell);
        }