示例#1
0
    private void Start()
    {
        //get the cannons script
        cannonManager  = GameObject.Find("Cannons Manager");
        cannonScript   = cannonManager.GetComponent <Cannons>();
        cannonballList = cannonScript.cannonballList;

        //get launch angle
        if (shootingFromTheLeft = cannonScript.getActiveCannon() == true)
        {
            launchAngle = cannonScript.getCurRotleft();
        }
        else
        {
            launchAngle = cannonScript.getCurRotRight();
        }

        //decomposing the launch speed into it's x and y components
        xVel = cannonScript.getLaunchVelocity() * Mathf.Cos(launchAngle);
        yVel = cannonScript.getLaunchVelocity() * Mathf.Sin(launchAngle);

        //Velocity's sign depends on which cannon we are firing from
        if (shootingFromTheLeft == false)
        {
            xVel *= -1;
        }

        //get terrain data points
        GameObject mountains     = GameObject.Find("Mountain range");
        Terrain    terrainScript = mountains.GetComponent <Terrain>();

        mountainPoints = terrainScript.mountainPoints;

        leftSidePoints  = terrainScript.leftSidePoints;
        rightSidePoints = terrainScript.rightSidePoints;

        waterPoints    = terrainScript.waterPoints;
        waterAvgHeight = terrainScript.getWaterAvgHeight();

        //Getting the balloon manager script
        balloonManager       = GameObject.Find("Balloon Spawner");
        balloonManagerScript = balloonManager.GetComponent <BalloonSpawner>();
    }