Beispiel #1
0
    public bool AlcoveHasItem(Alcove alcove)
    {
        //    CHOSENONE = alcove;
        //  Debug.Log("worldState alcove = " + b);
        //   Debug.Log("AlcoveHasItem: transform.childCount " + alcove.transform.childCount);
        if (alcove == null)
        {
            Debug.Log("alcove is null");
        }
        if (alcove.transform == null)
        {
            Debug.Log("alcove transform is null");
        }
        if (alcove.transform.childCount == 0)
        {
            Debug.Log("alcove transform.childCount is null");
        }


        if (alcove.transform.childCount > 1)
        {
            return(true);
        }
        return(false);
    }
Beispiel #2
0
        protected virtual IActuatorX CreateWallDecoration(int currentIdentifer, List <IGrabableItem> items)
        {
            var descriptor = builder.CurrentMap.WallDecorations[currentIdentifer];
            var texture    = builder.WallTextures[currentIdentifer];

            switch (descriptor.Type)
            {
            case GraphicsItemState.GraphicOnly:
                var decoration = new DecorationItem();
                decoration.Renderer = builder.Factories.RenderersSource.GetRandomDecorationRenderer(decoration, texture);
                return(decoration);

            case GraphicsItemState.Alcove:
                var alcove = new Alcove(items);
                items.Clear();
                alcove.Renderer = builder.Factories.RenderersSource.GetAlcoveDecorationRenderer(alcove, texture);
                return(alcove);

            case GraphicsItemState.ViAltair:
                var altair = new ViAltairAlcove(items);
                items.Clear();
                altair.Renderer = builder.Factories.RenderersSource.GetAlcoveDecorationRenderer(altair, texture);
                return(altair);

            case GraphicsItemState.Fountain:
                var fountain = new Fountain(builder.Factories);
                fountain.Renderer = builder.Factories.RenderersSource.GetFountainDecoration(fountain, texture);
                return(fountain);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Beispiel #3
0
 public GameObject GetItem(Alcove alcove)
 {
     if (alcove.transform.childCount == 2)
     {
         return(alcove.transform.GetChild(0).gameObject);
     }
     return(null);
 }
Beispiel #4
0
 void initializeAlcoves()
 {
     alcoves[0] = new Alcove(new Vector3(-60, 2, 37), false);
     alcoves[1] = new Alcove(new Vector3(-30, 2, 37), false);
     alcoves[2] = new Alcove(new Vector3(0, 2, 37), false);
     alcoves[3] = new Alcove(new Vector3(30, 2, 37), false);
     alcoves[4] = new Alcove(new Vector3(60, 2, 37), false);
     alcoves[5] = new Alcove(new Vector3(-60, 2, -37), false);
     alcoves[6] = new Alcove(new Vector3(-30, 2, -37), false);
     alcoves[7] = new Alcove(new Vector3(0, 2, -37), false);
     alcoves[8] = new Alcove(new Vector3(30, 2, -37), false);
     alcoves[9] = new Alcove(new Vector3(60, 2, -37), false);
 }
Beispiel #5
0
 public WorldState()
 {
     platformSide = GetInstance().GetOwnSide();
     if (GetInstance().IsInOpen(GetInstance().gameObject))
     {
         currentLocation = CurrentLocation.OPEN;
         currentAlcove   = null;
     }
     else
     {
         currentLocation = CurrentLocation.ALCOVE;
         currentAlcove   = GetInstance().GetCurrentAlcove();
     }
 }
Beispiel #6
0
    private Alcove GetOppositeAlcove(Alcove alcove)
    {
        int i = -1;

        for (int j = 0; j < alcoves.Count; j++)
        {
            if (alcove == alcoves[j])
            {
                i = j;
                break;
            }
        }
        if (i <= 4)
        {
            return(alcoves[i + 5]);
        }
        else
        {
            return(alcoves[i - 5]);
        }
    }
Beispiel #7
0
    public Alcove GetCounterClockAlcove(Alcove alcove)
    {
        int i = -1;

        for (int j = 0; j < alcoves.Count; j++)
        {
            if (alcove == alcoves[j])
            {
                i = j;
                break;
            }
        }
        switch (i)
        {
        case 0: return(alcoves[1]);

        case 1: return(alcoves[2]);

        case 2: return(alcoves[3]);

        case 3: return(alcoves[4]);

        case 4: return(alcoves[9]);

        case 5: return(alcoves[0]);

        case 6: return(alcoves[5]);

        case 7: return(alcoves[6]);

        case 8: return(alcoves[7]);

        case 9: return(alcoves[8]);

        default:
            return(alcove);
        }
    }
Beispiel #8
0
        /// <summary>
        /// Parses the dungeon.lua file in the current project directory
        /// </summary>
        /// <returns> A Map object representing the current dungeon.lua file contents </returns>
        public static Map ParseMapFile()
        {
            Char[] delimiters            = { '=', ' ', ',', '"', '{', '}', '\r', '\n', '\t', ')', '(' };
            Char[] delimitersAttributes  = { '.', ':', ',', '"', '(', ')', '\r', '\n', '\t' };
            Char[] delimitersAttributes2 = { '.', ':', ',', '"', '(', ')', '\r', '\n', '\t', ' ' };

            Dictionary <string, MapElement> elements = new Dictionary <string, MapElement>();

            Monster.MonsterType             tmpMonstertype;
            Text.TextType                   tmpTextType;
            Door.DoorType                   tmpDoorType;
            Lever.LeverType                 tmpLeverType;
            Lock.LockType                   tmpLockType;
            ButtonE.ButtonType              tmpButtonType;
            Alcove.AlcoveType               tmpAlcoveType;
            PressurePlate.PressurePlateType tmpPressurePlateType;
            TrapDoor.TrapDoorType           tmpTrapDoorType;
            TorchHolder.TorchHolderType     tmpTorchHolderType;
            Lantern.LanternType             tmpLanternType;
            Altar.AltarType                 tmpAltarType;
            WallEffect.WallEffectType       tmpWallEffectType;
            Weapon.WeaponType               tmpWeaponType;
            Armor.ArmorType                 tmpArmorType;
            Food.FoodType                   tmpFoodType;
            Potion.PotionType               tmpPotionType;

            string fileText = System.IO.File.ReadAllText(DirectoryManager.DungeonFilePath);

            string patternSpawn      = @"spawn\(.*\)";
            string patternAttributes = @"\w+\.\w+\:\w+\(.*\)";
            string patternLoadLayer  = @"loadLayer\(([^)]+)\)";
            string patternParameters = @"\w+ = .*,";
            string patternTiles      = @"tiles = {(\n|\t|[^{])*(?=})";


            MatchCollection matchsSpawn      = Regex.Matches(fileText, patternSpawn, RegexOptions.IgnoreCase);
            MatchCollection matchsAttribute  = Regex.Matches(fileText, patternAttributes, RegexOptions.IgnoreCase);
            MatchCollection matchsParameters = Regex.Matches(fileText, patternParameters, RegexOptions.IgnoreCase);
            Match           matchLayer       = Regex.Match(fileText, patternLoadLayer, RegexOptions.IgnoreCase);
            Match           matchTiles       = Regex.Match(fileText, patternTiles, RegexOptions.IgnoreCase);

            string name = "", ambientTrack = "";
            int    width = 0, height = 0;

            int[]              levelCoord    = null;
            List <string>      tiles         = new List <string>();
            List <Cell>        cells         = new List <Cell>();
            List <EndingPoint> endingPoints  = new List <EndingPoint>();
            StartingPoint      startingPoint = null;

            foreach (Match m in matchsParameters)
            {
                string[] split = m.Value.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

                if (split[0].Contains("name"))
                {
                    name = split[1];
                }
                else if (split[0].Contains("width"))
                {
                    width = Convert.ToInt32(split[1]);
                }
                else if (split[0].Contains("height"))
                {
                    height = Convert.ToInt32(split[1]);
                }
                else if (split[0].Contains("levelCoord"))
                {
                    levelCoord = new int[] { Convert.ToInt32(split[1]), Convert.ToInt32(split[2]), Convert.ToInt32(split[3]) };
                }
                else if (split[0].Contains("ambientTrack"))
                {
                    ambientTrack = split[1];
                }
            }

            string[] splitTiles = matchTiles.Value.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 1; i < splitTiles.Length; i++)
            {
                tiles.Add(splitTiles[i]);
            }

            string[] splitLayer = matchLayer.Value.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 2; i < splitLayer.Length; i++)
            {
                int  x    = (i - 2) % width;
                int  y    = (i - 2) / width;
                int  type = Convert.ToInt32(splitLayer[i]);
                Cell c    = new Cell(x, y, type);
                if (type == 1)
                {
                    c.IsWalkable = true;
                }
                else if (type == 2)
                {
                    c.IsWalkable = false;                 //FIXME: Se houverem mais tipos esta comparação pode não chegar.
                }
                cells.Add(c);
            }

            foreach (Match m in matchsSpawn)
            {
                string[] splitString = m.Value.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

                string id       = splitString[1];
                int    x        = Convert.ToInt32(splitString[2]);
                int    y        = Convert.ToInt32(splitString[3]);
                int    o        = Convert.ToInt32(splitString[4]);
                int    h        = Convert.ToInt32(splitString[5]);
                string uniqueId = splitString[6];

                Cell       tmpCell    = cells.Where(c => c.X == x && c.Y == y).First();
                MapElement tmpElement = null;

                if (id.Contains("starting_location"))
                {
                    startingPoint           = new StartingPoint(id, x, y, o, h, uniqueId);
                    tmpCell.IsStartingPoint = true;
                    tmpCell.StartPoint      = startingPoint;

                    elements.Add(uniqueId, startingPoint);
                }
                else if (id.Contains("exit") || id.Contains("stairs") || id.Contains("healing_crystal"))
                {
                    var newEndingPoint = new EndingPoint(id, x, y, o, h, uniqueId);
                    tmpCell.IsEndingPoint = true;
                    tmpCell.EndPoint      = newEndingPoint;

                    endingPoints.Add(newEndingPoint);
                    elements.Add(uniqueId, newEndingPoint);
                }
                else if (Enum.TryParse(id, true, out tmpTorchHolderType))
                {
                    tmpElement = new TorchHolder(id, x, y, o, h, uniqueId);
                }
                else if (id.Equals("scroll"))
                {
                    tmpElement = new Scroll(id, x, y, o, h, uniqueId);
                }
                else if (Enum.TryParse(id, true, out tmpAlcoveType))
                {
                    tmpElement = new Alcove(id, x, y, o, h, uniqueId);
                }
                else if (Enum.TryParse(id, true, out tmpButtonType))
                {
                    tmpElement = new ButtonE(id, x, y, o, h, uniqueId);
                }
                else if (Enum.TryParse(id, true, out tmpDoorType))
                {
                    tmpElement = new Door(id, x, y, o, h, uniqueId);
                }
                else if (Enum.TryParse(id, true, out tmpLeverType))
                {
                    tmpElement = new Lever(id, x, y, o, h, uniqueId);
                }
                else if (Enum.TryParse(id, true, out tmpLockType))
                {
                    tmpElement = new Lock(id, x, y, o, h, uniqueId);
                }
                else if (Enum.TryParse(id, true, out tmpMonstertype))
                {
                    var newMonster = new Monster(id, x, y, o, h, uniqueId);
                    tmpCell.Monster = newMonster;
                    elements.Add(uniqueId, newMonster);
                }
                else if (Enum.TryParse(id, true, out tmpPressurePlateType))
                {
                    tmpElement = new PressurePlate(id, x, y, o, h, uniqueId);
                }
                else if (Enum.TryParse(id, true, out tmpTextType))
                {
                    tmpElement = new Text(id, x, y, o, h, uniqueId);
                }
                else if (Enum.TryParse(id, true, out tmpTrapDoorType))
                {
                    tmpElement = new TrapDoor(id, x, y, o, h, uniqueId);
                }
                else if (Enum.TryParse(id, true, out tmpLanternType))
                {
                    tmpElement = new Lantern(id, x, y, o, h, uniqueId);
                }
                else if (Enum.TryParse(id, true, out tmpAltarType))
                {
                    tmpElement = new Altar(id, x, y, o, h, uniqueId);
                }
                else if (Enum.TryParse(id, true, out tmpWallEffectType))
                {
                    tmpElement = new WallEffect(id, x, y, o, h, uniqueId);
                }
                else if (Enum.TryParse(id, true, out tmpWeaponType))
                {
                    tmpElement = new Weapon(id, x, y, o, h, uniqueId);
                }
                else if (Enum.TryParse(id, true, out tmpArmorType))
                {
                    tmpElement = new Armor(id, x, y, o, h, uniqueId);
                }
                else if (Enum.TryParse(id, true, out tmpFoodType))
                {
                    tmpElement = new Food(id, x, y, o, h, uniqueId);
                }
                else if (Enum.TryParse(id, true, out tmpPotionType))
                {
                    tmpElement = new Potion(id, x, y, o, h, uniqueId);
                }
                else
                {
                    tmpElement = new Item(id, x, y, o, h, uniqueId);
                }

                if (tmpElement != null)
                {
                    tmpCell.AddElement(tmpElement);
                    elements.Add(uniqueId, tmpElement);
                }
            }

            foreach (Match m in matchsAttribute)
            {
                Char[] delimit = delimitersAttributes;
                if (m.Value.Contains("addConnector"))
                {
                    delimit = delimitersAttributes2;
                }

                string[] split = m.Value.Split(delimit, StringSplitOptions.RemoveEmptyEntries);

                MapElement tmpElement = null;
                if (elements.TryGetValue(split[0], out tmpElement))
                {
                    if (split[2].Contains("addConnector"))
                    {
                        tmpElement.addConnector(split[3], split[4], split[5]);
                    }
                    else if (split[2].Contains("addItem") || split[2].Contains("setWallText") || split[2].Contains("setOpenedBy") || split[2].Contains("setState") || split[2].Contains("setDoorState") || split[2].Contains("setScrollText"))
                    {
                        tmpElement.setAttribute(split[2], split[3]);
                    }
                    else if (split[2].Contains("disable"))
                    {
                        tmpElement.setAttribute(split[2], "");
                    }
                    else // True or false
                    {
                        tmpElement.setAttribute(split[2], split[3].Contains("true") ? true : false);
                    }
                }
            }

            Map map = new Map(name, width, height)
            {
                StartPoint   = startingPoint,
                EndPointList = endingPoints,
                AmbientTrack = ambientTrack,
                LevelCoord   = levelCoord,
                Cells        = cells,
                Tiles        = new ArrayList(tiles), //FIXME
                Elements     = elements,
            };

            CurrentMap = map;

            return(map);
        }
 public virtual IRenderer GetAlcoveDecorationRenderer(Alcove alcove, Texture2D wallTexture)
 {
     return(new AlcoveRenderer(wallTexture, alcove));
 }