Esempio n. 1
0
    public static Exits GetOppositeExit(Exits exit)
    {// Gets the exit opposite of the one inputed.
        switch (exit)
        {
        case Exits.NORTH:
        {
            return(Exits.SOUTH);
        }

        case Exits.SOUTH:
        {
            return(Exits.NORTH);
        }

        case Exits.EAST:
        {
            return(Exits.WEST);
        }

        case Exits.WEST:
        {
            return(Exits.EAST);
        }

        default:
        {
            return(Exits.NONE);
        }
        }
    }
Esempio n. 2
0
    Vector3 GetNewPosition(Vector3 oldPosition, Exits exit)
    {// Returns the necessary offset to move to match the exit
        switch (exit)
        {
        case Exits.NORTH:
        {
            return(oldPosition + new Vector3(roomSize_, 0f, 0f));
        }

        case Exits.SOUTH:
        {
            return(oldPosition - new Vector3(roomSize_, 0f, 0f));
        }

        case Exits.EAST:
        {
            return(oldPosition - new Vector3(0f, 0f, roomSize_));
        }

        case Exits.WEST:
        {
            return(oldPosition + new Vector3(0f, 0f, roomSize_));
        }

        default:
        {
            return(oldPosition);
        }
        }
    }
Esempio n. 3
0
    public static Vector2 GetNewCoordinates(Vector2 oldCoordinates, Exits exit)
    {
        switch (exit)
        {
        case Exits.NORTH:
        {
            return(oldCoordinates + new Vector2(1, 0));
        }

        case Exits.SOUTH:
        {
            return(oldCoordinates - new Vector2(1, 0));
        }

        case Exits.EAST:
        {
            return(oldCoordinates - new Vector2(0, 1));
        }

        case Exits.WEST:
        {
            return(oldCoordinates + new Vector2(0, 1));
        }

        default:
        {
            return(oldCoordinates);
        }
        }
    }
Esempio n. 4
0
 override protected void CallOnLoad()
 {
     bot.SetPosition(11, 11, "up");
     WallBuild.Vertical(10, 10, 2, Walls, this);
     WallBuild.Vertical(12, 10, 2, Walls, this);
     Exits.Add(new Exit(11, 9, this, new L2()));
 }
Esempio n. 5
0
    Room SpawnRoom(RoomData nextRoomData, Room previousRoom = null, Exits exit = Exits.NONE)
    {     // Spawns a room and aligns it with the exit in question
        if (exit != Exits.NONE)
        { // Checks to make sure the exit works
            if (!nextRoomData.ContainsExit(exit))
            {
                Debug.LogWarning("Tried to connect room (" + nextRoomData + ") that does not contain exit " + GetOppositeExit(exit));
                return(null);
            }
        }
        ;
        // This allows for the first room to spawn
        Vector3 oldPosition = transform.position;

        if (previousRoom != null)
        {
            oldPosition = previousRoom.transform.position;
        }
        GameObject returnRoomGO = GameObject.Instantiate(nextRoomData.prefab_, GetNewPosition(oldPosition, exit), Quaternion.identity);
        Room       returnRoom   = returnRoomGO.GetComponent <Room>();

        // Set room type, and room's new coordinates
        returnRoom.roomType_ = nextRoomData;
        if (previousRoom != null)
        {
            returnRoom.coordinate_     = GetNewCoordinates(coordinates_[previousRoom], GetOppositeExit(exit));
            returnRoom.gameObject.name = returnRoom.roomType_.name_ + "(" + returnRoom.coordinate_ + ")";
        }
        return(returnRoom);
    }
