Esempio n. 1
0
    private IEnumerator SpawningRoutine()
    {
        while (true)
        {
            GameObject customerObj = InstantiateACustomer();

            if (customerObj != null)
            {
                ShopMover customer = customerObj.GetComponent <ShopMover> ();

                if (customer != null)
                {
                    customerSpawner.SpawnCustomer(customer);
                }
                else
                {
                    Debug.LogFormat("Customer object {0} does not have a ShopMover component and will not be spawned.", customerObj.name);
                }
            }
            else
            {
                Debug.Log("No customers to spawn!");
            }

            yield return(new WaitForSeconds(7 + Random.value * 10));
        }
    }
Esempio n. 2
0
    private void Update()
    {
        OnPause();

        if (Time.time >= currTime)
        {
            currTime = Time.time + timeBtwnSpawn;
            //   Debug.Log("Spawn.");
            spawner.SpawnCustomer();
        }
        //updating Time
        if (_timePlayer1 >= 0)
        {
            _timePlayer1 = LoseTime(_timePlayer1);
        }
        if (_timePlayer2 >= 0)
        {
            _timePlayer2 = LoseTime(_timePlayer2);
        }

        //update UI && Time.
        UpdateUI();

        maxScore = Mathf.Max(_scorePlayer1, _scorePlayer2);

        if ((int)_timePlayer1 <= 0)
        {
            player1.speed = 0f;
        }
        if ((int)_timePlayer2 <= 0)
        {
            player2.speed = 0f;
        }
        if ((int)_timePlayer1 == 0 && (int)_timePlayer2 == 0)
        {
            if (maxScore == _scorePlayer1 && maxScore == _scorePlayer2)
            {
                winnerPlayer.text = "Game Draw is by score : " + maxScore;
            }
            else if (maxScore == _scorePlayer1)
            {
                winnerPlayer.text = "Winner is Player1 with Score : " + maxScore;
            }
            else if (maxScore == _scorePlayer2)
            {
                winnerPlayer.text = "Winner is Player2 with Score : " + maxScore;
            }
            restartPanel.SetActive(true);
            if (Time.timeScale == 1)
            {
                Time.timeScale = 0;
            }
        }
    }
Esempio n. 3
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        CustomerSpawner myScript = (CustomerSpawner)target;

        if (GUILayout.Button("Force Spawn"))
        {
            if (myScript.customer)
            {
                myScript.SpawnCustomer(myScript.customer);
            }
            else
            {
                Debug.Log("There is no customer set for force spawning.");
            }
        }
    }