Ejemplo n.º 1
0
    void OnLaundryGarmentReleased(LaundryGarment laundryGarment)
    {
        if (!Locked)
        {
            //If BasketView is open
            if (basketView.activeSelf)
            {
                bool alreadyInBasket  = laundryGarments.Contains(laundryGarment);
                bool withinBasketView = basketView.GetComponent <Collider2D>().bounds.Contains(laundryGarment.transform.position);

                if (alreadyInBasket && withinBasketView)
                {
                    Rigidbody2D rb = laundryGarment.GetComponent <Rigidbody2D>();
                    rb.gravityScale = 0.0f;
                    rb.velocity     = Vector3.zero;
                    AudioManager.instance.PlaySound(laundryGarment.garment.fabric.dropSound);
                    if (PlacedInBasketView != null)
                    {
                        PlacedInBasketView(laundryGarment);
                    }
                }
                else if (!alreadyInBasket && withinBasketView)
                {
                    if (basket.AddGarment(laundryGarment.garment, laundryGarment.transform.position - transform.position))
                    {
                        laundryGarment.transform.parent = transform;
                        Rigidbody2D rb = laundryGarment.GetComponent <Rigidbody2D>();
                        rb.gravityScale = 0.0f;
                        rb.velocity     = Vector3.zero;
                        AudioManager.instance.PlaySound(laundryGarment.garment.fabric.dropSound);
                        laundryGarments.Add(laundryGarment);
                    }
                    else
                    {
                        BasketIsFull();
                    }
                    if (PlacedInBasketView != null)
                    {
                        PlacedInBasketView(laundryGarment);
                    }
                }
                else if (alreadyInBasket && !withinBasketView)
                {
                    basket.RemoveGarment(laundryGarment.garment);
                    laundryGarments.Remove(laundryGarment);
                }
            }
            //If BasketView is closed
            //Wait for a frame, in case an overlapping BasketView captures the garment first
            else
            {
                StartCoroutine(DelayedAddToBasket(laundryGarment));
            }
        }
    }
Ejemplo n.º 2
0
    private void GenerateLaundry()
    {
        Basket basket = new Basket();

        pants = new GarmentPants(new Fabric(FabricType.Denim), GarmentColor.Sky);

        Fabric cotton = new Fabric(FabricType.Cotton);

        basket.AddGarment(pants);
        basket.AddGarment(new GarmentUnderwear(cotton, GarmentColor.White));
        basket.AddGarment(new GarmentSock(cotton, GarmentColor.Red));
        basket.AddGarment(new GarmentUnderwear(cotton, GarmentColor.White));
        basket.AddGarment(new GarmentSock(cotton, GarmentColor.Red));
        basket.AddGarment(new GarmentShirt(cotton, GarmentColor.Teal));
        basket.AddGarment(new GarmentTop(cotton, GarmentColor.White));
        basket.AddGarment(new GarmentTop(cotton, GarmentColor.Salmon));

        ollie.basket = basket;

        ollie.garments = new List <Garment>();

        for (int i = 0; i < basket.contents.Count; i++)
        {
            ollie.garments.Add(basket.contents[i]);
        }
    }
Ejemplo n.º 3
0
    private void Start()
    {
        GameObject laundromatBasketPrefab = (GameObject)Resources.Load("LaundromatBasket");

        RecurringCustomer customer = CustomerManager.instance.GetRecurringCustomer(characterIndex);
        Garment           bone     = new OllieFemur();

        Basket basket = LaundryManager.GetRandomBasket();

        while (!basket.AddGarment(bone))
        {
            //If there is no space in the basket for the bone, remove something
            Garment removed = basket.RemoveTopGarment();
            //If the removed garment is a sock, remove its match
            if (removed is GarmentSock)
            {
                foreach (Garment garment in basket.contents)
                {
                    if (garment is GarmentSock)
                    {
                        if (garment.color.Equals(removed.color) && garment.fabric.Equals(removed.fabric))
                        {
                            basket.RemoveGarment(garment);
                            break;
                        }
                    }
                }
            }
        }

        List <Garment> olliesGarments = new List <Garment>();

        foreach (Garment garment in basket.contents)
        {
            garment.customerID = customerID;
            olliesGarments.Add(garment);
        }

        customer.basket   = basket;
        customer.garments = olliesGarments;
    }
