コード例 #1
0
        /// <summary>
        /// Returns the first block that has only the given direction.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public DungeonBlockData Get(DungeonBlockType type, int direction)
        {
            var top    = direction == 0 ? 1 : 0;
            var right  = direction == 1 ? 1 : 0;
            var bottom = direction == 2 ? 1 : 0;
            var left   = direction == 3 ? 1 : 0;

            return(this.Get(type, top, right, bottom, left));
        }
コード例 #2
0
        /// <summary>
        /// Returns the first block with the given type and directions.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public DungeonBlockData Get(DungeonBlockType type, int[] directions)
        {
            if (directions.Length != 4)
            {
                throw new ArgumentException("Expected 4 directions: top, right, bottom, and left, in order.");
            }

            var top    = directions[0] != 0 ? 1 : 0;
            var right  = directions[1] != 0 ? 1 : 0;
            var bottom = directions[2] != 0 ? 1 : 0;
            var left   = directions[3] != 0 ? 1 : 0;

            return(this.Get(type, top, right, bottom, left));
        }
コード例 #3
0
ファイル: Door.cs プロジェクト: xKamuna/aura
		/// <summary>
		/// Creates new door prop.
		/// </summary>
		/// <param name="propId"></param>
		/// <param name="regionId"></param>
		/// <param name="x"></param>
		/// <param name="y"></param>
		/// <param name="direction">Direction the door faces in, in degree.</param>
		/// <param name="doorType"></param>
		/// <param name="name"></param>
		/// <param name="state"></param>
		public Door(int propId, int regionId, int x, int y, int direction, DungeonBlockType doorType, string name, string state = "open")
			: base(propId, regionId, x, y, direction, 1, 0, state, "", "")
		{
			this.Name = name;
			this.DoorType = doorType;
			this.BlockBoss = false;
			this.Behavior = this.DefaultBehavior;
			_isSwitchDoor = false;
			_closedFrom = new Position(x / Dungeon.TileSize, y / Dungeon.TileSize);

			// Set direction and adjust Y for boss doors
			if (doorType == DungeonBlockType.BossDoor)
			{
				this.Info.Direction = MabiMath.DirectionToRadian(0, 1);
				this.Info.Y += Dungeon.TileSize + Dungeon.TileSize / 2;
			}
			else
			{
				this.Info.Direction = MabiMath.DegreeToRadian(direction);
			}
		}
コード例 #4
0
        /// <summary>
        /// Creates new door prop.
        /// </summary>
        /// <param name="propId"></param>
        /// <param name="regionId"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="direction">Direction the door faces in, in degree.</param>
        /// <param name="doorType"></param>
        /// <param name="name"></param>
        /// <param name="state"></param>
        public Door(int propId, int regionId, int x, int y, int direction, DungeonBlockType doorType, string name, string state = "open")
            : base(propId, regionId, x, y, direction, 1, 0, state, "", "")
        {
            this.Name      = name;
            this.DoorType  = doorType;
            this.BlockBoss = false;
            this.Behavior  = this.DefaultBehavior;
            _isSwitchDoor  = false;
            _closedFrom    = new Position(x / Dungeon.TileSize, y / Dungeon.TileSize);

            // Set direction and adjust Y for boss doors
            if (doorType == DungeonBlockType.BossDoor)
            {
                this.Info.Direction = MabiMath.DirectionToRadian(0, 1);
                this.Info.Y        += Dungeon.TileSize + Dungeon.TileSize / 2;
            }
            else
            {
                this.Info.Direction = MabiMath.DegreeToRadian(direction);
            }
        }
コード例 #5
0
ファイル: PuzzlePlace.cs プロジェクト: trueever/aura
        /// <summary>
        /// Adds door to place.
        /// </summary>
        /// <param name="direction"></param>
        /// <param name="doorType"></param>
        private void AddDoor(int direction, DungeonBlockType doorType)
        {
            var door = _room.GetPuzzleDoor(direction);

            // We'll create new door and replace if we want locked door instead of normal one here
            if (door != null && doorType == DungeonBlockType.Door)
            {
                this.Doors[direction] = door;
                return;
            }

            // Create new door
            var floorData = this.Puzzle.FloorData;
            var doorBlock = this.Puzzle.Dungeon.Data.Style.Get(doorType, direction);
            var doorName  = string.Format("{0}_door_{1}{2}_{3}", _name, this.X, this.Y, direction);

            door             = new Door(doorBlock.PropId, 0, this.X, this.Y, doorBlock.Rotation, doorType, doorName);
            door.Info.Color1 = floorData.Color1;
            door.Info.Color2 = floorData.Color2;
            door.Info.Color3 = this.LockColor;

            if (doorType == DungeonBlockType.BossDoor)
            {
                if (this.Puzzle.Dungeon.Data.BlockBoss)
                {
                    door.BlockBoss = true;
                }
                door.Behavior += this.Puzzle.Dungeon.BossDoorBehavior;
            }
            door.Behavior += this.Puzzle.PuzzleEvent;

            this.Doors[direction]       = door;
            this.Puzzle.Props[doorName] = door;
            _room.SetPuzzleDoor(door, direction);
            _room.SetDoorType(direction, (int)doorType);
        }
コード例 #6
0
ファイル: PuzzlePlace.cs プロジェクト: aura-project/aura
		/// <summary>
		/// Adds door to place.
		/// </summary>
		/// <param name="direction"></param>
		/// <param name="doorType"></param>
		private void AddDoor(int direction, DungeonBlockType doorType)
		{
			var door = _room.GetPuzzleDoor(direction);
			// We'll create new door and replace if we want locked door instead of normal one here
			if (door != null && doorType == DungeonBlockType.Door)
			{
				this.Doors[direction] = door;
				return;
			}

			// Create new door
			var floorData = this.Puzzle.FloorData;
			var doorBlock = this.Puzzle.Dungeon.Data.Style.Get(doorType, direction);
			var doorName = string.Format("{0}_door_{1}{2}_{3}", _name, this.X, this.Y, direction);

			door = new Door(doorBlock.PropId, 0, this.X, this.Y, doorBlock.Rotation, doorType, doorName);
			door.Info.Color1 = floorData.Color1;
			door.Info.Color2 = floorData.Color2;
			door.Info.Color3 = this.LockColor;

			if (doorType == DungeonBlockType.BossDoor)
			{
				if (this.Puzzle.Dungeon.Data.BlockBoss)
					door.BlockBoss = true;
				door.Behavior += this.Puzzle.Dungeon.BossDoorBehavior;
			}
			door.Behavior += this.Puzzle.PuzzleEvent;

			this.Doors[direction] = door;
			this.Puzzle.Props[doorName] = door;
			_room.SetPuzzleDoor(door, direction);
			_room.SetDoorType(direction, (int)doorType);
		}
コード例 #7
0
 /// <summary>
 /// Returns the first block with the given type and directions.
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public DungeonBlockData Get(DungeonBlockType type, int top, int right, int bottom, int left)
 {
     return(this.Blocks.FirstOrDefault(a => a.Type == type && a.Top == top && a.Right == right && a.Bottom == bottom && a.Left == left));
 }
コード例 #8
0
 /// <summary>
 /// Returns the first block with the given type.
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public DungeonBlockData Get(DungeonBlockType type)
 {
     return(this.Blocks.FirstOrDefault(a => a.Type == type));
 }