Esempio n. 6
0
    public Exits GetRandomFreeConnection()
    {
        List <Exits> freeExits = new List <Exits> {
        };

        foreach (Exits exit in roomType_.exits_)
        {
            if (!connectedRooms_.ContainsKey(exit))
            {
                // Check if the proposed new location already has something
                if (FacilitySpawner.TryCoordinatesStatic(this, exit))
                {
                    // Check if the proposed location would put it outside of the max/min bounds
                    Vector2 newCoords = FacilitySpawner.GetNewCoordinates(coordinate_, exit);
                    if (FacilitySpawner.instance_.TryMaxSize(newCoords))
                    {
                        freeExits.Add(exit);
                    }
                    ;
                }
                ;
            }
        }
        if (freeExits.Count > 0)
        {
            Exits randomExit = freeExits[Random.Range(0, freeExits.Count)];
            Debug.Log("Found free exit " + randomExit + " from room " + this);
            return(randomExit);
        }
        else
        {
            Debug.Log("Found no free exits in room " + this);
            return(Exits.NONE);
        }
    }
Esempio n. 7
0
        // this is being called from game services
        public string Use(IItem item)
        {
            if (LockedExits.ContainsKey(item))
            {
                //unlock with item, remove from one dict, place in other
                Exits.Add(LockedExits[item].Key, LockedExits[item].Value);
                LockedExits.Remove(item);
                string actionMessage = "";
                switch (item.Name.ToLower())
                {
                case "appointment":
                    actionMessage = @"You have unlocked the door to the pharmacy.
    Now that it is your appointment time,enter the pharmacy and get a vaccination";
                    break;

                case "receipt":
                    actionMessage = @"You have unlocked the door to leave the store.
    Now that you have checked out, you may leave";
                    break;

                default:
                    actionMessage = "You have unlocked a room";
                    break;
                }
                return(actionMessage);
            }
            //maybe have else if for local items like light switch
            return("No use for that here");
        }
Esempio n. 8
0
 public bool AttemptConnectRoom(Room room, Exits exit, bool connectReverse = false)
 { //This should not happen, as we should check for exits first
     if (!roomType_.ContainsExit(exit))
     {
         Debug.LogWarning("Cannot connect " + room + " to exit " + exit + ", " + roomType_.name_ + " does not have it");
         return(false);
     }
     ;
     if (connectedRooms_.ContainsKey(exit))
     { // Already contains the exit
         Debug.Log("Cannot connect to exit " + exit + ", " + this + " already has a connection. (connecting reverse: " + connectReverse + ")");
         return(false);
     }
     else
     {
         connectedRooms_.Add(exit, room);
         if (connectReverse)
         {
             room.AttemptConnectRoom(this, FacilitySpawner.GetOppositeExit(exit));
         }
         connectedRoomsDebug_.Add(room.gameObject);
         connectedRoomsDebugDirs_.Add(exit);
         Debug.Log("Connected the exit " + exit + "of this room (" + this + ") to " + room + "(connectReverse: " + connectReverse + ")");
         return(true);
     }
 }
Esempio n. 9
0
        override protected void CallOnLoad()
        {
            bot.SetPosition(19, 19, "up");

            int x = 16;
            int y = 17;

            for (int i = 0; i < 5; i++)
            {
                WallBuild.Horizontal(x, y, 3, Walls, this);
                WallBuild.Horizontal(x + 1, y - 2, 3, Walls, this);
                x -= 3;
                y -= 3;
            }
            x = 15;
            y = 15;
            for (int i = 0; i < 5; i++)
            {
                WallBuild.Vertical(x, y, 3, Walls, this);
                WallBuild.Vertical(x + 5, y, 3, Walls, this);
                x -= 3;
                y -= 3;
            }
            WallBuild.Vertical(18, 18, 3, Walls, this);
            WallBuild.Vertical(20, 18, 3, Walls, this);
            WallBuild.Vertical(3, 1, 2, Walls, this);
            WallBuild.Vertical(5, 1, 2, Walls, this);

            Exits.Add(new Exit(4, 4, this, new L6()));
        }
