コード例 #1
0
    IEnumerator launchBalls(int ballsLaunched)
    {
        Vector3 launchPosition = transform.position;

        //Shoot balls until ball count is reached
        while (ballsLaunched != BallCount)
        {
            ballText.text = "x" + (BallCount - ballsLaunched);
            GameObject newBall = balls.getPooledObject();                                //Get pooled balls
            newBall.transform.position = launchPosition;                                 //set position to player positon
            newBall.SetActive(true);                                                     //Activate ball
            newBall.GetComponent <Rigidbody2D> ().velocity = dir.normalized * BallSpeed; // apply calculated speed
            yield return(new WaitForSeconds(0.03f));

            ballsLaunched++; //increase number of balls shot
        }
        ballText.gameObject.SetActive(false);
        yield return(null);
    }
コード例 #2
0
ファイル: platformGenerator.cs プロジェクト: lixxz/Stroke-Run
    // Update is called once per frame
    void Update()
    {
        if (transform.position.x < generationPoint.transform.position.x)
        {
            distanceBetween  = Random.Range(distanceBetweenMin, distanceBetweenMax);
            platformSelector = Random.Range(0, theObjectPools.Length);
            heightChange     = transform.position.y + Random.Range(maxHeightChange, -maxHeightChange);

            if (heightChange > maxHeight)
            {
                heightChange = maxHeight;
            }
            else if (heightChange < minHeight)
            {
                heightChange = minHeight;
            }
            transform.position = new Vector3(transform.position.x + distanceBetween + (platformWidths[platformSelector]) / 2, heightChange, transform.position.z);

            //Instantiate (thePlatforms[platformSelector], transform.position, transform.rotation);

            GameObject newPlatform = theObjectPools[platformSelector].getPooledObject();
            newPlatform.transform.position = transform.position;
            newPlatform.transform.rotation = transform.rotation;
            newPlatform.SetActive(true);

            if (Random.Range(0f, 100f) < randomSpikeThreshold)
            {
                GameObject newSpike = spikePool.getPooledObject();

                float spikeXPosition = Random.Range(-platformWidths[platformSelector] / 2 + 5f, platformWidths[platformSelector] / 2);

                Vector3 spikePosition = new Vector3(spikeXPosition, 0.5f, 0f);

                newSpike.transform.position = transform.position + spikePosition;
                newSpike.transform.rotation = transform.rotation;
                newSpike.SetActive(true);
            }

            transform.position = new Vector3(transform.position.x + (platformWidths[platformSelector]) / 2, transform.position.y, transform.position.z);
        }
    }
コード例 #3
0
ファイル: ParticalPooler.cs プロジェクト: Shab09/BBBreak
 public GameObject playParticle()
 {
     return(particals.getPooledObject());
 }