예제 #1
0
 void InitiatePizzaReception(DeliveryTruck receiver)
 {
     //make sure the truck is going slow enough to deliver pizzas
     if (receiver.GetComponent <Rigidbody>().velocity.magnitude < speedTolerance)
     {
         //it is! wait a sec, then drop the 'zas
         receivingPizzas = true;
         launchTimer     = delayBeforeReceive;
     }
 }
예제 #2
0
 void InitiatePizzaResupply(DeliveryTruck receiver)
 {
     //make sure the truck is going slow enough to receive pizzas
     if (receiver.GetComponent <Rigidbody>().velocity.magnitude < speedTolerance)
     {
         //it is! wait a sec, then drop the 'zas
         supplying            = true;
         pizzasToGiveThisTrip = truck.getMaxPizzas() - truck.HowManyPizzas();
         spawnTimer           = delayBeforeResupply;
     }
 }
예제 #3
0
    void Update()
    {
        if (supplying)
        {
            //don't spawn em all at once
            spawnTimer -= Time.deltaTime;
            if (spawnTimer < 0)
            {
                spawnTimer = spawnInterval;
                GameObject pizza = (GameObject)Instantiate(pizzaPrefab, truck.pizzaSpawnPoint.position, truck.transform.rotation);
                pizza.GetComponent <Rigidbody>().velocity = truck.GetComponent <Rigidbody>().velocity;
                pizzasGivenThisTrip++;
            }

            if (pizzasGivenThisTrip >= pizzasToGiveThisTrip)
            {
                supplying            = false;
                pizzasGivenThisTrip  = 0;
                pizzasToGiveThisTrip = 0;
            }
        }
    }