コード例 #1
0
 public void FreezeAll()
 {
     for (int i = 0; i < balls.Count; i++)
     {
         rigidbodyContainers[i] = new RigidbodyContainer();
         rigidbodyContainers[i].StoreRigidbody(balls[i].GetComponent <Rigidbody>());
         balls[i].GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
     }
 }
コード例 #2
0
    public void AddBall()
    {
        int ballSize = sceneContainer.GetBallPositions().Count;

        if (ballSize < 5)
        {
            var ballPre = Instantiate(ballPrefab);
            ballPre.transform.GetChild(0).GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;

            Vector3 ballPos = ballPre.transform.position;

            switch (ballSize)
            {
            case 1:
                ballPre.transform.position = new Vector3(ballPos.x + 2, ballPos.y, ballPos.z);
                break;

            case 2:
                ballPre.transform.position = new Vector3(ballPos.x - 2, ballPos.y, ballPos.z);
                break;

            case 3:
                ballPre.transform.position = new Vector3(ballPos.x, ballPos.y, ballPos.z + 2);
                break;

            case 4:
                ballPre.transform.position = new Vector3(ballPos.x, ballPos.y, ballPos.z - 2);
                break;
            }

            //SET BALLS
            RigidbodyContainer rigidbodyContainer = new RigidbodyContainer();
            rigidbodyContainer.StoreRigidbody(ballPre.transform.GetChild(0).GetComponent <Rigidbody>());
            sceneContainer.GetRigidbodyContainers().Add(rigidbodyContainer);

            sceneContainer.GetBalls().Add(ballPre.transform.GetChild(0).gameObject);
            sceneContainer.GetBallPositions().Add(ballPre.transform.GetChild(0).position);

            //SET SHADOWS
            sceneContainer.GetShadows().Add(ballPre.transform.GetChild(1).gameObject);
            sceneContainer.GetShadowPositions().Add(ballPre.transform.GetChild(1).position);
        }
    }
コード例 #3
0
 protected virtual void Awake()
 {
     RigidbodyContainer = new RigidbodyContainer(this);
 }