public RoomTemplate(Rect bounds, Range numBranches, RoomFlags flags, params Tuple <Direction, int>[] connections)
 {
     Bounds      = bounds;
     Flags       = flags;
     NumBranches = numBranches;
     Connections = connections;
 }
示例#2
0
文件: RoomData.cs 项目: fuding/yupi
        public virtual RoomFlags GetFlags()
        {
            RoomFlags flag = RoomFlags.Default;

            if (NavigatorImage != null)
            {
                flag |= RoomFlags.Image;
            }

            if (Group != null)
            {
                flag |= RoomFlags.Group;
            }

            if (Event != null)
            {
                flag |= RoomFlags.Event;
            }

            if (!IsPublic)
            {
                flag |= RoomFlags.Private;
            }

            if (AllowPets)
            {
                flag |= RoomFlags.AllowPets;
            }
            return(flag);
        }
 public RoomTemplate(Rect bounds, Range numBranches, RoomFlags flags, params Tuple<Direction, int>[] connections)
 {
     Bounds = bounds;
     Flags = flags;
     NumBranches = numBranches;
     Connections = connections;
 }
示例#4
0
 public Room(IEnumerable <ISDLElement> roomElements, IEnumerable <PerimeterPoint> perimeterPoints, byte propRule = 0, RoomFlags flags = 0) : this()
 {
     Elements.AddRange(roomElements);
     Perimeter.AddRange(perimeterPoints);
     Flags    = flags;
     PropRule = propRule;
 }
示例#5
0
    /// <summary>
    /// Returns the correct wall.
    /// </summary>
    /// <param name="flags">The flags</param>
    /// <param name="direction">0 north, 1 east, 2 south, 3 west</param>
    /// <returns></returns>
    static GameObject GetWall(RoomFlags flags, int direction)
    {
        GameObject wall = Wall;

        switch (direction)
        {
        case 0:
            if ((flags & RoomFlags.NorthDoor) != 0)
            {
                wall = Door;
            }
            if ((flags & RoomFlags.LockedNorthDoor) != 0)
            {
                wall = LockedDoor;
            }
            break;

        case 1:
            if ((flags & RoomFlags.EastDoor) != 0)
            {
                wall = Door;
            }
            if ((flags & RoomFlags.LockedEastDoor) != 0)
            {
                wall = LockedDoor;
            }
            break;

        case 2:
            if ((flags & RoomFlags.SouthDoor) != 0)
            {
                wall = Door;
            }
            if ((flags & RoomFlags.LockedSouthDoor) != 0)
            {
                wall = LockedDoor;
            }
            break;

        case 3:
            if ((flags & RoomFlags.WestDoor) != 0)
            {
                wall = Door;
            }
            if ((flags & RoomFlags.LockedWestDoor) != 0)
            {
                wall = LockedDoor;
            }
            break;
        }
        return(wall);
    }
        public void Load(BinaryReader reader)
        {
            this.ConnectionAid = reader.ReadInt32();
            this.ConnectionBid = reader.ReadInt32();
            this.DungeonAid    = reader.ReadInt32();
            this.DungeonBid    = reader.ReadInt32();
            this.IconType      = (RoomFlags)reader.ReadInt32();
            int count = reader.ReadInt32();

            PathList = new List <Vector2>(count);
            for (int i = 0; i < count; i++)
            {
                this.PathList.Add(reader.ReadVector2());
            }
            this.ShowIcon = reader.ReadBoolean();
        }
