Пример #1
0
    private IEnumerator SpawnRegularly()
    {
        while (true)
        {
            yield return(new WaitForSeconds(spawnRateInSeconds));

            Vector3 spawnLocation = transform.position + new Vector3(xVariance == 0 ? 0 : Random.Range(-xVariance / 2, xVariance / 2), 0, zVariance == 0 ? 0 : Random.Range(-zVariance / 2, zVariance / 2));

            GameObject ball = ObjectPooler.pooler.GetPooledObject();

            // All transform properties needing to be changed
            ball.transform.position   = spawnLocation;
            ball.transform.rotation   = transform.rotation;
            ball.transform.localScale = new Vector3(ballScale, ballScale, ballScale);

            // Rigidbody properties
            ball.GetComponent <Rigidbody>().velocity        = Vector3.zero;
            ball.GetComponent <Rigidbody>().angularVelocity = Vector3.zero;


            // Set the ball free
            ball.SetActive(true);
            Ball ballScript = ball.GetComponent <Ball>();
            ServerSend.BallActive(ballScript);
        }
    }
Пример #2
0
    public void resetPlayerAndBall(GameObject player)
    {
        player.GetComponent <Player>().Kill();

        // TODO: Make sure client gets explosion
        //Instantiate(explosionParticle, transform.position, transform.rotation);
        ServerSend.BallCollided(transform.position);
        gameObject.SetActive(false);
        ServerSend.BallActive(this);
    }
Пример #3
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("Player"))
        {
            if (!sendToSpawn)
            {
                return;
            }

            other.GetComponent <Player>().Kill();
        }
        else if (other.gameObject.CompareTag("Ball"))
        {
            other.gameObject.SetActive(false);

            Ball ball = other.GetComponent <Ball>();
            ServerSend.BallActive(ball);
        }
    }