// Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         GainPoints new_particle = Instantiate(point_prefab, new Vector2(5, 0), new Quaternion());
         new_particle.destination = new Vector2(Random.Range(-8, -5), Random.Range(-4, 4));
     }
 }
Beispiel #2
0
    public void ProcessDishInput()
    {
        if (IsCarryingDish())
        {
            Table closestTable = null;
            foreach (var table in tablesInRange)
            {
                if (table.isWaitingForDish)
                {
                    closestTable = table;
                }
            }

            if (closestTable != null)
            {
                Debug.Assert(closestTable.isWaitingForDish);
                if (closestTable.Serve(dish))
                {
                    int got_tip = closestTable.CollectTip();
                    m_collectedTip += got_tip;

                    GainPoints new_particle = Instantiate(waiter_gain_points_particle,
                                                          closestTable.transform.position, new Quaternion());
                    Vector2 particles_destination = new Vector2(5, 1);
                    if (waiter_face != null)
                    {
                        particles_destination = waiter_face.transform.position;
                    }
                    else
                    {
                        Debug.Log("Please set waiters its faces from GUI");
                    }

                    new_particle.destination      = particles_destination;
                    new_particle.color            = waiter_color;
                    new_particle.number_of_points = got_tip;
                }
                else
                {
                    int penalty = Random.Range(incorrectDishPenalty, incorrectDishPenalty + incorrectDishPenaltyDeviation);
                    m_collectedTip -= penalty;
                    if (m_collectedTip < 0)
                    {
                        m_collectedTip = 0;
                    }
                }

                RemoveDish();
            }
            else
            {
                ReclaimDish();
            }
        }
        else
        {
            Vector3    pos = GetComponent <Transform>().position;
            DishPickup closestDishPickup         = null;
            float      closestDishPickupDistance = float.MaxValue;
            foreach (var dishPickup in dishPickupsInRange)
            {
                float distance = (dishPickup.GetComponent <Transform>().position - pos).sqrMagnitude;
                if (dishPickup.hasDish && distance < closestDishPickupDistance)
                {
                    closestDishPickup         = dishPickup;
                    closestDishPickupDistance = distance;
                }
            }

            if (closestDishPickup != null)
            {
                Debug.Assert(closestDishPickup.hasDish);

                dish = closestDishPickup.PickUp();
                dish.Transfer(GetComponent <Transform>().Find("DishPivot"));

                if (bubble)
                {
                    bubble.Fadeout();
                }
            }
        }
    }