Esempio n. 1
0
        public int SaveInventory(RoomInventory RoomInventory)
        {
            HotelInformation Hinfo = new HotelInformation();
            int result             = Hinfo.SaveRoomInventory(RoomInventory);

            return(result);
        }
Esempio n. 2
0
    public void stopLayerSwitch()
    {
        if (gameObject.GetComponent <Player>() == null)
        {
            usableDoor.close();
            if (usableDoor.otherSide != null)
            {
                usableDoor.otherSide.close();
            }
        }
        unlockMovement();
        viewDirection = DirectionEnum.LEFT;
        BroadcastMessage("stopAnimation", "moveFore");
        BroadcastMessage("stopAnimation", "moveBack");
        finishedAction = true;

        // Player und NPC Komponenten
        Character chara  = gameObject.GetComponent <Character>();
        Player    player = gameObject.GetComponent <Player>();

        // Erhalte Raumkomponente
        Transform     tempRoom = (chara != null) ? usableDoor.otherSide.transform : usableDoor.transform;
        RoomInventory roomComp = null;

        while (true)
        {
            // Oberstes Element in der Hierarchie erreicht => beende Loop
            if (tempRoom.parent == null)
            {
                break;
            }
            else if (tempRoom.parent.GetComponent <RoomInventory>() != null)
            {
                roomComp = tempRoom.parent.GetComponent <RoomInventory>();
                break;
            }
            else
            {
                tempRoom = tempRoom.parent;
            }
        }

        // Wenn Objekt NPC ...
        if (chara != null)
        {
            chara.setCurrentLocation(roomComp);
            chara.setCharacterPath(chara.currentObjectOfInterest);
            // Wenn Objekt Player ...
        }
        else if (player != null)
        {
            player.currentLocation = roomComp;
        }
    }
Esempio n. 3
0
    bool roomContainsObject(RoomInventory room, GameObject obj)
    {
        foreach (GameObject g in room.objects)
        {
            if (g.Equals(obj))
            {
                return(true);
            }
        }

        return(false);
    }
Esempio n. 4
0
    //Findet die Tür zu einem Nachbarraum
    public GameObject getDoorToRoom(RoomInventory room)
    {
        foreach (GameObject g in objects)
        {
            Door   door   = g.GetComponent <Door>();
            Stairs stairs = g.GetComponent <Stairs>();
            if (door != null)
            {
                for (int i = 0; i < door.connectedRooms.Length; ++i)
                {
                    if (door.connectedRooms[i].Equals(room))
                    {
                        return(g);
                    }
                }
            }
        }

        return(null);
    }
Esempio n. 5
0
    public void finishAction(Moving movComp)
    {
        movComp.finishedAction = true;
        // Erhalte Raumkomponente
        RoomInventory roomComp = (level == 1) ? upperMainFloor : lowerMainFloor;

        // Wenn Objekt NPC ...
        Character     chara      = movComp.GetComponent <Character>();
        Player        player     = movComp.GetComponent <Player>();
        RoomInventory otherFloor = null;

        if (chara != null)
        {
            Debug.Log("Char " + chara.name + " wechselt durch Treppe von Raum " + chara.getCurrentLocation() + " in Raum " + roomComp);
            chara.setCurrentLocation(roomComp);
            chara.setCharacterPath(chara.currentObjectOfInterest);
            // Wenn Objekt Player ...
        }
        else if (player != null)
        {
            player.setCurrentLocation(roomComp);
        }
    }
Esempio n. 6
0
 public override void ShowRoomDescription()
 {
     if (RoomInventory.All(i => i.ItemId != 7))
     {
         Description = "A small hallway with cement covered walls, the air is damp. I think I'm in a cellar?\n" +
                       "There is a path leading to the left, it looks dark. There's also a path leading to the right.";
         base.ShowRoomDescription();
         return;
     }
     foreach (var exit in Exit)
     {
         if (exit.Locked || exit.ExitId != 10)
         {
             continue;
         }
         Description = "A small hallway with cement covered walls, the air is damp. I think I'm in a cellar.\n" +
                       "There's a path leading to the left, my torch should be able to light up the path for me to follow.\n" +
                       "There's also a path leading to the right and a door.";
         base.ShowRoomDescription();
         break;
     }
     base.ShowRoomDescription();
 }
