public void CheckCondition()
        {
            IDoor.DoorState doorState = IDoor.DoorState.Open;
            foreach (IBlock block in RoomBlocks.Instance.ListRef)
            {
                if (!block.IsMoved())
                {
                    doorState = IDoor.DoorState.Closed;
                    break;
                }
            }

            List <IDoor> doors = RoomDoors.Instance.ListRef as List <IDoor>;

            foreach (int doornum in conditionVariables)
            {
                doors[doornum].State = doorState;
            }

            if (doorState != prevState)
            {
                SoundFactory.PlaySound(SoundFactory.Instance.doorUnlock);
            }
            prevState = doorState;
        }
        public void CheckCondition()
        {
            IDoor.DoorState doorState = IDoor.DoorState.Open;
            if (RoomEnemies.Instance.ListRef.Count == 0)
            {
                List <ISpawner> spawners = RoomSpawners.Instance.ListRef as List <ISpawner>;
                foreach (ISpawner spawner in spawners)
                {
                    if (spawner.CurrentCount > 0)
                    {
                        doorState = IDoor.DoorState.Closed;
                        break;
                    }
                }
            }
            else
            {
                doorState = IDoor.DoorState.Closed;
            }

            List <IDoor> doors = RoomDoors.Instance.ListRef as List <IDoor>;

            foreach (int doornum in conditionVariables)
            {
                doors[doornum].State = doorState;
            }

            if (doorState != prevState)
            {
                SoundFactory.PlaySound(SoundFactory.Instance.doorUnlock);
            }
            prevState = doorState;
        }
Exemple #3
0
        public NormalLeftDoor(Game1 game, Vector2 center, IDoor.DoorState initialDoorState)
        {
            this.game             = game;
            this.initialDoorState = initialDoorState;
            doorSprite            = DoorSpriteFactory.Instance.CreateLeftDoorSprite(game.SpriteBatch, center, initialDoorState);
            roomTranslationVector = new Vector3(-1, 0, 0);
            State = initialDoorState;

            this.collidable = new DoorCollidable(this);
        }
Exemple #4
0
        private IDoor CreateDoor(String type, Vector2 startingPos, IDoor.DoorState initialDoorState, Vector2 xyChange)
        {
            IDoor newDoor = null;

            switch (type)
            {
            case "Up":
                newDoor = new NormalUpDoor(game, startingPos, initialDoorState);
                break;

            case "Down":
                newDoor = new NormalDownDoor(game, startingPos, initialDoorState);
                break;

            case "Left":
                newDoor = new NormalLeftDoor(game, startingPos, initialDoorState);
                break;

            case "Right":
                newDoor = new NormalRightDoor(game, startingPos, initialDoorState);
                break;

            case "StairDown":
                newDoor = new DownStaircaseDoor(game, startingPos);
                break;

            case "OffscreenUp":
                newDoor = new OffscreenUpDoor(game, startingPos);
                break;

            case "PortalUp":
                newDoor = new PortalUp(game, startingPos, xyChange);
                break;

            case "PortalDown":
                newDoor = new PortalDown(game, startingPos, xyChange);
                break;

            default:
                break;
            }

            return(newDoor);
        }
