Ejemplo n.º 1
0
    public void SendWaitress()
    {
        Waitress selWaitress = null;

        while (selWaitress == null)
        {
            int      rnd         = Random.Range(0, numOfWaitresses - 1);
            Waitress tmpWaitress = _waitresses[rnd];
            if (!tmpWaitress.InPlay)
            {
                selWaitress = tmpWaitress;
                int numOfDrinks          = Random.Range(minNumOfDrinks, maxNumOfDrinks);
                List <GameObject> drinks = new List <GameObject>();
                for (int i = 0; i < numOfDrinks; i++)
                {
                    GameObject  drinkObject = _drinkFactory.GetDrinkObject(_drinkManager.GetRandomDrink());
                    Rigidbody2D rb          = drinkObject.AddComponent <Rigidbody2D>();
                    rb.gravityScale = 0;
                    drinkObject.transform.localScale = new Vector2(0.5f, 0.5f);
                    drinks.Add(drinkObject);
                }
                selWaitress.transform.transform.position = new Vector2(-5, -5);
                selWaitress.OnReachedTable += OnReachedTable;
                selWaitress.Activate(GetRandomTable(), drinks);
            }
        }
    }
Ejemplo n.º 2
0
 private void LaunchDrink()
 {
     if (_drinkFactory != null)
     {
         GameObject  drinkObject = _drinkFactory.GetDrinkObject(_drinkManager.GetRandomDrink());
         Rigidbody2D rb          = drinkObject.AddComponent <Rigidbody2D>();
         rb.gravityScale = 0;
         rb.drag         = 0.2f;
         drinkObject.transform.localScale = new Vector2(0.5f, 0.5f);
         drinkObject.GetComponent <DrinkObject>().OnReachedEnd += OnReachedEnd;
         drinkObject.transform.position = transform.TransformPoint(beginPosition);
         drinkObject.GetComponent <Rigidbody2D>().AddForce(Vector2.right * launchForce);
     }
     else
     {
         Debug.LogError("drinkFactory is null");
     }
 }