Esempio n. 7
0
 public void setCurrentLocation(RoomInventory location)
 {
     currentLocation = location;
 }
Esempio n. 8
0
 public HouseInventory()
 {
     kitchen    = GameObject.Find("Kitchen").GetComponent <RoomInventory>();
     diningRoom = GameObject.Find("Dining Room").GetComponent <RoomInventory>();
 }
Esempio n. 9
0
    public void setCharacterPath(GameObject specificObject)
    {
        characterPath = new GameObject[0];
        // Wenn kein spezielles Objekt definiert wird, wird ein neues Objekt der Interesse hinzugefügt ...
        if (specificObject == null)
        {
            assignNextObjectOfInterest();
        }
        // ... ansonsten wird spezifisch definiertes Objekt benutzt
        else
        {
            currentObjectOfInterest = specificObject;
        }

        // Wenn aktueller Raum das gesuchte Objekt beinhaltet, füge es zum Pfad hinzu ...
        if (currentLocation.containsObject(currentObjectOfInterest))
        {
            addToPath(currentObjectOfInterest);
        }
        // ... ansonsten gehe durch andere Räume
        else
        {
            RoomInventory mainFloor = null;
            GameObject    door      = null;
            // Wenn aktueller Raum nicht der Flur ist ...
            if (!currentLocation.isMainFloor)
            {
                // ... setze Flur auf aktuellem Stockwerk und erhalte die Tür zum Flur.
                mainFloor = this.getMainFloorNeighbour();                 // !!!
                door      = currentLocation.getDoorToRoom(mainFloor);
                // Füge danach die Tür zum Pfad hinzu
                addToPath(door);
            }
            // Wenn aktueller Raum der Flur ist, füge diesen als Flur hinzu
            else
            {
                mainFloor = currentLocation;
            }

            // Wenn Flur das gesuchte Objekt beinhaltet, füge es zum Pfad hinzu und beende Funktion
            if (mainFloor.containsObject(currentObjectOfInterest))
            {
                addToPath(currentObjectOfInterest);
                return;
            }

            RoomInventory nextRoom = null;
            // Durchgehe alle Räume des Flures auf dem aktuellen Stockwerk ...
            foreach (RoomInventory room in mainFloor.getNeighbouringRooms())
            {
                // ... und überprüfe, ob Objekt in Raum enthalten ist ...
                if (roomContainsObject(room, currentObjectOfInterest))
                {
                    // ... und setze nextRoom Variable mit diesem Raum und beende die Schleife
                    nextRoom = room;
                    break;
                }
            }

            // Wenn Objekt in keinem dieser Räume ist ...
            if (nextRoom == null || nextRoom.isMainFloor)
            {
                // ... benutze die Treppe in das andere Stockwerk
                addToPath(mainFloor.stairs);

                // Erhalte Stairs Komponente
                Stairs stairs = mainFloor.stairs.GetComponent <Stairs>();
                // Wenn aktueller Flur dem unteren Flur entspricht, setzte Flur um auf den oberen ...
                if (mainFloor.Equals(stairs.lowerMainFloor))
                {
                    mainFloor = stairs.upperMainFloor;
                }
                // ... ansonsten auf den unteren
                else
                {
                    mainFloor = stairs.lowerMainFloor;
                }

                // Wenn anderer Flur as Objekt der Interesse beinhaltet, füge zu Pfad hinzu und beende Funktion ...
                if (mainFloor.containsObject(currentObjectOfInterest))
                {
                    addToPath(currentObjectOfInterest);
                    return;
                }

                // ... ansonsten durchgehe alle Räume, die an Flur angehangen sind nach dem Objekt und setzte nächsten Raum
                foreach (RoomInventory room in mainFloor.getNeighbouringRooms())
                {
                    if (roomContainsObject(room, currentObjectOfInterest))
                    {
                        nextRoom = room;
                    }
                }
            }

            // Erhalte die TÜr zum nächsten Raum und füge sie zum Pfad hinzu
            door = mainFloor.getDoorToRoom(nextRoom);
            addToPath(door);
            // Anschließend füge das Objekt der Interesse zum Pfad hinzu
            addToPath(currentObjectOfInterest);
        }
    }