Esempio n. 10
0
    public Vector2 getNextRoomCoordinate(Exits exit)
    {
        int newSX = 0;
        int newSY = 0; //coordinates for the next room

        //5 é o comprimento do tunel, TODO change this
        switch (exit)
        {
        case Exits.UP:
            newSX = sX;
            newSY = sY + lenY + Tunnel.DEFAULT_LENGTH;
            break;

        case Exits.DOWN:
            newSX = sX;
            newSY = sY - lenY - Tunnel.DEFAULT_LENGTH;
            break;

        case Exits.LEFT:
            newSX = sX - lenX - Tunnel.DEFAULT_LENGTH;
            newSY = sY;
            break;

        case Exits.RIGHT:
            newSX = sX + lenX + Tunnel.DEFAULT_LENGTH;
            newSY = sY;
            break;
        }
        return(new Vector2(newSX, newSY));
    }
Esempio n. 11
0
    RoomData GetRandomBlockerRoom(Exits requiredExit, bool tileEmpty = true)
    {
        // Gets a random blocked/end room from available ones with all of the required exits

        List <RoomData> matchingRooms = new List <RoomData> {
        };
        RoomData returnRoom           = null;

        foreach (RoomData data in data_.endingRooms_)
        {
            if (data.ContainsExit(requiredExit))
            {
                // If tile is empty, we add any - otherwise only blockers that don't take up the whole space
                if (tileEmpty)
                {
                    matchingRooms.Add(data);
                }
                else if (!tileEmpty && !data.occupiesWholeTile)
                {
                    matchingRooms.Add(data);
                }
            }
            ;
        }
        if (matchingRooms.Count > 0)
        {
            returnRoom = matchingRooms[Random.Range(0, matchingRooms.Count)];
        }
        Debug.Log("Returning ENDING room " + returnRoom + "with the exit " + requiredExit + " to fit " + GetOppositeExit(requiredExit));
        return(returnRoom);
    }
Esempio n. 12
0
        private void ProcessSpecialTileProps(int x, int y, byte tileId, SCTileDef tileDef)
        {
            var poi = new SCPointOfInterest
            {
                Coords  = new SCCoords(x, y),
                TileDef = tileDef,
                TileId  = tileId
            };

            if ((tileDef.OWBitFlags & SCBitFlags.Enter) > 0)
            {
                var overworldTeleport = (OverworldTeleportIndex)(tileDef.TileProp.Byte2 & 0x3F);
                var teleDef           = enter[(int)overworldTeleport];
                var t = new SCTeleport {
                    Coords = poi.Coords, Type = SCPointOfInterestType.OwEntrance, TargetMap = teleDef.Map, TargetCoords = new SCCoords {
                        X = teleDef.X, Y = teleDef.Y
                    }, OverworldTeleport = overworldTeleport
                };
                Exits.Add(t);

                poi.Type     = SCPointOfInterestType.Tele;
                poi.Teleport = t;
                PointsOfInterest.Add(poi);
            }
            else if ((tileDef.OWBitFlags & SCBitFlags.Caravan) > 0)
            {
                poi.Type   = SCPointOfInterestType.Shop;
                poi.ShopId = 69;
                PointsOfInterest.Add(poi);
            }
        }
Esempio n. 13
0
        public void ParseTransitions()
        {
            var stateTransitionTag = Element.Element(XName.Get("State.Transitions", Machine.Namespaces.DefaultNamespace));

            if (stateTransitionTag == null)
            {
                return;
            }

            var transitionTags = stateTransitionTag.Elements(XName.Get("Transition", Machine.Namespaces.DefaultNamespace));

            foreach (var transitionTag in transitionTags)
            {
                var toValue = transitionTag.Attribute("To")?.Value ?? string.Empty;
                if (string.IsNullOrWhiteSpace(toValue))
                {
                    var transitionToTag = transitionTag.Element(XName.Get("Transition.To", Machine.Namespaces.DefaultNamespace));
                    if (transitionToTag == null)
                    {
                        continue;
                    }

                    var childState = transitionToTag.Element(XName.Get("State", Machine.Namespaces.DefaultNamespace));
                    var childName  = childState.Attribute(XName.Get("Name", Machine.Namespaces.LookupNamespace("x"))).Value;
                    Exits.Add(Machine.GetState(childName));
                }
                else
                {
                    Exits.Add(Machine.GetState(ExtractReference(toValue)));
                }
            }
        }
