상속: MonoBehaviour
예제 #1
0
    private void Start()
    {
        templates = GameObject.FindGameObjectWithTag("Templates").GetComponent <DungeonPrefabs>();
        stats     = GameObject.FindGameObjectWithTag("Level").GetComponent <LevelGeneration>();
        door      = this.transform.GetChild(0).GetComponentInChildren <DoorWay>();

        //Invoke("Spawn", 0.1f);
    }
예제 #2
0
        public void AddExitThrowsArgumentNullExceptionIfRoomIsNull()
        {
            RoomExits roomExits = new RoomExits();
            DoorWay   doorway   = new DoorWay
            {
                Direction = Direction.North
            };

            roomExits.AddExit(doorway, null);
        }
예제 #3
0
        private static void InitializeGame()
        {
            _game = new Game();

            AddContentItems();

            _game.Prologue = _game.ContentManagement.RetrieveContentItem("Prologue");
            _game.HelpText = _game.ContentManagement.RetrieveContentItem("HelpText");
            _game.Parser.Nouns.Add("light", "lightswitch");
            _game.Parser.Nouns.Add("lights", "lightswitch");
            _game.Parser.Nouns.Add("lightswitch", "lightswitch");
            _game.Parser.Nouns.Add("switch", "lightswitch");
            _game.Parser.Nouns.Add("plantpot", "plantpot");
            _game.Parser.Nouns.Add("plant", "plantpot");
            _game.Parser.Nouns.Add("pot", "plantpot");

            _game.Parser.Nouns.Add("key", "key");
            _game.Parser.Nouns.Add("keys", "key");

            _game.Parser.Nouns.Add("doormat", "doormat");
            _game.Parser.Nouns.Add("mat", "doormat");

            _game.Parser.Nouns.Add("door", "door");
            _game.Parser.Nouns.Add("frontdoor", "door");

            _outside = new Outside(_game.ContentManagement.RetrieveContentItem("OutsideName"),
                                   _game.ContentManagement.RetrieveContentItem("OutsideDescription"), _game);

            _hallway = new Hallway(_game.ContentManagement.RetrieveContentItem("HallwayName"),
                                   _game.ContentManagement.RetrieveContentItem("HallwayDescription"), _game)
            {
                LightsOn             = false,
                LightsOffDescription = _game.ContentManagement.RetrieveContentItem("HallwayLightsOff")
            };

            _lounge = new Lounge(_game.ContentManagement.RetrieveContentItem("LoungeName"),
                                 _game.ContentManagement.RetrieveContentItem("LoungeDescription"), _game);

            _game.HintSystemEnabled = true;

            var doorway = new DoorWay
            {
                Direction = Direction.North,
                Locked    = true,
            };

            _outside.AddExit(doorway, _hallway);
            _hallway.AddExit(Direction.West, _lounge);

            _game.StartRoom   = _outside;
            _game.CurrentRoom = _outside;
        }
예제 #4
0
        public void AddExitCallsAddExitOnGameExits()
        {
            IGame game      = new Game();
            var   roomExits = new RoomExitsStub();
            var   room      = new Room(roomExits, game);
            var   room2     = new Room("name2", "description2", null);

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

            room.AddExit(doorway, room2, false);

            Assert.AreEqual(1, roomExits.AddExitCounter);
        }
예제 #5
0
        private void InitializeGame()
        {
            _game = new Game {
                Prologue = Prologue
            };

            _game.Parser.Nouns.Add("light", "lightswitch");
            _game.Parser.Nouns.Add("lightswitch", "lightswitch");
            _game.Parser.Nouns.Add("switch", "lightswitch");
            _game.Parser.Nouns.Add("plantpot", "plantpot");
            _game.Parser.Nouns.Add("plant", "plantpot");
            _game.Parser.Nouns.Add("pot", "plantpot");

            _game.Parser.Nouns.Add("key", "key");
            _game.Parser.Nouns.Add("keys", "key");

            _game.Parser.Nouns.Add("doormat", "doormat");
            _game.Parser.Nouns.Add("mat", "doormat");

            _game.Parser.Nouns.Add("door", "door");
            _game.Parser.Nouns.Add("frondoor", "door");

            _game.HintSystemEnabled = true;

            _outside = new Outside(OutsideName, OutsideDescription, _game);
            _hallway = new Hallway(HallwayName, HallwayDescription, _game)
            {
                LightsOn = false, LightsOffDescription = HallwayLightsOff
            };


            _lounge = new Room(LoungeName, LoungeDescription, _game);

            var doorway = new DoorWay
            {
                Direction = Direction.North,
                Locked    = true,
            };

            _outside.AddExit(doorway, _hallway);
            _hallway.AddExit(Direction.West, _lounge);

            _game.StartRoom   = _outside;
            _game.CurrentRoom = _outside;
        }
예제 #6
0
        public void AddExitCallsAddsExitWithReturn()
        {
            IGame game       = new Game();
            var   roomExits  = new RoomExitsStub();
            var   roomExits2 = new RoomExitsStub();

            var room  = new Room(roomExits, game);
            var room2 = new Room(roomExits2, game);

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

            room.AddExit(doorway, room2);

            Assert.AreEqual(1, roomExits.AddExitCounter);
            Assert.AreEqual(1, roomExits2.AddExitCounter);
        }
예제 #7
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);
        }
예제 #8
0
        public void MovingBetweenRoomsIncrementsNumberOfMoves()
        {
            IGame game  = new Game();
            var   room  = new Room(game);
            var   room2 = new Room("name2", "description2", game);

            game.CurrentRoom = room;
            game.StartRoom   = room;

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

            room.AddExit(doorway, room2, true);

            game.ProcessCommand("go north");
            game.ProcessCommand("go south");

            Assert.AreEqual(2, game.NumberOfMoves);
        }
예제 #9
0
        private void SetupRooms()
        {
            Outside         = new Outside(Game);
            Garage          = new Garage(Game);
            Kitchen         = new Kitchen(Game);
            DiningRoom      = new DiningRoom(Game);
            UpstairsHallway = new UpstairsHallway(Game);
            LargeBedroom    = new LargeBedroom(Game);
            SmallBedroom    = new SmallBedroom(Game);
            Bathroom        = new Bathroom(Game);

            Lounge  = new Lounge(Game);
            Hallway = new Hallway(Game)
            {
                LightsOn = false
            };

            var doorway = new DoorWay
            {
                Direction = Direction.North,
                Locked    = true,
            };

            var doorwayToGarage = new DoorWay
            {
                Direction = Direction.NorthWest,
                Locked    = true,
            };

            Outside.AddExit(doorway, Hallway);
            Outside.AddExit(doorwayToGarage, Garage);
            Hallway.AddExit(Direction.West, Lounge);
            Hallway.AddExit(Direction.North, Kitchen);
            Hallway.AddExit(Direction.NorthEast, UpstairsHallway);
            UpstairsHallway.AddExit(Direction.East, LargeBedroom);
            UpstairsHallway.AddExit(Direction.West, SmallBedroom);
            UpstairsHallway.AddExit(Direction.North, Bathroom);

            Kitchen.AddExit(Direction.East, DiningRoom);
        }
예제 #10
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));
        }
예제 #11
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);
        }
 public void AddExit(DoorWay door, IRoom room, bool locked = false, string objectToUnlock = "")
 {
     AddExitCounter++;
 }