Ejemplo n.º 4
0
    private LaundromatBasket SpawnFirstBasket()
    {
        Basket basket = new Basket();
        Fabric cotton = new Fabric(FabricType.Cotton);

        basket.AddGarment(new GarmentPants(cotton, GarmentColor.Sky));
        basket.AddGarment(new GarmentUnderwear(cotton, GarmentColor.White));
        basket.AddGarment(new GarmentSock(cotton, GarmentColor.Red));
        basket.AddGarment(new GarmentSock(cotton, GarmentColor.Red));
        basket.AddGarment(new GarmentShirt(cotton, GarmentColor.White));
        basket.AddGarment(new GarmentTop(cotton, GarmentColor.White));
        basket.AddGarment(new GarmentPants(cotton, GarmentColor.Salmon));

        CreateTutorialCustomer(basket);

        LaundromatBasket laundromatBasket = Instantiate(laundromatBasketPrefab, firstBasketSpawn.position, firstBasketSpawn.rotation).GetComponent <LaundromatBasket>();

        laundromatBasket.basket = basket;
        return(laundromatBasket);
    }
Ejemplo n.º 5
0
    public static Basket GetRandomBasket()
    {
        Basket basket = new Basket();

        //Determine number of garments
        int numberOfGarments = UnityEngine.Random.Range(instance.MinimumNumberOfGarments, instance.MaximumNumberOfGarments + 1);

        List <Garment> garments = new List <Garment>();

        //Generate the garments
        for (int i = 0; i < numberOfGarments;)
        {
            //Determine fabricType
            int        fabricIndex = instance.WeightedFabricIndices[UnityEngine.Random.Range(0, instance.WeightedFabricIndices.Length)];
            FabricType fabricType  = instance.LaundryGenerationParameters[fabricIndex].fabric;

            //Determine garmentType
            int         garmentTypeIndex = UnityEngine.Random.Range(0, instance.LaundryGenerationParameters[fabricIndex].garmentType.Length);
            GarmentType garmentType      = instance.LaundryGenerationParameters[fabricIndex].garmentType[garmentTypeIndex];

            //Instantiate garment
            Garment garment = null;
            switch (garmentType)
            {
            case GarmentType.Top:
                garment = new GarmentTop(new Fabric(fabricType), GarmentColor.RandomColor());
                break;

            case GarmentType.Pants:
                garment = new GarmentPants(new Fabric(fabricType), GarmentColor.RandomColor());
                break;

            case GarmentType.Sock:
                garment = new GarmentSock(new Fabric(fabricType), GarmentColor.RandomColor());
                break;

            case GarmentType.Underwear:
                garment = new GarmentUnderwear(new Fabric(fabricType), GarmentColor.RandomColor());
                break;

            case GarmentType.Dress:
                garment = new GarmentDress(new Fabric(fabricType), GarmentColor.RandomColor());
                break;

            case GarmentType.Skirt:
                garment = new GarmentSkirt(new Fabric(fabricType), GarmentColor.RandomColor());
                break;

            case GarmentType.Shirt:
                garment = new GarmentShirt(new Fabric(fabricType), GarmentColor.RandomColor());
                break;

            default:
                Debug.LogError("Unknown garment type");
                break;
            }

            i += garment.size;
            garments.Add(garment);
            if (garment is GarmentSock)
            {
                Garment otherSock = new GarmentSock((GarmentSock)garment);
                garments.Add(otherSock);
                i += otherSock.size;
            }
        }

        //Shuffle clothing to separate socks
        int n = garments.Count;

        while (n > 1)
        {
            n--;
            int     k     = UnityEngine.Random.Range(0, n + 1);
            Garment value = garments[k];
            garments[k] = garments[n];
            garments[n] = value;
        }

        foreach (Garment garment in garments)
        {
            basket.AddGarment(garment);
        }

        return(basket);
    }