コード例 #1
0
        public void BuildRoom()
        {
            // Game Objects
            this.objects = new Dictionary <byte, Dictionary <int, GameObject> > {
                [(byte)LoadOrder.Platform]     = new Dictionary <int, GameObject>(),
                [(byte)LoadOrder.Enemy]        = new Dictionary <int, GameObject>(),
                [(byte)LoadOrder.Item]         = new Dictionary <int, GameObject>(),
                [(byte)LoadOrder.TrailingItem] = new Dictionary <int, GameObject>(),
                [(byte)LoadOrder.Character]    = new Dictionary <int, GameObject>(),
                [(byte)LoadOrder.Projectile]   = new Dictionary <int, GameObject>()
            };

            // Object Coordination and Cleanup
            this.markedForAddition = new List <GameObject>();
            this.markedForRemoval  = new List <GameObject>();

            // Build Tilemap with Correct Dimensions
            short xCount, yCount;

            RoomGenerate.DetectRoomSize(Systems.handler.levelContent.data.rooms[roomID], out xCount, out yCount);

            this.tilemap = new TilemapLevel(xCount, yCount);

            // Additional Components
            this.colors      = new ColorToggles();
            this.trackSys    = new TrackSystem();
            this.roomExits   = new RoomExits();
            this.queueEvents = new QueueEvent(this);

            // Generate Room Content (Tiles, Objects)
            RoomGenerate.GenerateRoom(this, Systems.handler.levelContent, roomID);

            // Prepare the Full Track System
            this.trackSys.SetupTrackSystem();
        }
コード例 #2
0
        public void AddExitThrowsArgumentNullExceptionIfRoomIsNull()
        {
            RoomExits roomExits = new RoomExits();
            DoorWay   doorway   = new DoorWay
            {
                Direction = Direction.North
            };

            roomExits.AddExit(doorway, null);
        }
コード例 #3
0
        public void GetRoomForExitReturnsNullForNonExistentRoom_UnLockedDoor()
        {
            var game  = new Game();
            var room  = new Room("testRoom", "this is a test room.", game);
            var room2 = new Room("testRoom2", "this is a test room.", game);

            var roomExits = new RoomExits();

            roomExits.AddExit(Direction.North, room);
            roomExits.AddExit(Direction.South, room2);

            Assert.AreEqual(null, roomExits.GetRoomForExit(Direction.East));
            Assert.AreEqual(null, roomExits.GetRoomForExit(Direction.West));
        }
コード例 #4
0
        public void GetRoomForExitReturnsValidRoom_UnLockedDoor()
        {
            var game  = new Game();
            var room  = new Room("testRoom", "this is a test room.", game);
            var room2 = new Room("testRoom2", "this is a test room.", game);

            var roomExits = new RoomExits();

            roomExits.AddExit(Direction.North, room);
            roomExits.AddExit(Direction.South, room2);

            Assert.AreEqual(room, roomExits.GetRoomForExit(Direction.North));
            Assert.AreEqual(room2, roomExits.GetRoomForExit(Direction.South));
        }
コード例 #5
0
        public void AddExitThrowsInvalidOperationExceptionIfSameDirectionUsedMoreThanOnce_UnLockedDoor()
        {
            var game  = new Game();
            var room  = new Room("testRoom", "this is a test room.", game);
            var room2 = new Room("testRoom2", "this is a test room.", game);

            var roomExits = new RoomExits();

            roomExits.AddExit(Direction.North, room);
            roomExits.AddExit(Direction.North, room2);

            roomExits.AddExit(Direction.South, room);
            roomExits.AddExit(Direction.South, room2);
        }
コード例 #6
0
        public void AddExitForNorthAddsTheExit_UnLockedDoor()
        {
            var game = new Game();
            var room = new Room("testRoom", "this is a test room.", game);

            var roomExits = new RoomExits();

            roomExits.AddExit(Direction.North, room);

            var savedRoom = roomExits.GetRoomForExit(Direction.North);

            Assert.AreEqual(room, savedRoom);
            Assert.AreSame("testRoom", savedRoom.Name);
            Assert.AreSame("this is a test room.", savedRoom.Description);
        }
