Ejemplo n.º 1
0
        public StartingRoomCat(Location location)
            : base(location, GetDefaultName())
        {
            _Description = "A cat";
            _State = "curled up on the ground, sleeping";

            AddEventHandler(EventType.Emote, OnEventEmote);
            AddEventHandler(EventType.WorldConstructed, OnEventWorldConstructed);
        }
Ejemplo n.º 2
0
        public CombatEntity(Location location, string name)
            : base(location, name)
        {
            _InCombat = false;
            CombatPeriod = 2.0 + Program.RNG.NextDouble();
            _MaximumHealth = 40 + Program.RNG.Next(15);
            _CurrentHealth = _MaximumHealth;

            AddEventHandler(EventType.Leave, OnEventLeave);
        }
Ejemplo n.º 3
0
        public ForestBird(Location location)
            : base(location, GetDefaultName())
        {
            _Description = "A bird";

            string[] states = new string[] {
                "perched on a nearby branch",
                "flying around nearby",
                "pecking around for worms"
            };

            _State = states[Program.RNG.Next(0, states.Length)];
        }
Ejemplo n.º 4
0
        public Player (TelnetClient client, Location location)
            : base(location, null) {
            Client = client;
            client.RegisterOnDispose(OnDisconnected);

            RebuildCommandTrie();
            AddExitCommands(location);

            AddEventHandler(EventType.CombatHit, OnEventCombatHit);
            AddEventHandler(EventType.CombatMiss, OnEventCombatMiss);
            AddEventHandler(EventType.CombatStart, OnEventCombatStart);
            AddEventHandler(EventType.Death, OnEventDeath);
            AddEventHandler(EventType.Emote, OnEventEmote);
            AddEventHandler(EventType.Enter, OnEventEnter);
            AddEventHandler(EventType.Leave, OnEventLeave);
            AddEventHandler(EventType.Say, OnEventSay);
            AddEventHandler(EventType.Tell, OnEventTell);
        }
Ejemplo n.º 5
0
 protected virtual void OnLocationChange(Location oldLocation, Location newLocation)
 {
 }
Ejemplo n.º 6
0
 public EntityBase(Location location, string name)
 {
     if (location == null)
         throw new ArgumentNullException("location");
     _Name = name;
     Location = location;
     _ThinkTask = Program.Scheduler.Start(ThinkTask(), TaskExecutionPolicy.RunAsBackgroundTask);
     _EventDispatchTask = Program.Scheduler.Start(EventDispatchTask(), TaskExecutionPolicy.RunAsBackgroundTask);
 }
