Example #1
0
 public SchoolScene()
 {
     EarthquakeManager = new EarthquakeManager();
 }
Example #2
0
    private void Awake()
    {
        Instance = this;

        _initialPosition = Platform.transform.position;

        _rb         = Platform.GetComponent <Rigidbody>();
        Earthquakes = Resources.LoadAll <Earthquake>("Data/Earthquake/Data").ToList();

        #region Dictionary

        if (Earthquakes != null && Earthquakes.Count > 0)
        {
            for (int i = 0; i < Earthquakes.Count; i++)
            {
                // to read and write only once =>
                if (Earthquakes[i].Info.XAxis.Acceleration.Length == 0 ||
                    Earthquakes[i].Info.XAxis.Seconds.Length == 0 ||
                    Earthquakes[i].Info.ZAxis.Acceleration.Length == 0 ||
                    Earthquakes[i].Info.ZAxis.Seconds.Length == 0
                    )
                {
                    //get axes
                    Earthquakes[i].Info = ReadFromTXT.ReturnEarthquakeInfo(
                        Earthquakes[i].X,
                        Earthquakes[i].Z
                        );

                    //set seconds
                    Earthquakes[i].Info.MaxSeconds = Earthquakes[i].Info.XAxis.Seconds[
                        Earthquakes[i].Info.XAxis.Seconds.Length - 1
                                                     ];

                    //calculate average acceleration

                    float xAverage = Earthquakes[i].Info.XAxis.Acceleration.Average();
                    float zAverage = Earthquakes[i].Info.ZAxis.Acceleration.Average();

                    Earthquakes[i].Info.AverageAcceleration = new Vector3(xAverage, 0, zAverage);

                    //add to dictionary
                }
                else
                {
                    Debug.Log("No empty data detected. Using the pre-filled ones ...");
                }
                if (Earthquakes[i] != null)
                {
                    Dictionary.Add(Earthquakes[i].Type, Earthquakes[i].Info);
                }
            }
        }

        #endregion

        #region Events And Actions

        //change
        OnEarthquakeChange.AddListener(
            delegate { OnEQChange(); }
            );
        //start
        OnEarthquakeStart.AddListener(
            delegate { OnEQStart(); }
            );
        //Pause
        OnEarthquakePause.AddListener(
            delegate { OnEQPause(); }
            );
        //Continue
        OnEarthquakeContinue.AddListener(
            delegate { OnEQContinue(); }
            );
        //stop
        OnEarthquakeStop.AddListener(
            delegate { OnEQStop(); }
            );

        #endregion
    }