Example #1
0
    public void Start()
    {
        BallCost_Out.text    = BallCost.ToString();
        PointKeeper_Out.text = CoinScore.ToString();

        GameObject[] Pegs      = GameObject.FindGameObjectsWithTag("QPeg");
        GameObject[] WasteBins = GameObject.FindGameObjectsWithTag("WasteBins");

        foreach (var p in Pegs)
        {
            if (p.gameObject.GetComponent <PegCollision>() == null)
            {
                bool registered = false;
                foreach (var _peg in RegisteredPegs)
                {
                    if (_peg._instantiatedObject != null && _peg._instantiatedObject == p)
                    {
                        registered = true;
                    }
                }

                if (!registered)
                {
                    Peg _newPeg = new Peg(this, p.gameObject);
                    RegisteredPegs.Add(_newPeg);
                }
            }
        }
        foreach (var wb in WasteBins)
        {
            WasteBinBarrier wbr = wb.GetComponent <WasteBinBarrier>();
            wbr.Controller = this;
        }
    }
Example #2
0
    public void SpawnBall()
    {
        if (CoinScore >= BallCost)
        {
            ProcessCoinChange(-BallCost);
            BallCost_Out.text = BallCost.ToString();
            GameObject _instantiatedObject = Instantiate(Puck);

            //Add to collections for Registration and Clean Object Removal
            Debug.Log("Adding QBall #" + (QBalls.Count + 1));
            QBalls.Add(_instantiatedObject.GetComponent <QBall>());

            _instantiatedObject.transform.position = PuckSpawnLocation.transform.position;
            float Velocity = UnityEngine.Random.Range(175, 1000);
            _instantiatedObject.GetComponent <Rigidbody>().velocity = new Vector3(0, Velocity, 0);
        }
    }