示例#7
0
        public static void Append(this ServerMessage message, RoomData data)
        {
            RoomManager manager = DependencyFactory.Resolve <RoomManager>();
            Room        room    = manager.GetIfLoaded(data);

            message.AppendInteger(data.Id);
            message.AppendString(data.Name);
            message.AppendInteger(data.Owner.Id);
            message.AppendString(data.Owner.Name);
            message.AppendInteger(data.State.Value);
            message.AppendInteger(room == null ? 0 : room.GetUserCount());
            message.AppendInteger(data.UsersMax);
            message.AppendString(data.Description);
            message.AppendInteger(data.TradeState.Value);
            message.AppendInteger(data.Score); // Score
            message.AppendInteger(data.Score); // Ranking Difference?
            message.AppendInteger(data.Category.Id);
            message.AppendInteger(data.Tags.Count);

            foreach (Tag tag in data.Tags)
            {
                message.AppendString(tag.Value);
            }

            RoomFlags flags = data.GetFlags();

            message.AppendInteger((int)flags);

            if ((flags & RoomFlags.Image) > 0)
            {
                message.AppendString(data.NavigatorImage);
            }

            if ((flags & RoomFlags.Group) > 0)
            {
                message.AppendInteger(data.Group.Id);
                message.AppendString(data.Group.Name);
                message.AppendString(data.Group.Badge);
            }

            if ((flags & RoomFlags.Event) > 0)
            {
                message.AppendString(data.Event.Name);
                message.AppendString(data.Event.Description);
                message.AppendInteger((int)(data.Event.ExpiresAt - DateTime.Now).TotalMinutes);
            }
        }
示例#8
0
 public void IsOutside_Test(RoomFlags flag, bool expectedValue)
 {
     _ch.CurrentRoom       = new RoomTemplate(1, "Test");
     _ch.CurrentRoom.Flags = _ch.CurrentRoom.Flags.SetBit(flag);
     Assert.That(_ch.IsOutside(), Is.EqualTo(expectedValue));
 }
示例#9
0
        public void Load(BinaryReader reader)
        {
            this.Id                 = reader.ReadInt32();
            this.IsDungeon          = reader.ReadBoolean();
            this.DungeonId          = reader.ReadInt32();
            this.Area               = reader.ReadString();
            this.IsRoomTransition   = reader.ReadBoolean();
            this.RoomFlags          = (RoomFlags)reader.ReadInt32();
            this.DifficultyModifier = reader.ReadSingle();
            this.X = reader.ReadInt32();
            this.Y = reader.ReadInt32();
            this.VariationIndex   = reader.ReadInt32();
            this.SpawnIndex       = reader.ReadInt32();
            this.TemplateId       = reader.ReadInt32();
            this.PlayerEntersLeft = reader.ReadBoolean();
            int count = reader.ReadInt32();

            LeftDoors = new Dictionary <int, LinkDefinition>(count);
            for (int i = 0; i < count; i++)
            {
                int            key   = reader.ReadInt32();
                LinkDefinition value = default(LinkDefinition);
                value.Load(reader);
                this.LeftDoors.Add(key, value);
            }
            count      = reader.ReadInt32();
            RightDoors = new Dictionary <int, LinkDefinition>(count);
            for (int j = 0; j < count; j++)
            {
                int            key   = reader.ReadInt32();
                LinkDefinition value = default(LinkDefinition);
                value.Load(reader);
                this.RightDoors.Add(key, value);
            }
            count       = reader.ReadInt32();
            CustomDoors = new Dictionary <int, LinkDefinition>(count);
            for (int k = 0; k < count; k++)
            {
                int            key   = reader.ReadInt32();
                LinkDefinition value = default(LinkDefinition);
                value.Load(reader);
                this.CustomDoors.Add(key, value);
            }
            count     = reader.ReadInt32();
            EnemyInfo = new List <EnemyInfo>(count);
            for (int l = 0; l < count; l++)
            {
                EnemyInfo item = default(EnemyInfo);
                item.Load(reader);
                this.EnemyInfo.Add(item);
            }
            count       = reader.ReadInt32();
            RandomProps = new List <PropData>(count);
            for (int m = 0; m < count; m++)
            {
                string fullName  = reader.ReadString();
                string localName = fullName.IndexOf("ComboLock", StringComparison.OrdinalIgnoreCase) > -1
                    ? "ComboLockHint"
                    : fullName.Substring(fullName.LastIndexOf(".", StringComparison.OrdinalIgnoreCase) + 1);
                Type        type        = Type.GetType("ChasmDeserializer.Model.SaveGameData.WorldState.Saveable." + localName);
                GenericProp genericProp = Activator.CreateInstance(type) as GenericProp;
                this.RandomProps.Add(new PropData(fullName, genericProp));
                ISaveGame saveGame = genericProp as ISaveGame;
                saveGame.LoadGame(reader);
            }
            count           = reader.ReadInt32();
            AreaConnections = new List <AreaConnectionDef>(count);
            for (int n = 0; n < count; n++)
            {
                this.AreaConnections.Add(AreaConnectionDef.Load(reader));
            }
            this.IsDark      = reader.ReadBoolean();
            this.IsBacktrack = reader.ReadBoolean();
            count            = reader.ReadInt32();
            LocalVaribles    = new Dictionary <string, string>(count);
            for (int num4 = 0; num4 < count; num4++)
            {
                string key   = reader.ReadString();
                string value = reader.ReadString();
                this.LocalVaribles.Add(key, value);
            }
            this.IsHub     = reader.ReadBoolean();
            count          = reader.ReadInt32();
            IdTranslations = new List <KeyValuePair <int, int> >(count);
            for (int num6 = 0; num6 < count; num6++)
            {
                int key   = reader.ReadInt32();
                int value = reader.ReadInt32();
                this.IdTranslations.Add(new KeyValuePair <int, int>(key, value));
            }
        }
