Ejemplo n.º 1
0
    public void DeployHotAirBalloon(bool isSpawnFromRight, bool isSpeedUpEnabled)
    {
        float spawnY = UnityEngine.Random.Range(spawnOffsetY, Screen.height - spawnOffsetY);
        int   spawnX = isSpawnFromRight ? Screen.width : 0;

        Vector3 spawnPosition = Camera.main.ScreenToWorldPoint(new Vector3(spawnX, spawnY, 10));

        GameObject hotAirBalloon = Instantiate(hotAirBalloonPrefab, spawnPosition, Quaternion.identity) as GameObject;

        hotAirBalloon.name = "hotAirBalloon";
        LinearFlight linearFlight = hotAirBalloon.GetComponent <LinearFlight>();

        if (isSpawnFromRight)
        {
            linearFlight.flightDirection = new Vector3(-1, 0, 0);
        }
        else
        {
            linearFlight.flightDirection = new Vector3(1, 0, 0);
        }
        if (isSpeedUpEnabled)
        {
            linearFlight.AdjustSpeedByMultiplicativeFactor(SPEED_UP_FACTOR);
        }
    }
Ejemplo n.º 2
0
    private void CreateNewBalloon(float rotationDegrees)
    {
        Balloon newBalloon = (Balloon)Instantiate(balloonPrefab, transform.position, Quaternion.identity);

        newBalloon.name = "BalloonPrefab";
        newBalloon.transform.localScale *= sizeDecrement;
        newBalloon.balloonsInCluster     = this.balloonsInCluster / 2;
        LinearFlight flight = newBalloon.GetComponent <LinearFlight>();

        flight.IncrementSpeed();
        flight.RotateFlightDirection(rotationDegrees);
    }
Ejemplo n.º 3
0
    private void ShootWaterBalloon()
    {
        Vector3 playerDirection = player.transform.position - gameObject.transform.position;

        Quaternion q            = Quaternion.FromToRotation(Vector3.up, playerDirection);
        GameObject waterBalloon = (GameObject)Instantiate(waterBalloonPrefab, transform.position, q);

        waterBalloon.name = "WaterBallooon";
        LinearFlight linearFlight = waterBalloon.GetComponent <LinearFlight>();

        linearFlight.flightDirection = playerDirection;
        //Must rotate drops because they spawn upside down
        waterBalloon.transform.Rotate(new Vector3(1, 0, 0), 180f);
    }
Ejemplo n.º 4
0
    void CreateBalloonClusters()
    {
        for (int i = 0; i < numBalloonClusters; i++)
        {
            Vector3 randomPosition = new Vector3(UnityEngine.Random.Range(0.2f, 0.8f), UnityEngine.Random.Range(0.2f, 0.8f), 10.0f);
            Vector3 worldPos       = Camera.main.ViewportToWorldPoint(randomPosition);
            Balloon balloonCluster = (Balloon)Instantiate(balloonPrefab, worldPos, Quaternion.identity);
            balloonCluster.name = "BalloonCluster";
            LinearFlight flight = balloonCluster.GetComponent <LinearFlight>();
            flight.RotateFlightDirection(UnityEngine.Random.Range(0f, 360f));

            balloonClusters.Add(balloonCluster);
        }
    }