Esempio n. 14
0
 /// <summary>
 /// Set all the exits
 /// </summary>
 /// <param name="exits"></param>
 public void SetExits(Exits exits)
 {
     foreach (var exit in exits)
     {
         AddExit(exit.Key, exit.Value);
     }
 }
Esempio n. 15
0
        Exits ParseExits(string exitString)
        {
            Exits exits = Exits.None;

            foreach (var exit in exitString.Split(','))
            {
                switch (exit)
                {
                case "north":
                    exits |= Exits.North;
                    break;

                case "south":
                    exits |= Exits.South;
                    break;

                case "east":
                    exits |= Exits.East;
                    break;

                case "west":
                    exits |= Exits.West;
                    break;

                default:
                    break;
                }
            }

            return(exits);
        }
Esempio n. 16
0
        public Tile(string filename, XElement properties)
        {
            ImageName  = Path.GetFileNameWithoutExtension(filename);
            BaseOffset = 15.0f;

            int centreX = 50, centreY = 30;

            if (properties != null)
            {
                foreach (var propElement in properties.Elements())
                {
                    switch (propElement.Attribute("name").Value)
                    {
                    case "centre-x":
                        centreX = Convert.ToInt32(propElement.Attribute("value").Value);
                        break;

                    case "centre-y":
                        centreY = Convert.ToInt32(propElement.Attribute("value").Value);
                        break;

                    case "exits":
                        ValidExits = ParseExits(propElement.Attribute("value").Value);
                        Console.WriteLine("Exits: {0} {1}", ImageName, ValidExits);
                        break;

                    default:
                        break;
                    }
                }
            }

            Centre = new CoreGraphics.CGPoint(centreX, centreY);
        }
Esempio n. 17
0
 public string Use(IItem item)
 {
     if (LockedExits.ContainsKey(item))
     {
         Exits.Add(LockedExits[item].Key, LockedExits[item].Value);
         LockedExits.Remove(item);
         if (item.Name.ToLower() == "machete")
         {
             return("You use the machete and slash anything in your way! You can now see the path to the east.");
         }
         if (item.Name.ToLower() == "torch and matches")
         {
             return("You can now see around the cave! There's a wooden paddle over there in the corner! You also see an exit to the north.");
         }
         if (item.Name.ToLower() == "row boat")
         {
             return("You are now in the row boat. This rowboat is pretty worn...Will it make it to the ship?");
         }
         if (item.Name.ToLower() == "wooden paddle")
         {
             return("You are now able to row south towards the ship!");
         }
     }
     return("No use for that here");
 }
Esempio n. 18
0
        /// <summary>
        /// Emits the value code.
        /// </summary>
        /// <param name="emitter">The emitter.</param>
        /// <param name="exits">The non-exceptional exit targets.</param>
        private void EmitValue(Emitter emitter, Exits exits)
        {
            switch (this.Operator)
            {
            case "=": emitter.Emit(this.Value, exits); break;

            case "+=": emitter.Emit(this.Value, exits).Emit(Opcode.Add); break;

            case "-=": emitter.Emit(this.Value, exits).Emit(Opcode.Subtract); break;

            case "*=": emitter.Emit(this.Value, exits).Emit(Opcode.Multiply); break;

            case "/=": emitter.Emit(this.Value, exits).Emit(Opcode.Divide); break;

            case "%=": emitter.Emit(this.Value, exits).Emit(Opcode.Remainder); break;

            case "&=": emitter.Emit(this.Value, exits).Emit(Opcode.And); break;

            case "|=": emitter.Emit(this.Value, exits).Emit(Opcode.Or); break;

            case "^=": emitter.Emit(this.Value, exits).Emit(Opcode.Xor); break;

            default: Debug.Fail("Unexpected operator"); break;
            }
        }
