Esempio n. 1
0
        public override object ReadValue(Type ValueType, Newtonsoft.Json.JsonReader Reader, MudObject Owner)
        {
            var r = new Dictionary <RelativeLocations, List <MudObject> >();

            Reader.Read();
            while (Reader.TokenType != Newtonsoft.Json.JsonToken.EndObject)
            {
                var relloc = StringToRelativeLocation(Reader.Value.ToString());
                var l      = new List <MudObject>();
                Reader.Read();
                Reader.Read();
                while (Reader.TokenType != Newtonsoft.Json.JsonToken.EndArray)
                {
                    var mudObject = MudObject.GetObject(Reader.Value.ToString());
                    if (mudObject != null)
                    {
                        l.Add(mudObject);
                    }
                    mudObject.Location = Owner;
                    Reader.Read();
                }
                Reader.Read();
                r.Upsert(relloc, l);
            }
            Reader.Read();

            return(r);
        }
Esempio n. 2
0
        public static void AtStartup(RuleEngine GlobalRules)
        {
            GlobalRules.DeclarePerformRuleBook <Actor>("player joined", "[Player] : Considered when a player enters the game.", "actor");

            GlobalRules.DeclarePerformRuleBook <Actor>("player left", "[Player] : Considered when a player leaves the game.", "actor");

            GlobalRules.Perform <Actor>("player joined")
            .First
            .Do((actor) =>
            {
                MudObject.Move(actor, MudObject.GetObject(Core.SettingsObject.NewPlayerStartRoom));
                return(PerformResult.Continue);
            })
            .Name("Move to start room rule.");
        }
Esempio n. 3
0
File: Portal.cs Progetto: SinaC/RMUD
        /// <summary>
        /// Given a portal, find the opposite side. Portals are used to connect two rooms. The opposite side of
        /// the portal is assumed to be the portal in the linked room that faces the opposite direction. For example,
        /// if portal A is in room 1, faces west, and is linked to room 2, the opposite side would be the portal
        /// in room 2 that faces east. It does not actually check to see if the opposite side it finds is linked
        /// to the correct room.
        /// </summary>
        /// <param name="Portal"></param>
        /// <returns></returns>
        public static MudObject FindOppositeSide(MudObject Portal)
        {
            // Every object added to a room as a portal will be given the 'portal?' property, with a value of true.
            if (Portal.GetPropertyOrDefault <bool>("portal?", false) == false)
            {
                return(null);                                                              // Not a portal.
            }
            var destination = MudObject.GetObject(Portal.GetProperty <String>("link destination")) as Room;

            if (destination == null)
            {
                return(null);                     // Link is malformed in some way.
            }
            var direction         = Portal.GetPropertyOrDefault <Direction>("link direction", Direction.NOWHERE);
            var oppositeDirection = Link.Opposite(direction);
            var mirrorLink        = destination.EnumerateObjects().FirstOrDefault(p =>
                                                                                  p.GetBooleanProperty("portal?") && p.GetPropertyOrDefault <Direction>("link direction", Direction.NOWHERE) == oppositeDirection);

            return(mirrorLink);
        }