Exemple #1
0
 public MapObject(MapObjectKind kind, Double x, Double y, Double r)
 {
     this.kind = kind;
     this.x = x;
     this.y = y;
     this.r = r;
 }
Exemple #2
0
        public static MapInfo Parse(TextAsset textAsset)
        {
            var data = new MapInfo
            {
                Name = textAsset.name
            };

            var lines     = textAsset.text.Split('\n').Select(s => s.Trim('\r')).ToArray();
            var firstLine = lines[0].Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).ToArray();

            data.Width  = int.Parse(firstLine[0]);
            data.Height = int.Parse(firstLine[1]);
            data.Map    = new MapObjectKind[data.Height][];

            for (var lineIdx = 1; lineIdx <= data.Height; lineIdx++)
            {
                var currentLineMap = new MapObjectKind[data.Width];

                for (var colIdx = 0; colIdx < data.Width; colIdx++)
                {
                    currentLineMap[colIdx] = ParseCell(lines, lineIdx, colIdx);
                }

                data.Map[lineIdx - 1] = currentLineMap;
            }

            return(data);
        }
Exemple #3
0
        public void Add(Vector2 position, MapObjectKind objectKind)
        {
            var mos = _moFactory.Create(objectKind, position);

            foreach (var mo in mos)
            {
                NetworkServer.Spawn(mo);
                _mapObjects.Add(mo);
            }
        }
Exemple #4
0
        public IEnumerable <GameObject> Create(MapObjectKind kind, Vector2 position)
        {
            var infos = _prototypes[kind];

            foreach (var info in infos)
            {
                var go = _instantiator.InstantiatePrefab(info.Prefab);
                go.transform.position = position + info.Offset;
                yield return(go);
            }
        }
Exemple #5
0
        public MapInfo Parse(TextAsset textAsset)
        {
            var data = new MapInfo
            {
                Name = textAsset.name
            };

            var lines     = textAsset.text.Split('\n').Select(s => s.Trim('\r')).ToArray();
            var firstLine = lines[0].Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).ToArray();

            data.Width  = int.Parse(firstLine[0]);
            data.Height = int.Parse(firstLine[1]);
            Color color;

            if (firstLine.Length > 2 && ColorUtility.TryParseHtmlString(firstLine[2], out color))
            {
                data.BackgroundColor = color;
            }
            if (firstLine.Length > 3 && ColorUtility.TryParseHtmlString(firstLine[3], out color))
            {
                data.CrawlerBeltColor = color;
            }

            data.Map = new MapObjectKind[data.Height][];

            for (var lineIdx = 1; lineIdx <= data.Height; lineIdx++)
            {
                var currentLineMap = new MapObjectKind[data.Width];

                for (var colIdx = 0; colIdx < data.Width; colIdx++)
                {
                    currentLineMap[colIdx] = ParseCell(lines, lineIdx, colIdx);
                }

                data.Map[lineIdx - 1] = currentLineMap;
            }

            return(data);
        }
Exemple #6
0
 public static void Add(this MapObjectsManager mapObjects, float x, float y, MapObjectKind objectKind)
 {
     mapObjects.Add(new Vector2(x, y), objectKind);
 }
Exemple #7
0
 public MapCellDto(Vector2 vector2, MapObjectKind obj) : this()
 {
     Vector2       = vector2;
     MapObjectKind = obj;
 }