コード例 #7
0
        public Exits GetRoomExit(string direction = null)
        {
            GetRoomExits();
            Exits result = null;

            if (!string.IsNullOrEmpty(direction))
            {
                result = RoomExits.Where(e => e.Direction.ToUpper() == direction.ToUpper()).SingleOrDefault();
            }
            else
            {
                result = RoomExits.FirstOrDefault();
            }

            return(result);
        }
コード例 #8
0
        public void AddExitForNorthAddsTheExit()
        {
            var game = new Game();
            var room = new Room("testRoom", "this is a test room.", game);

            var roomExits = new RoomExits();

            DoorWay doorway = new DoorWay
            {
                Direction = Direction.North
            };

            roomExits.AddExit(doorway, room);

            var savedRoom = roomExits.GetRoomForExit(Direction.North);

            Assert.AreEqual(room, savedRoom);
            Assert.AreSame("testRoom", savedRoom.Name);
            Assert.AreSame("this is a test room.", savedRoom.Description);
        }
コード例 #9
0
        public void GetRoomForExitReturnsValidRoom()
        {
            var game  = new Game();
            var room  = new Room("testRoom", "this is a test room.", game);
            var room2 = new Room("testRoom2", "this is a test room.", game);

            var roomExits = new RoomExits();

            DoorWay doorway = new DoorWay
            {
                Direction = Direction.North
            };

            DoorWay doorway2 = new DoorWay
            {
                Direction = Direction.South
            };

            roomExits.AddExit(doorway, room);
            roomExits.AddExit(doorway2, room2);

            Assert.AreEqual(room, roomExits.GetRoomForExit(Direction.North));
            Assert.AreEqual(room2, roomExits.GetRoomForExit(Direction.South));
        }
コード例 #10
0
        public void AddExitThrowsInvalidOperationExceptionIfSameDirectionUsedMoreThanOnce()
        {
            var game  = new Game();
            var room  = new Room("testRoom", "this is a test room.", game);
            var room2 = new Room("testRoom2", "this is a test room.", game);

            var roomExits = new RoomExits();

            DoorWay doorway = new DoorWay
            {
                Direction = Direction.North
            };

            DoorWay doorway2 = new DoorWay
            {
                Direction = Direction.South
            };

            roomExits.AddExit(doorway, room);
            roomExits.AddExit(doorway, room2);

            roomExits.AddExit(doorway2, room);
            roomExits.AddExit(doorway2, room2);
        }
コード例 #11
0
ファイル: Room.cs プロジェクト: josh28/risen
        public virtual Room GetRoomInDirectionOf(int exitTemplateId)
        {
            var roomExit = RoomExits.SingleOrDefault(o => o.Exit.ExitTemplate.Id == exitTemplateId);

            return(roomExit != null ? roomExit.DestinationRoom : null);
        }
