Exemplo n.º 1
0
 public bool ContainsObjectOfRoomObjectType(RoomObjectType objType)
 {
     for (int i = 0; i < objectList.Count; i++)
     {
         if (objectList[i].GetRoomObjectType() == objType)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 2
0
    public int GetCountOfType(RoomObjectType t)
    {
        int count = 0;

        for (int i = 0; i < containedObjects.Count; i++)
        {
            if (containedObjects[i].Type == t)
            {
                count++;
            }
        }
        return(count);
    }
Exemplo n.º 3
0
    /// <summary>
    /// Given a RoomObject, this returns a list of existing Rooms that have
    /// an open interaction point for that RoomObject type
    /// </summary>
    /// <typeparam name="T">The RoomObject object type</typeparam>
    /// <returns>A list of Rooms with the available RoomObject type</returns>
    public List <Room> GetRoomsWithAvailableObjectType <T>(RoomObjectType objType) where T : RoomObject
    {
        List <Room.Type> roomTypes  = RoomObject.GetAllowedRoomTypes(objType);
        List <Room>      roomList   = new List <Room>();
        List <Room>      returnList = new List <Room>();

        foreach (Room.Type type in roomTypes)
        {
            roomList = GetRoomsOfType(type);
            foreach (Room room in roomList)
            {
                if (room.HasAvailableObjectType <T>())
                {
                    returnList.Add(room);
                }
            }
        }
        return(returnList);
    }
Exemplo n.º 4
0
 private static RoomObject CreateObject(RoomObjectType type, Vector2 position, Sprite sprite, Room room)
 {
     if(room == null)
     {
         room = currentRoom;
     }
     GameObject go = new GameObject (type.ToString ());
     go.transform.position = new Vector3 (position.x, position.y, 0);
     RoomObject roomObject = null;
     switch (type)
     {
     case RoomObjectType.Enemy:
     {
         roomObject = go.AddComponent<Enemy>();
         break;
     }
     case RoomObjectType.Door:
     {
         roomObject = go.AddComponent<Door>();
         break;
     }
     case RoomObjectType.Exit:
     {
         roomObject = go.AddComponent<Exit>();
         break;
     }
     case RoomObjectType.Decor:
     {
         roomObject = go.AddComponent<Decor>();
         break;
     }
     default:
     {
         Debug.Log ("Error: Creating " + type + " in room not implemented");
         return null;
     }
     }
     roomObject.sprite = sprite;
     if (roomObject != null)
     {
         room.objects.Add (roomObject);
     }
     roomObject.room = room;
     return roomObject;
 }