예제 #1
0
    private Simulation LoadData(String dataFile, String name)
    {
        Simulation simulation = new Simulation(dataFile, name);
        TextAsset  data       = Resources.Load(dataFile) as TextAsset;
        CoordsTime coordsTime = JsonUtility.FromJson <CoordsTime>(data.text);

        simulation.initialize(coordsTime);

        // instantiate balls
        int ballCount = simulation.coordsTime.coords_time[0].balls.Length;

        simulation.balls           = new GameObject[ballCount];
        simulation.prevBallHeights = new float[ballCount];
        for (int i = 0; i < ballCount; i++)
        {
            simulation.balls[i] = Instantiate(
                tennisBall, new Vector3(0, 0, 0), Quaternion.identity
                );

            // instantiate minBallHeights
            simulation.prevBallHeights[i] = float.MaxValue;
        }


        print(simulation.balls.Length);
        return(simulation);
    }
예제 #2
0
    public int prevGeneration = 0;  // for tracking generation change.

    public void initialize(CoordsTime coordsTime)
    {
        this.coordsTime = coordsTime;
    }