コード例 #12
0
ファイル: Move.cs プロジェクト: dmbyer/Hedron
        public CommandResult Execute(CommandEventArgs commandEventArgs, Constants.EXIT direction)
        {
            try
            {
                base.Execute(commandEventArgs);
            }
            catch (CommandException ex)
            {
                return(ex.CommandResult);
            }

            var output = new OutputBuilder();
            var entity = commandEventArgs.Entity;

            Room sourceRoom = entity.GetInstanceParentRoom();

            // Don't move entity if it's not already in a room
            if (sourceRoom != null && entity != null)
            {
                RoomExits exits = sourceRoom.Exits;
                Room      destRoom;

                switch (direction)
                {
                case Constants.EXIT.NORTH:
                    destRoom = DataAccess.Get <Room>(exits.North, CacheType.Instance);
                    break;

                case Constants.EXIT.EAST:
                    destRoom = DataAccess.Get <Room>(exits.East, CacheType.Instance);
                    break;

                case Constants.EXIT.SOUTH:
                    destRoom = DataAccess.Get <Room>(exits.South, CacheType.Instance);
                    break;

                case Constants.EXIT.WEST:
                    destRoom = DataAccess.Get <Room>(exits.West, CacheType.Instance);
                    break;

                case Constants.EXIT.UP:
                    destRoom = DataAccess.Get <Room>(exits.Up, CacheType.Instance);
                    break;

                case Constants.EXIT.DOWN:
                    destRoom = DataAccess.Get <Room>(exits.Down, CacheType.Instance);
                    break;

                default:
                    output.Append("You cannot go that way.");
                    return(CommandResult.Failure(output.Output));
                }

                if (destRoom != null)
                {
                    sourceRoom.Animates.RemoveEntity(entity.Instance, entity);
                    destRoom.Animates.AddEntity(entity.Instance, entity, false);

                    output.Append(
                        new Look()
                        .Execute(new CommandEventArgs("", commandEventArgs.Entity, commandEventArgs.PrivilegeOverride))
                        .ResultMessage);

                    return(CommandResult.Success(output.Output));
                }
                else
                {
                    // Create the room if Autodig is set
                    if (entity.GetType() == typeof(Player))
                    {
                        var player = (Player)entity;

                        if (player.Configuration.Autodig)
                        {
                            sourceRoom = DataAccess.Get <Room>(sourceRoom.Prototype, CacheType.Prototype);

                            if (sourceRoom == null)
                            {
                                return(CommandResult.Failure("You must be in a room with a saved prototype before you may dig."));
                            }

                            var sourceArea = entity.GetInstanceParentArea();
                            if (sourceArea == null)
                            {
                                return(CommandResult.Failure("You must be in an area before you may dig."));
                            }

                            var protoArea = DataAccess.Get <Area>(sourceArea.Prototype, CacheType.Prototype);
                            if (protoArea == null)
                            {
                                return(CommandResult.Failure("You must be in an area with a saved prototype before you may dig."));
                            }

                            destRoom = Room.NewPrototype((uint)protoArea.Prototype);
                            destRoom.Spawn(false, (uint)sourceArea.Instance);

                            RoomExits.ConnectRoomExits(sourceRoom, destRoom, direction, true, true);

                            // Now move the entity to the new room
                            output.Append($"You dig {direction.ToString().ToLower()}.");
                            output.Append(new MoveEntity().Execute(commandEventArgs).ResultMessage);

                            return(CommandResult.Success(output.Output));
                        }
                    }

                    output.Append("You cannot go that way.");
                    return(CommandResult.Failure(output.Output));
                }
            }

            // Return failure if entity was not already in a room or there was no entity to move
            output.Append("You cannot go that way.");
            return(CommandResult.Failure(output.Output));
        }
コード例 #13
0
ファイル: RoomsTab.cs プロジェクト: jandar78/Novus
        private void AddAdjacentRoom(RoomExits direction) {
			//todo:we should see if they haven't saved and prompt them too if they are going to be adding a new room
			//let's be smart and detect changes before we prompt them to save. use events wisely.
            string roomID = GetNewRoomId();
			roomIdValue.Text = roomID;
			//todo:we need to add this room as an exit to the previous room, so we'll have to keep it in memory somewhere
			//until they hit save for this room
			roomLoad_Click(null, null);
        }
コード例 #14
0
ファイル: TreeNode.cs プロジェクト: jandar78/Novus
        private void AddAdjacentRoomInDirection(TreeNode currentNode, IRoom room, RoomExits direction) {

            if (room.GetRoomExit(direction) != null) {
                if (currentNode.Parent != null && room.GetRoomExit(direction).availableExits[direction].Id != currentNode.Parent.ID) {
                    var newNode = new TreeNode(room.GetRoomExit(direction).availableExits[direction]);
                    if (!_unvisitedNodes.Contains(newNode)) {
                        if (!currentNode.AdjacentNodes.ContainsKey(direction.ToString())) {
                            currentNode.AdjacentNodes.Add(direction.ToString(), newNode);
                            currentNode.AdjacentNodes[direction.ToString()].Parent = currentNode;
                            AddNode(newNode);
                        }

                    }
                }
            }
        }
コード例 #15
0
ファイル: Room.cs プロジェクト: jandar78/Novus
        public IExit GetRoomExit(RoomExits direction = Interfaces.RoomExits.None) {
            GetRoomExits();
            IExit result = null;
            if (direction != Interfaces.RoomExits.None) {
                result = RoomExits.Where(e => e.Direction.ToUpper() == direction.ToString().ToUpper()).SingleOrDefault();
            } else {
                result = RoomExits.FirstOrDefault();
            }

            return result;
        }