コード例 #1
0
    Guest SpawnGuest()
    {
        List <Transform> availSpawnPositions = spawnPositions.Where(x => x.childCount == 0).ToList();

        if (availSpawnPositions.Count == 0)
        {
            Debug.Log("Nowhere to spawn!");
            return(null);
        }

        if (InventoryManager.Instance.currentItems.Count - activeGuests.Count <= 0)
        {
            Debug.Log("No unrequested items available");
            return(null);
        }
        Guest newGuest = Instantiate(guestFab).GetComponent <Guest>();

        newGuest.rect          = newGuest.GetComponent <RectTransform>();
        newGuest.RequestedItem = InventoryManager.Instance.GetUniqueAvailableItem(CurrentlyRequestedItems);
        activeGuests.Add(newGuest);
        newGuest.transform.SetParent(availSpawnPositions[0]);
        newGuest.transform.localScale    = Vector3.one;
        newGuest.rect.offsetMin          = Vector2.zero; //.sizeDelta = Vector2.zero;
        newGuest.rect.offsetMax          = Vector2.zero; //.sizeDelta = Vector2.zero;
        newGuest.transform.localPosition = Vector3.zero;
        newGuest.Configure(Random.Range(minDisgruntleTime, maxDisgruntleTime));
        CurrentlyRequestedItems = GetCurrentlyRequestedItems();
        return(newGuest);
    }