Exemplo n.º 1
0
    public SensorData GetData()
    {
        float[] distances     = new float[Sensors.Length];
        int     activeSensors = 0;

        for (int i = 0; i < distances.Length; i++)
        {
            distances[i] = Sensors[i].Distance;
            if (Sensors[i].SensorActive)
            {
                activeSensors++;
            }
        }

        SensorData result = new SensorData(distances);

        if (gameplayScript != null && result != null)
        {
            result.InsertData("Score", gameplayScript.Score);
            result.InsertData("Game In Progress", (gameplayScript.InProgress) ? 1 : 0);
            result.InsertData("Active Sensors", activeSensors);
            result.InsertData("Velocity", gameplayScript.Velocity());
        }

        if (activeSensors == 0 && gameplayScript.InProgress)
        {
            Debug.LogWarning("Nieaktywne czujniki!!!");
        }

        return(result);
    }