示例#1
0
    public Apartment GetUpperNeighbour(Apartment apartment)
    {
        BuildingSegment segment    = apartment.GetComponentInParent <BuildingSegment>();
        int             floorIndex = GetFloorIndex(segment);

        if (floorIndex < 0)
        {
            return(null);
        }
        int apartmentIndex = GetApartmentIndexInFloor(floorIndex, segment);

        if (apartmentIndex < 0)
        {
            return(null);
        }

        if (building.Count <= floorIndex + 1)
        {
            return(null);
        }

        BuildingSegment upperNeighbourSegment = building[floorIndex + 1][apartmentIndex];

        return(upperNeighbourSegment.GetComponentInChildren <Apartment>());
    }
示例#2
0
 void SpawnItems()
 {
     for (int i = 0; i < gameManager.itemPrefabs.Length; i++)
     {
         GameObject      itemGO          = Instantiate(gameManager.itemPrefabs[i]);
         BuildingSegment buildingSegment = building[0][1];
         Item            item            = itemGO.GetComponent <Item>();
         itemGO.transform.position = buildingSegment.apartmentRoom.floorTransform.position;
         itemGO.transform.Translate(new Vector3((float)3 * (1 - i), item.yOffset, 0f));
         item.currentApartment = buildingSegment.GetComponentInChildren <Apartment>();
     }
 }