Esempio n. 19
0
        public string[] View()
        {
            StringBuilder stringBuilder = new StringBuilder();
            List <string> view          = new List <string>();

            view.Add(Name);
            view.Add("");
            view.Add(Description);
            view.Add("");
            if (Exits.Any())
            {
                stringBuilder.Append("Exits: " + Function.GetNames(Exits.ToArray()));
                view.Add(stringBuilder.ToString());
                stringBuilder.Clear();
            }
            if (Mobs.Any())
            {
                stringBuilder.Append("Mobs: " + Function.GetNames(Mobs.ToArray()));
                view.Add(stringBuilder.ToString());
                stringBuilder.Clear();
            }
            if (Players.Any())
            {
                stringBuilder.Append("Players: " + Function.GetNames(Players.ToArray()));
                view.Add(stringBuilder.ToString());
                stringBuilder.Clear();
            }
            if (Items.Any())
            {
                // items on floor; need to search for duplicates, pronouns, etc., and display them in friendly grammar form
                // You see (an) orange, 23 pumpkin seed(s), (a) hungry cat, Toetag('s) nose.
            }
            return(view.ToArray());
        }
Esempio n. 20
0
 /**
  *  Add events for all these list modifier methods
  *
  */
 public void AddExit(Exits direction)
 {
     if (!_exits.Contains(direction))
     {
         _exits.Add(direction);
     }
 }
Esempio n. 21
0
        private GridLocation GetNextLocation(GridLocation currentGridLocation, Exits exit)
        {
            switch (exit)
            {
            case Exits.North:
                return(new GridLocation(currentGridLocation.X, currentGridLocation.Y - 1, currentGridLocation.Z));

            case Exits.East:
                return(new GridLocation(currentGridLocation.X + 1, currentGridLocation.Y, currentGridLocation.Z));

            case Exits.South:
                return(new GridLocation(currentGridLocation.X, currentGridLocation.Y + 1, currentGridLocation.Z));

            case Exits.West:
                return(new GridLocation(currentGridLocation.X - 1, currentGridLocation.Y, currentGridLocation.Z));

            case Exits.Up:
                return(new GridLocation(currentGridLocation.X, currentGridLocation.Y, currentGridLocation.Z + 1));

            case Exits.Down:
                return(new GridLocation(currentGridLocation.X, currentGridLocation.Y, currentGridLocation.Z - 1));
            }

            return(null);
        }
Esempio n. 22
0
        public IRoom Move(string direction)
        {
            IRoom room = this;

            if (room is TrapRoom && Locked == true)
            {
                if (room.Name == "Hidden Tunnel")
                {
                    System.Console.WriteLine("Its took dark to see");
                }
                else if (room.Name == "Pub")
                {
                    System.Console.WriteLine("You should try to relax a little.");
                }
                else
                {
                    // TrapRoom trap = (TrapRoom)room;
                    // System.Console.WriteLine("Locked door find a way out");
                    // return this;
                }
                return(this);
            }
            else
            {
                if (Exits.ContainsKey(direction))
                {
                    return(Exits[direction]);
                }
                return(this);
            }
        }
Esempio n. 23
0
 public IRoom Go(string destination)
 {
     if (Exits.ContainsKey(destination))
     {
         return(Exits[destination]);
     }
     return(this);
 }
Esempio n. 24
0
 internal int GetExit(Direction theInput)
 {
     if (Exits.ContainsKey(theInput))
     {
         return(Exits[theInput]);
     }
     return(-1);
 }
