コード例 #1
0
    public void RefForce()
    {
        Bl            = BallList.GetInstance();
        PointMass     = this.rigidbody.mass;
        PointPosition = V32Float(this.transform.position);
        float[] BallPosition = { 0, 0, 0 };
        float[] BallForce    = { 0, 0, 0 };
        float   BallMass     = 0;

        foreach (Ball bl in Bl.balllist)
        {
            BallMass     = bl.rigidbody.mass;
            BallPosition = V32Float(bl.transform.position);
            BallForce    = GetGravity(PointMass, BallMass, PointPosition, BallPosition);
            for (int i = 0; i < 3; i++)
            {
                PointForce[i] += BallForce[i];
            }
        }
        for (int i = 0; i < 3; i++)
        {
            PointForce [i] = PointForce [i] * 1f;
        }
        return;
    }
コード例 #2
0
    // Restart the simulation and camera view with new parameters
    public void RestartSimulation(int newNumBalls, float newBoxSize)
    {
        // Apply new user parameters
        numBalls = newNumBalls;
        boxSize  = newBoxSize;

        // Destroy current box and balls, if they exist
        if (box != null)
        {
            Destroy(box.gameObj);
        }
        if (ballList != null)
        {
            Destroy(ballList.gameObj);
        }

        // Does the user want to vary the radius?
        bool varyRadii = GameObject.Find("Panel").GetComponent <UserInputHandler> ().radiusToggle.isOn;

        // Does the user want color collisions?
        bool changeColor = GameObject.Find("Panel").GetComponent <UserInputHandler> ().colorToggle.isOn;

        // Create new box and balls with user parameters
        box      = new Box(transform, boxSize);
        ballList = new BallList(box.gameObj.transform, boxSize, numBalls, varyRadii, changeColor);

        // Reset camera view
        GameObject.Find("Main Camera").GetComponent <CameraController> ().ResetCamera(boxSize);
    }
コード例 #3
0
 public static BallList GetInstance()
 {
     if (instance == null)
     {
         instance = new BallList();
     }
     return(instance);
 }
コード例 #4
0
    public static void CreateMyBallList()
    {
        BallList asset = ScriptableObject.CreateInstance <BallList>();

        AssetDatabase.CreateAsset(asset, "Assets/CreatedAssets/NewBallList.asset");
        AssetDatabase.SaveAssets();

        EditorUtility.FocusProjectWindow();

        Selection.activeObject = asset;
    }
コード例 #5
0
        public void IsHit(int x, int y)
        {
            foreach (var ball in BallList)
            {
                if (ball.IsHit(x, y))
                {
                    ++Hits;
                }
            }

            BallList.RemoveAll(ball => ball.State == 0);
        }
コード例 #6
0
        public void Move()
        {
            foreach (var ball in BallList)
            {
                ball.Move(new Point(ball.Center.X + Velocity, ball.Center.Y));
                if (ball.Center.X >= Width + Ball.Radius)
                {
                    ball.State = -1;
                    ++Misses;
                }
            }

            BallList.RemoveAll(ball => ball.State == -1);
        }
コード例 #7
0
ファイル: Ball.cs プロジェクト: dtysky/Stars
    // Use this for initialization
    void Start()
    {
        float x, y, z, si, kg;
        float range = 1500;

        x  = Random.Range(-range, range) * 1f;
        y  = Random.Range(-range, range) * 1f;
        z  = Random.Range(-range, range) * 1f;
        si = Random.Range(1, 3);
        kg = si * 5;
        this.transform.position = new Vector3(x, y, z);
        this.rigidbody.mass     = kg;
        //this.transform.localScale.Set (si, si, si);
        BallList m;

        m = BallList.GetInstance();
        m.balllist.Add(this);
    }
コード例 #8
0
    /* -----------
    *  Code below
    *  ------------*/

    private void Awake()
    {
        player        = GameObject.FindGameObjectWithTag("Player").transform;
        ballGodScript = GameObject.Find("BallGod").GetComponent <BallList>();
        InitializeBattingPhase(homeBaseTarget);
    }
コード例 #9
0
 public void AddBall(Point center)
 {
     BallList.Add(new Ball(center));
 }
コード例 #10
0
 private void Awake()
 {
     targetingBeam  = gameObject.GetComponent <LineRenderer>();
     myScoreUpdater = GameObject.Find("ScoreUpdater").GetComponent <scoreUpdater>();
     myBallList     = GameObject.Find("BallGod").GetComponent <BallList>();
 }