Ejemplo n.º 7
0
        public static void Create()
        {
            Location _;

            _ = PlayerStartLocation = new Location("StartingRoom") {
                Title = "A small cottage",
                Description = "You find yourself inside a small, single-room forest cottage.\r\n" +
                "A table sits in the center of the room surrounded by two chairs.\r\n" +
                "There is a wooden door to your south that leads outside.",
                Exits = {
                    new Exit("Door", "A wooden door", "StartingForestA")
                }
            };

            new StartingRoomOldMan(_);
            new StartingRoomCat(_);

            _ = new Location("StartingForestA") {
                Title = "Forest clearing",
                Description = "You are standing in a clearing within a green, verdant forest.\r\n" +
                "In front of you is a small wooden cottage. A door leads inside.\r\n" +
                "An unkempt forest path leads to the south.",
                Exits = {
                    new Exit("Door", "Cottage door", "StartingRoom"),
                    new Exit("Path", "Forest path", "StartingForestB")
                }
            };

            new ForestBird(_);

            _ = new Location("StartingForestB") {
                Title = "Forest path",
                Description = "You are standing on an overgrown path in the forest.\r\n" +
                "You can hear the sounds of the forest all around you, and the sun is barely visible through the thick foliage.\r\n" +
                "The path winds along to the north and south.",
                Exits = {
                    new Exit("North", "North", "StartingForestA"),
                    new Exit("South", "South", "StartingForestC")
                }
            };

            new ForestBird(_);
            new ForestBird(_);

            _ = new Location("StartingForestC") {
                Title = "Forest path",
                Description = "You are standing on an overgrown path in the forest.\r\n" +
                "The wind blows quietly through the area, rustling the leaves of the trees.\r\n" +
                "The path winds along to the north and south.",
                Exits = {
                    new Exit("North", "North", "StartingForestB"),
                    new Exit("South", "South", "StartingForestD2")
                }
            };

            new ForestBird(_);

            _ = new Location("StartingForestD2") {
                Title = "Forest entrance",
                Description = "You are standing at the entrance to a small forest.\r\n" +
                "The forest opens onto a small, overgrown path heading north. The grassline ends abruptly to your south.\r\n" +
                "The path leads north into the forest. To the south you see a small path winding through sharp crags and worn stone. The treeline runs to your east and west.",
                Exits = {
                    new Exit("North", "North", "StartingForestC"),
                    new Exit("West", "West", "StartingForestD1"),
                    new Exit("East", "East", "StartingForestD3"),
                    new Exit("South", "Winding path", "StonePathA")
                }
            };

            _ = new Location("StartingForestD1") {
                Title = "Forest outskirts",
                Description = "You are standing at the edge of a small forest.\r\n" +
                "You see thick, overgrown grass and trees to the north. The way south and west is blocked by rocky, impassable terrain.",
                Exits = {
                    new Exit("East", "East", "StartingForestD2"),
                }
            };

            _ = new Location("StartingForestD3") {
                Title = "Forest outskirts",
                Description = "You are standing at the edge of a small forest.\r\n" +
                "You see thick, overgrown grass and trees to the north. The way south and east is blocked by rocky, impassable terrain.",
                Exits = {
                    new Exit("West", "West", "StartingForestD2"),
                }
            };

            _ = new Location("StonePathA") {
                Title = "Winding path entrance",
                Description = "You are standing at the entrance to a small, winding path.\r\n" +
                "The path carves its way through solid stone, worn and aged by the passage of time.\r\n" +
                "To your north you can see trees in the distance. The path continues southward.",
                Exits = {
                    new Exit("North", "Forest entrance", "StartingForestD2"),
                    new Exit("South", "South", "StonePathB")
                }
            };

            _ = new Location("StonePathB") {
                Title = "Winding path",
                Description = "You stand upon a small, winding path.\r\n" +
                "The stone here is cracked and weary, and shows signs of having once been home to a flowing stream.\r\n" +
                "The path continues to the north and south.",
                Exits = {
                    new Exit("North", "North", "StonePathA"),
                    new Exit("South", "South", "StonePathC")
                }
            };

            _ = new Location("StonePathC") {
                Title = "Winding path",
                Description = "You stand upon a winding path, at the mouth of a cave.\r\n" +
                "The cave in front of you is small and foreboding. Faint traces of sunlight illuminate the ground within.\r\n" +
                "The path continues to the north and south. The cave beckons.",
                Exits = {
                    new Exit("North", "North", "StonePathB"),
                    new Exit("South", "South", "StonePathD"),
                    new Exit("Cave", "Cave entrance", "CaveA")
                }
            };

            _ = new Location("StonePathD") {
                Title = "Winding path entrance",
                Description = "You stand at the end of a winding path hewn from stone.\r\n" +
                "A path winds to the north through crags and ancient stone.\r\n" +
                "To the south you see a bustling city.",
                Exits = {
                    new Exit("North", "North", "StonePathC"),
                    new Exit("City", "City entrance", "CityNorth"),
                }
            };

            _ = new Location("CityNorthwest") {
                Title = "Asteria Northwest",
                Description = "You stand upon a cobblestone street in the northwestern part of the city of Asteria.\r\n" +
                "The city is quieter here. Homes and apartments line the street, mostly empty as their owners go about their daily business.",
                Exits = {
                    new Exit("East", "Asteria North", "CityNorth"),
                    new Exit("South", "Asteria West", "CityWest"),
                }
            };

            Asteria.Add(_);

            _ = new Location("CityNorth") {
                Title = "Asteria North",
                Description = "You stand upon a cobblestone street in the northern part of the city of Asteria.\r\n" +
                "Shops line both sides of the street, bustling with people.",
                Exits = {
                    new Exit("North", "Stone path", "StonePathD"),
                    new Exit("West", "Asteria Northwest", "CityNorthwest"),
                    new Exit("South", "Asteria City Center", "CityCenter"),
                    new Exit("East", "Asteria Northeast", "CityNortheast"),
                }
            };

            Asteria.Add(_);

            _ = new Location("CityNortheast") {
                Title = "Asteria Northeast",
                Description = "You stand upon a cobblestone street in the northeastern part of the city of Asteria.\r\n" +
                "The city here buzzes with activity. Businesses of all kinds line the street and men and women rush about, seeing to their work.",
                Exits = {
                    new Exit("West", "Asteria North", "CityNorth"),
                    new Exit("South", "Asteria East", "CityEast"),
                }
            };

            Asteria.Add(_);

            _ = new Location("CityWest") {
                Title = "Asteria West",
                Description = "You stand upon a cobblestone street in the western part of the city of Asteria.\r\n" +
                "The street is occupied by large, elaborate homes, surrounded by fences and brick walls.",
                Exits = {
                    new Exit("North", "Asteria Northwest", "CityNorthwest"),
                    new Exit("East", "Asteria City Center", "CityCenter"),
                    new Exit("South", "Asteria Southwest", "CitySouthwest"),
                }
            };

            Asteria.Add(_);

            _ = new Location("CityCenter") {
                Title = "Asteria City Center",
                Description = "You stand upon the street in the center of the city of Asteria, in front of the town hall building.\r\n" +
                "The town hall is full of activity at this time of day, with politicians, businessmen, and people of all sort entering and leaving at a steady pace.",
                Exits = {
                    new Exit("North", "Asteria North", "CityNorth"),
                    new Exit("West", "Asteria West", "CityWest"),
                    new Exit("East", "Asteria East", "CityEast"),
                    new Exit("South", "Asteria South", "CitySouth"),
                }
            };

            Asteria.Add(_);

            _ = new Location("CityEast") {
                Title = "Asteria East",
                Description = "You stand upon a cobblestone street in the eastern part of the city of Asteria.\r\n" +
                "The city is quieter here. Homes and apartments line the street, mostly empty as their owners go about their daily business.",
                Exits = {
                    new Exit("North", "Asteria Northeast", "CityNortheast"),
                    new Exit("West", "Asteria City Center", "CityCenter"),
                    new Exit("South", "Asteria Southeast", "CitySoutheast"),
                }
            };

            Asteria.Add(_);

            _ = new Location("CitySouthwest") {
                Title = "Asteria Southwest",
                Description = "You stand upon a cobblestone street in the southwestern part of the city of Asteria.\r\n" +
                "The city is quieter here. Homes and apartments line the street, mostly empty as their owners go about their daily business.",
                Exits = {
                    new Exit("East", "Asteria South", "CitySouth"),
                    new Exit("North", "Asteria West", "CityWest"),
                }
            };

            Asteria.Add(_);

            _ = new Location("CitySouth") {
                Title = "Asteria South",
                Description = "You stand upon a cobblestone street in the southern part of the city of Asteria.\r\n" +
                "Shops line both sides of the street, bustling with people.",
                Exits = {
                    new Exit("North", "Asteria City Center", "CityCenter"),
                    new Exit("West", "Asteria Southwest", "CitySouthwest"),
                    new Exit("East", "Asteria Southeast", "CitySoutheast"),
                }
            };

            Asteria.Add(_);

            _ = new Location("CitySoutheast") {
                Title = "Asteria Southeast",
                Description = "You stand upon a cobblestone street in the southeastern part of the city of Asteria.\r\n" +
                "The city is quieter here. Homes and apartments line the street, mostly empty as their owners go about their daily business.",
                Exits = {
                    new Exit("West", "Asteria South", "CitySouth"),
                    new Exit("North", "Asteria East", "CityEast"),
                }
            };

            Asteria.Add(_);

            int n = Program.RNG.Next(16, 26);
            for (int i = 0; i < n; i++) {
                new Townsperson();
            }

            n = Program.RNG.Next(2, 8);
            for (int i = 0; i < n; i++) {
                new Wanderer();
            }
        }