Esempio n. 25
0
 public IRoom Go(string direction)
 {
     if (Exits.ContainsKey(direction))
     {
         return(Exits[direction]);
     }
     return(this);
 }
Esempio n. 26
0
 public void removeDoor(Exits exit)
 {
     foreach (Vector2 doorCoord in getDoorSlots(exit))
     {
         //replace for wall
         grid[doorCoord] = wallTiles[0];
     }
 }
Esempio n. 27
0
 /// <summary>
 /// Emits the code and data.
 /// </summary>
 /// <param name="emitter">The emitter.</param>
 /// <param name="exits">The non-exceptional exit targets.</param>
 public override void Emit(Emitter emitter, Exits exits)
 {
     emitter.Emit(Opcode.LoadReceiver);
     emitter.Emit(Opcode.LoadGlobal, value: emitter.GetOrAdd(this.Identifier.Name));
     this.Identifier.EmitStore(emitter, this.Value.Emit, exits);
     emitter.Emit(Opcode.StoreElement);
     emitter.Emit(Opcode.Drop, value: 1);
 }
Esempio n. 28
0
 public void RemoveExit()
 {
     if (SelectedExit != null)
     {
         Exits.Remove(SelectedExit);
     }
     SelectedExit = null;
 }
Esempio n. 29
0
 /// <summary>
 /// Generates the door slots, replacing walls with floor tiles.
 /// </summary>
 /// <param name="exit"></param>
 public void generateDoor(Exits exit)
 {
     foreach (Vector2 doorCoord in getDoorSlots(exit))
     {
         //replace for tunnel entrance
         grid[doorCoord] = floorTiles[0];
     }
 }
Esempio n. 30
0
        // Move the player, and return a new level if applicable
        public LevelTransition MovePlayer(Player player, Constants.DIRECTION dir)
        {
            LevelTransition  newLevel  = null;
            Tuple <int, int> playerLoc = player.GetCoords();
            char             entity    = Map[playerLoc.Item1, playerLoc.Item2];
            int xToCheck = playerLoc.Item1;
            int yToCheck = playerLoc.Item2;

            switch (dir)
            {
            case Constants.DIRECTION.NORTH:
                xToCheck--;
                break;

            case Constants.DIRECTION.EAST:
                yToCheck++;
                break;

            case Constants.DIRECTION.SOUTH:
                xToCheck++;
                break;

            case Constants.DIRECTION.WEST:
                yToCheck--;
                break;
            }

            if (Map[xToCheck, yToCheck] == (char)Constants.MAP_CHARS.EMPTY)
            {
                Map[xToCheck, yToCheck] = entity;
                Map[playerLoc.Item1, playerLoc.Item2] = (char)Constants.MAP_CHARS.EMPTY;
                player.SetCoords(Tuple.Create(xToCheck, yToCheck));
                MoveEnemies(player);
                RunModifiers(player);
            }
            else if (Map[xToCheck, yToCheck] == (char)Constants.MAP_CHARS.EXIT)
            {
                newLevel = Exits.Where(x => x.ExitLocation.Item1 == xToCheck && x.ExitLocation.Item2 == yToCheck).FirstOrDefault();
                ResetCell(player.GetCoords());
            }
            else if (Map[xToCheck, yToCheck] == (char)Constants.MAP_CHARS.ITEMBOX)
            {
                ItemBox item = ItemBoxs.Where(x => x.XCoord == xToCheck && x.YCoord == yToCheck).First();

                if (item != null)
                {
                    player.ConsumeItemBox(item);
                    ItemBoxs.Remove(item);
                    Map[playerLoc.Item1, playerLoc.Item2] = (char)Constants.MAP_CHARS.EMPTY;
                    Map[xToCheck, yToCheck] = (char)Constants.MAP_CHARS.CHARACTER;
                    player.SetCoords(Tuple.Create(xToCheck, yToCheck));
                    MoveEnemies(player);
                    RunModifiers(player);
                }
            }

            return(newLevel);
        }