Esempio n. 1
0
        public static ClientMap getClientMap(MapModel mm)
        {
            ClientMap cm = new ClientMap();

            cm.mapSquares = new ClientMapSquare[mm.map.GetLength(0)][];
            List <string> urls = new List <string>();

            for (var i = 0; i < cm.mapSquares.Length; i++)
            {
                cm.mapSquares[i] = new ClientMapSquare[mm.map.GetLength(1)];
            }
            cm.name = mm.name;
            for (var x = 0; x < mm.map.GetLength(0); x++)
            {
                for (var y = 0; y < mm.map.GetLength(1); y++)
                {
                    int    imageUrlId;
                    string imageUrl = getImageURL(mm.map[x, y]);
                    if (urls.Contains(imageUrl))
                    {
                        imageUrlId = urls.IndexOf(imageUrl);
                    }
                    else
                    {
                        imageUrlId = urls.Count;
                        urls.Add(imageUrl);
                    }
                    cm.mapSquares[x][y] = new ClientMapSquare()
                    {
                        i   = imageUrlId,
                        isI = getInteractable(mm.map[x, y]),
                        isT = getTraversable(mm.map[x, y])
                    };
                }
            }

            cm.mapUrl = urls.ToArray();

            cm.events = new List <ClientEvent>();
            foreach (MapEventModel me in mm.eventCollection.getAll())
            {
                ClientEvent ce = new ClientEvent();
                ce.x          = me.x;
                ce.y          = me.y;
                ce.rewardType = me.rewardType;
                cm.events.Add(ce);
            }

            return(cm);
        }
        public static ClientMap getClientMap(MapModel mm)
        {
            ClientMap cm = new ClientMap();
            cm.mapSquares = new ClientMapSquare[mm.map.GetLength(0)][];
            List<string> urls = new List<string>();
            for (var i = 0; i < cm.mapSquares.Length; i++)
            {
                cm.mapSquares[i] = new ClientMapSquare[mm.map.GetLength(1)];
            }
            cm.name = mm.name;
            for (var x = 0; x < mm.map.GetLength(0); x++)
            {
                for (var y = 0; y < mm.map.GetLength(1); y++)
                {
                    int imageUrlId;
                    string imageUrl = getImageURL(mm.map[x, y]);
                    if (urls.Contains(imageUrl))
                    {
                        imageUrlId = urls.IndexOf(imageUrl);
                    }
                    else
                    {
                        imageUrlId = urls.Count;
                        urls.Add(imageUrl);
                    }
                    cm.mapSquares[x][y] = new ClientMapSquare()
                    {
                        i = imageUrlId,
                        isI = getInteractable(mm.map[x, y]),
                        isT = getTraversable(mm.map[x, y])
                    };
                }
            }

            cm.mapUrl = urls.ToArray();

            cm.events = new List<ClientEvent>();
            foreach (MapEventModel me in mm.eventCollection.getAll())
            {
                ClientEvent ce = new ClientEvent();
                ce.x = me.x;
                ce.y = me.y;
                ce.rewardType = me.rewardType;
                cm.events.Add(ce);
            }

            return cm;
        }