Ejemplo n.º 8
0
 public StartingRoomOldMan(Location location)
     : base(location, "An old man")
 {
     _State = "sitting at the table";
     AddEventHandler(EventType.Enter, OnEventEnter);
     AddEventHandler(EventType.Leave, OnEventLeave);
 }
Ejemplo n.º 9
0
        private void RemoveExitCommands(Location l)
        {
            if (l == null)
                return;

            foreach (var ex in l.Exits)
                _Commands.Remove(ex.Name);
        }
Ejemplo n.º 10
0
        private void AddExitCommands(Location l)
        {
            if (l == null)
                return;

            foreach (var ex in l.Exits) {
                _Commands.Insert(
                    ex.Name,
                    new CommandHandler(
                        new CommandHandler.PlayerCheckDelegate[] {
                            CheckPlayerIsAlive
                        },
                    delegate(Player p, string[] words) {
                        var ourExit = p.Location.Exits.Where(x => (x.Name.ToLower() == words[0])).First();
                        if (World.Locations.ContainsKey(ourExit.Target.ToLower()))
                            p.Location = World.Locations[ourExit.Target.ToLower()];
                        else {
                            Console.WriteLine("Warning: '{0}' exit '{1}' leads to undefined location '{2}'.", p.Location.Name, ourExit.Description, ourExit.Target);
                            p.SendMessage("Your attempt to leave via {0} is thwarted by a mysterious force.", ourExit.Description);
                            p.SendPrompt();
                        }
                        return null;
                    }));
            }
        }
Ejemplo n.º 11
0
        protected override void OnLocationChange(Location oldLocation, Location newLocation)
        {
            // If there is no name, we won't have our player data instantiated.
            if (_Name == null)
                return;

            RemoveExitCommands(oldLocation);
            AddExitCommands(newLocation);
        }