示例#10
0
        public override string ToString()
        {
            var sb = new StringBuilder();

            //vnum line
            sb.Append("#");
            sb.AppendLine(VNUM.ToString());

            //title line
            sb.Append(Title);
            sb.AppendLine("~");

            //description
            sb.AppendLine(MainDescription);
            sb.AppendLine("~");

            // zone number, flags, sector line
            sb.Append(ZoneNumber.ToString());
            // space before flags
            sb.Append(" ");
            if (RoomFlags.Count == 0)
            {
                sb.Append("0");
            }
            else
            {
                var sortedRoomFlags = RoomFlags.OrderBy(rf => (int)rf);
                sb.Append("^");  // prepend the first item's caret, take care of the rest with this join
                sb.Append(string.Join("|^", sortedRoomFlags.Select(x => ((int)x).ToString()).ToArray()));
            }
            // space before sector
            sb.Append(" ");
            sb.AppendLine(((int)SectorType).ToString());

            // exits - only get the ones that are enabled
            var sortedExits = Exits.OrderBy(e => ((int)e.Direction)).Where(e => e.Enabled == true).ToList();

            foreach (var exit in sortedExits)
            {
                //D line
                sb.Append("D");
                sb.AppendLine(((int)exit.Direction).ToString());

                //Exit description
                sb.AppendLine(exit.Description);
                sb.AppendLine("~");

                // Door keywords line
                if (exit.DoorType != DoorType.None)
                {
                    sb.Append(exit.DoorKeywords);
                }
                sb.AppendLine("~");

                // Door config line
                sb.Append(((int)exit.DoorType).ToString());
                sb.Append(" ");
                sb.Append(exit.DoorKeyVnum);
                sb.Append(" ");
                sb.AppendLine(exit.DestinationVnum.ToString());
            }

            // extra descriptions
            foreach (var ex in ExtraDescriptions)
            {
                // E line
                sb.AppendLine("E");

                // Extra description keywords line
                sb.Append(ex.Keywords);
                sb.AppendLine("~");

                // Extra description
                sb.AppendLine(ex.Description);
                sb.AppendLine("~");
            }

            // closing S
            sb.AppendLine("S");

            return(sb.ToString());
        }
