예제 #1
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;
     }
 }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (gameTimer > 0 && !won)
        {
            gameTimer           -= Time.deltaTime;
            timeElapsedThisGame += Time.deltaTime;
        }
        else
        {
            lost = true;
            Lose();
        }

        if (enemySpawnCounter > 0f)
        {
            enemySpawnCounter -= Time.deltaTime;
            if (enemySpawnCounter <= 0f)
            {
                enemySpawnCounter = enemySpawnInterval;
                enemies.Add(Instantiate(enemyPrefab, possibleDeliveries[0].transform.position, possibleDeliveries[0].transform.rotation) as GameObject);
            }
        }

        foreach (Text t in mainCanvas.GetComponentsInChildren <Text>())
        {
            if (t.name.Equals("Pizza Count"))
            {
                t.text = "PIZZA COUNT: " + playerTruck.HowManyPizzas();
            }

            if (t.name.Equals("Tips"))
            {
                t.text = "TIPS: £" + cash;
            }

            if (t.name.Equals("Timer"))
            {
                t.text = "" + (int)gameTimer;
            }
        }

        UpdateBoostMeter();
        UpdateRepulseMeter();
        CheckWinCondition();

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            SceneManager.LoadScene("main menu");
        }
    }
예제 #3
0
    void OnTriggerStay(Collider other)
    {
        //if there's a truck in the bay, start taking pizzas!
        if (other.gameObject.CompareTag("DeliveryTruck"))
        {
            truck = other.GetComponent <DeliveryTruck>();

            //if the truck has no pizzas, ignore it
            if (truck.HowManyPizzas() == 0)
            {
                return;
            }

            if (receivingPizzas == false)
            {
                InitiatePizzaReception(truck);
            }
        }
    }
예제 #4
0
    // Update is called once per frame
    void OnTriggerStay(Collider other)
    {
        //if there's a truck in the bay, start resupplying pizzas!
        if (other.gameObject.CompareTag("DeliveryTruck"))
        {
            truck = other.GetComponent <DeliveryTruck>();

            //if the truck's already got enough pizzas, ignore it
            if (truck.HowManyPizzas() >= truck.getMaxPizzas())
            {
                return;
            }

            if (supplying == false)
            {
                InitiatePizzaResupply(truck);
            }
        }
    }