Exemple #1
0
        private ILevelPlaceabe SearchRope(char ch, int x, int y, PrefabsStore prefabsStore)
        {
            if (!SearchLongItem(ch, ch == 'O', x, y, out var start, out var end))
            {
                return(null);
            }

            return(new RopePlacer(prefabsStore.Rope, end, start, Map.CellSize.z, start.x != end.x));
        }
Exemple #2
0
        private ILevelPlaceabe SearchLadder(char ch, int x, int y, PrefabsStore prefabsStore)
        {
            if (!SearchLongItem(ch, ch == 'L', x, y, out var start, out var end))
            {
                return(null);
            }

            return(new LadderPlacer(prefabsStore.Ladder, start, end, Map.CellSize.z));
        }
Exemple #3
0
        private ILevelPlaceabe PlaceableFromChar(char ch, PrefabsStore prefabsStore, int x, int y)
        {
            switch (ch)
            {
            case 'H': return(prefabsStore.Block);

            case ' ': return(null);

            case 'L':
            case 'R': return(SearchLadder(ch, x, y, prefabsStore));

            case 'O':
            case 'P': return(SearchRope(ch, x, y, prefabsStore));

            case 'm': return(prefabsStore.SmallMonster);

            case 's': return(prefabsStore.Stone);

            default: throw new InvalidOperationException("Nezname pismeno");
            }
        }
Exemple #4
0
        public IEnumerable <(ILevelPlaceabe, Vector3)> Placeables(PrefabsStore prefabsStore)
        {
            int y = Data.Length - 1;

            foreach (string str in Data)
            {
                int x = 0;
                foreach (char ch in str)
                {
                    Vector2 pos = ToWorld(x, y);

                    var p = PlaceableFromChar(ch, prefabsStore, x, y);
                    if (p != null)
                    {
                        yield return(p, pos);
                    }

                    x++;
                }
                y--;
            }
        }