示例#11
0
 /// <summary>
 /// Calculate a Room, Check if its free, 
 /// </summary>
 /// <param name="x"> start X position</param>
 /// <param name="y"> start Y position</param>
 /// <param name="dir"> direction of the room</param>
 /// <param name="hight">hight of the Room</param>
 /// <param name="with">with of the Room</param>
 /// <param name="aktualArrayUsage">Fields in field</param>
 /// <param name="maxArrayUsage">Max Fields in field</param>
 /// <param name="type">Type of the Room</param>
 /// <param name="flags">Extraflaggs of the room</param>
 /// <returns>A List withe Fields for the Room, empty if imposible</returns>
 private List<Field> createRoom(int x, int y, int dir, int hight, int with, int aktualArrayUsage, int maxArrayUsage, RoomTypes type, RoomFlags[] flags)
 {
     List<Field> value = new List<Field>();
     if (maxArrayUsage - aktualArrayUsage < hight * with)
         return value;
     if (hight <= 2 || with <= 2)
         return value;
     #region example
     /*
      *  New Room;
      *  UL        UR
      *  h|FFFFFFFFF
      *  i|FFFFFFFFF
      *  g|FFFFFFFFF
      *  h|FFFFFFFFF
      *  t|FFFFFFFFF
      *   X--------Y
      *  DL        DR
      *     with
      */
     /*
     *                             Dir 3
     *         x  y                x  y           x  y
     *        -1 -1 UpLeft        +0 -1 Up       +1 -1 UpRight
     * Dir 2  -1 +0 Left          +0 +0 Center   +1 +0 Right     Dir 4
     *        -1 +1 DownLeft      +0 +1 Down     +1 +1 DownRight
     *                             Dir 1
     */
     #endregion
     Point UpRight, DownRight, UpLelft, DownLeft;
     Point Center;
     #region Set Basics
     #region All = 0
     UpLelft = new Point(x, y);
     UpRight = new Point(x, y);
     DownRight = new Point(x, y);
     DownLeft = new Point(x, y);
     #endregion
     switch (dir)
     {
         case 1:
             DownLeft = new Point(x - (with / 2), y);
             DownRight = new Point(DownLeft.X + with, DownLeft.Y);
             UpLelft = new Point(DownLeft.X, DownLeft.Y - hight);
             UpRight = new Point(DownLeft.X + with, DownLeft.Y - hight);
             break;
         case 2:
             DownLeft = new Point(x, y - (with / 2));
             DownRight = new Point(DownLeft.X + hight, DownLeft.Y);
             UpLelft = new Point(DownLeft.X, DownLeft.Y - with);
             UpRight = new Point(DownLeft.X + with, DownLeft.Y - with);
             break;
         case 3:
             DownLeft = new Point(x - (with / 2), y + hight);
             DownRight = new Point(DownLeft.X + with, DownLeft.Y);
             UpLelft = new Point(DownLeft.X, DownLeft.Y - hight);
             UpRight = new Point(DownLeft.X + with, DownLeft.Y - hight);
             break;
         case 4:
             DownLeft = new Point(x - hight, y + (with / 2));
             DownRight = new Point(DownLeft.X + hight, DownLeft.Y);
             UpLelft = new Point(DownLeft.X, DownLeft.Y - with);
             UpRight = new Point(DownLeft.X + with, DownLeft.Y - with);
             break;
         default:
             DownLeft = new Point(x - (with / 2), y);
             DownRight = new Point(DownLeft.X + with, DownLeft.Y);
             UpLelft = new Point(DownLeft.X, DownLeft.Y - hight);
             UpRight = new Point(DownLeft.X + with, DownLeft.Y - hight);
             break;
     }
     int XMax = DownRight.X - DownLeft.X;
     int YMax = DownLeft.Y - UpLelft.Y;
     #region Check Region
     if (surroundingPathDedect(UpRight.X, UpRight.Y) >= 10)
         return value;
     if (surroundingPathDedect(DownRight.X, DownRight.Y) >= 10)
         return value;
     if (surroundingPathDedect(UpLelft.X, UpLelft.Y) >= 10)
         return value;
     if (surroundingPathDedect(DownLeft.X, DownLeft.Y) >= 10)
         return value;
     #endregion
     #endregion
     #region Set Fields & Center Point
     for (int X = 0; X < XMax; ++X)
     {
         for (int Y = 0; Y < YMax; ++Y)
         {
             value.Add(new Field(UpLelft.X + X, UpLelft.Y + Y));
         }
     }
     int centerPos = (value.Count / 2) - ((value.Count + 1) % 2);
     Center = new Point(value[centerPos].X, value[centerPos].Y);
     #endregion
     #region Check Space for Room
     foreach (Field f in value)
     {
         if (surrounding(f.X, f.Y) >= 10)
         {
             value.Clear();
             return value;
         }
     }
     #endregion
     #region RoomTypes
     switch (type)
     {
         case RoomTypes.SaveRoom:
             break;
         case RoomTypes.NormalRoom:
             break;
         case RoomTypes.MSpawnerRoom:
             break;
         case RoomTypes.BossRoom:
             break;
     }
     #endregion
     #region Room Flags
     foreach (RoomFlags rf in flags)
     {
         switch (rf)
         {
             case RoomFlags.ConectingEdges:
                 #region ConnectiongEdges
                 value.Add(new Field(UpLelft.X - 1, UpLelft.Y));
                 value.Add(new Field(UpLelft.X, UpLelft.Y - 1));
                 value.Add(new Field(DownRight.X - 1, DownRight.Y));
                 value.Add(new Field(DownRight.X, DownRight.Y + 1));
                 value.Add(new Field(UpRight.X + 1, UpRight.Y));
                 value.Add(new Field(UpRight.X, UpRight.Y - 1));
                 value.Add(new Field(DownLeft.X + 1, DownLeft.Y));
                 value.Add(new Field(DownLeft.X, DownLeft.Y + 1));
                 break;
                 #endregion
             case RoomFlags.CrossRoadsBig:
                 #region CrossRoadsBig
                 for (int i = 0; i < 4; ++i) //dir 3
                 {
                     Field temp = new Field(Center.X, Center.Y - i - (with / 2));
                     if (surrounding(temp.X, temp.Y) < 10)
                         value.Add(temp);
                     else
                         break;
                 }
                 for (int i = 0; i < 4; ++i) //dir 4
                 {
                     Field temp = new Field(Center.X + i + (hight / 2), Center.Y);
                     if (surrounding(temp.X, temp.Y) < 10)
                         value.Add(temp);
                     else
                         break;
                 }
                 for (int i = 0; i < 4; ++i) //dir 1
                 {
                     Field temp = new Field(Center.X, Center.Y + i + (with / 2));
                     if (surrounding(temp.X, temp.Y) < 10)
                         value.Add(temp);
                     else
                         break;
                 }
                 for (int i = 0; i < 4; ++i) //dir 2
                 {
                     Field temp = new Field(Center.X - i - (hight / 2), Center.Y);
                     if (surrounding(temp.X, temp.Y) < 10)
                         value.Add(temp);
                     else
                         break;
                 }
                 break;
                 #endregion
             case RoomFlags.CrossRoadsSmall:
                 #region CrossRoadsSmall
                 for (int i = 0; i < 2; ++i) //dir 3
                 {
                     Field temp = new Field(Center.X, Center.Y - i - (with / 2));
                     if(surrounding(temp.X,temp.Y) < 10)
                         value.Add(temp);
                     else
                         break;
                 }
                 for (int i = 0; i < 2; ++i) //dir 4
                 {
                     Field temp = new Field(Center.X + i + (hight / 2), Center.Y);
                     if (surrounding(temp.X, temp.Y) < 10)
                         value.Add(temp);
                     else
                         break;
                 }
                 for (int i = 0; i < 2; ++i) //dir 1
                 {
                     Field temp = new Field(Center.X, Center.Y + i + (with / 2));
                     if (surrounding(temp.X, temp.Y) < 10)
                         value.Add(temp);
                     else
                         break;
                 }
                 for (int i = 0; i < 2; ++i) //dir 2
                 {
                     Field temp = new Field(Center.X - i - (hight / 2), Center.Y);
                     if (surrounding(temp.X, temp.Y) < 10)
                         value.Add(temp);
                     else
                         break;
                 }
                 break;
                 #endregion
             case RoomFlags.HasCoins:
                 #region HasCoins
                 break;
                 #endregion
             case RoomFlags.HasEnergy:
                 #region HasEnergy
                 break;
                 #endregion
             case RoomFlags.HasHelper:
                 #region HasHelper
                 break;
                 #endregion
             case RoomFlags.HasMSpawner:
                 #region HasMSpawner
                 break;
                 #endregion
             case RoomFlags.Traped:
                 #region Traped
                 break;
                 #endregion
         }
     }
     #endregion
     return value;
 }