Exemple #5
0
        public void ParseDoors(Room roomobj, XElement roomxml, XDocument doc)
        {
            XName doorsName = XName.Get("doors", doc.Root.Name.NamespaceName);

            XElement        doors    = roomxml.Element(doorsName);
            List <XElement> doorList = doors.Elements("door").ToList();

            foreach (XElement door in doorList)
            {
                XElement typeName  = door.Element("type");
                XElement doorPos   = door.Element("pos");   //not used for walls
                XElement initState = door.Element("state"); //used only for normal doors
                XElement xLoc      = door.Element("xloc");  //not used for normal doors
                XElement yLoc      = door.Element("yloc");  //not used for normal doors

                Vector2 xyChange = new Vector2();
                if (typeName.Value.Equals("PortalUp") || typeName.Value.Equals("PortalDown"))
                {
                    xyChange = GetXYChange(door);
                }

                RoomUtilities.DoorPos dPos = FindDoorPos(typeName.Value);
                Vector2 center;
                if (dPos == RoomUtilities.DoorPos.NONE)
                {
                    center = RoomUtilities.CalculateBlockCenter(roomobj.RoomPos, new Vector2(float.Parse(xLoc.Value), float.Parse(yLoc.Value)));
                }
                else
                {
                    center = RoomUtilities.CalculateDoorCenter(roomobj.RoomPos, dPos);
                }

                IDoor.DoorState initialDoorState = GetInitialDoorState(initState.Value);
                IDoor           doorAdd          = CreateDoor(typeName.Value, center, initialDoorState, xyChange);
                Vector3         connectingRoom   = roomobj.RoomPos + GetConnectingRoom(typeName.Value, xyChange);

                if (roomHandler.rooms.ContainsKey(connectingRoom))
                {
                    HandleDoorConnection(connectingRoom, ref doorAdd, Int32.Parse(doorPos.Value));
                }

                roomobj.AddDoor(doorAdd);
            }
        }
        public void CheckCondition()
        {
            IDoor.DoorState doorState = IDoor.DoorState.Closed;
            if (RoomEnemies.Instance.ListRef.Count == 0)
            {
                doorState = IDoor.DoorState.Open;
            }

            List <IDoor> doors = RoomDoors.Instance.ListRef as List <IDoor>;

            foreach (int doornum in conditionVariables)
            {
                doors[doornum].State = doorState;
            }

            if (doorState != prevState)
            {
                SoundFactory.PlaySound(SoundFactory.Instance.doorUnlock);
            }
            prevState = doorState;
        }
Exemple #7
0
 public void OnCollidedWith(ICollidable collidableObject)
 {
     if (collidableObject is PlayerCollidable)
     {
         IDoor.DoorState state = this.door.State;
         if (state == IDoor.DoorState.Open)
         {
             if (this.door is NormalUpDoor && collidableObject.RectangleRef.Y < this.RectangleRef.Y)
             {
                 this.door.Interact();
             }
             else if (this.door is NormalDownDoor && collidableObject.RectangleRef.Y + collidableObject.RectangleRef.Height > this.RectangleRef.Y + this.RectangleRef.Height)
             {
                 this.door.Interact();
             }
             else if (this.door is NormalLeftDoor && collidableObject.RectangleRef.X < this.RectangleRef.X)
             {
                 this.door.Interact();
             }
             else if (this.door is NormalRightDoor && collidableObject.RectangleRef.X + collidableObject.RectangleRef.Width > this.RectangleRef.X + this.RectangleRef.Width)
             {
                 this.door.Interact();
             }
         }
         else
         {
             this.door.Interact();
         }
     }
     else if (collidableObject is ProjectileCollidable) //needs to be modified to only allow bomb projectile to do this
     {
         if (this.door.State == IDoor.DoorState.Wall && this.door.ConnectedDoor != null && ((ProjectileCollidable)collidableObject).Projectile is BombProjectile)
         {
             this.door.State = IDoor.DoorState.Bombed;
             this.door.ConnectedDoor.State = IDoor.DoorState.Bombed;
         }
     }
 }
        public AllEnemiesKilledOpenDoor(List <int> condVariables)
        {
            /*
             * condVariables[i] = index of desired door in door list of desired room to be opened
             * conditionVariables[conditionVariables.Count - 1] = initial state of specified doors
             *
             * There is no limit to the number of doors this can be done for in each room.
             */
            conditionVariables = condVariables;
            switch (conditionVariables[conditionVariables.Count - 1])
            {
            case 0:
                prevState = IDoor.DoorState.Closed;
                break;

            case 1:
                prevState = IDoor.DoorState.Open;
                break;

            default:     //this should never happen
                break;
            }
            conditionVariables.RemoveAt(conditionVariables.Count - 1);
        }