示例#12
0
        public void Unserialize(GMDataReader reader)
        {
            Name                = reader.ReadStringPointerObject();
            Caption             = reader.ReadStringPointerObject();
            Width               = reader.ReadInt32(); Height = reader.ReadInt32();
            Speed               = reader.ReadInt32();
            Persistent          = reader.ReadWideBoolean();
            BackgroundColor     = reader.ReadInt32();
            DrawBackgroundColor = reader.ReadWideBoolean();
            CreationCodeID      = reader.ReadInt32();
            int flags = reader.ReadInt32();

            if (reader.VersionInfo.IsNumberAtLeast(2, 3))
            {
                flags &= ~0x30000;
            }
            else if (reader.VersionInfo.IsNumberAtLeast(2))
            {
                flags &= ~0x20000;
            }
            Flags       = (RoomFlags)flags;
            Backgrounds = reader.ReadPointerObject <GMPointerList <Background> >();
            Views       = reader.ReadPointerObject <GMPointerList <View> >();
            int gameObjectListPtr = reader.ReadInt32(); // read this later
            int tilePtr           = reader.ReadInt32();

            Tiles          = reader.ReadPointerObject <GMPointerList <Tile> >(tilePtr);
            Physics        = reader.ReadWideBoolean();
            Top            = reader.ReadInt32(); Left = reader.ReadInt32();
            Right          = reader.ReadInt32(); Bottom = reader.ReadInt32();
            GravityX       = reader.ReadSingle(); GravityY = reader.ReadSingle();
            PixelsToMeters = reader.ReadSingle();
            if (reader.VersionInfo.IsNumberAtLeast(2))
            {
                Layers = reader.ReadPointerObject <GMPointerList <Layer> >();
                if (reader.VersionInfo.IsNumberAtLeast(2, 3))
                {
                    // Read sequence ID list
                    reader.Offset = reader.ReadInt32();
                    SequenceIDs   = new List <int>();
                    for (int i = reader.ReadInt32(); i > 0; i--)
                    {
                        SequenceIDs.Add(reader.ReadInt32());
                    }
                }
            }

            // Handle reading game objects, which change lengths in 2.2.2.302 roughly, so calculate the size of them
            reader.Offset = gameObjectListPtr;
            int count = reader.ReadInt32();
            int eachSize;

            if (count > 1)
            {
                int first = reader.ReadInt32();
                eachSize = reader.ReadInt32() - first;
            }
            else
            {
                eachSize = tilePtr - (reader.Offset + 4);
            }
            if (eachSize >= 40)
            {
                reader.VersionInfo.RoomObjectPreCreate = true;
                if (eachSize == 48)
                {
                    reader.VersionInfo.SetNumber(2, 2, 2, 302);
                }
            }
            reader.Offset = gameObjectListPtr;
            GameObjects   = new GMPointerList <GameObject>();
            GameObjects.Unserialize(reader);
        }
示例#13
0
 public AdventureRoom(string d) : base()
 {
     Description = d;
     Exits       = new List <AdventureExit>();
     Flags       = RoomFlags.None;
 }
示例#14
0
		public bool RoomFlagged (RoomFlags flag)
		{
			return ((Flags & (byte)flag) == (byte)flag);
		}