Пример #1
0
    // Use this for initialization
    void Start()
    {
        //get the instance of pedometer plugin
        pedometerPlugin = PedometerPlugin.GetInstance();

        //set to zero to hide debug toast messages
        pedometerPlugin.SetDebug(0);

        utilsPlugin = UtilsPlugin.GetInstance();
        utilsPlugin.SetDebug(0);

        //check if step detector is supported
        bool hasStepDetector = utilsPlugin.HasStepDetector();

        if (hasStepDetector)
        {
            UpdateStepDetectorStatus("available");

            //initialze pedometer
            pedometerPlugin.Init();

            //set this to true to always starts at zero steps, else set to false to continue steps
            pedometerPlugin.SetAlwaysStartAtZero(true);

            //set call back listener for pedometer events
            pedometerPlugin.SetCallbackListener(OnStepCount, OnStepDetect);

            //register sensor event listener and pass sensor delay that you want
            pedometerPlugin.RegisterSensorListener(SensorDelay.SENSOR_DELAY_FASTEST);
        }
        else
        {
            UpdateStepDetectorStatus("not available");
        }
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        //get the instance of pedometer plugin
        pedometerPlugin = PedometerPlugin.GetInstance();

        //set to zero to hide debug toast messages
        pedometerPlugin.SetDebug(0);

        utilsPlugin = UtilsPlugin.GetInstance();
        utilsPlugin.SetDebug(0);

        //check if step detector is supported on the current android mobile device
        bool hasStepDetector = utilsPlugin.HasStepDetector();
        bool hasStepCounter  = utilsPlugin.HasStepCounter();

        //if (hasStepDetector) {
        if (hasStepCounter)
        {
            // yehey your android mobile device support pedometer

            UpdateStepDetectorStatus("available");
            // event listeners
            AddEventListeners();
            //initialze pedometer
            pedometerPlugin.Init();
        }
        else
        {
            // if you get this meaning
            // pedometer is not available on your android mobile device sorry!
            UpdateStepDetectorStatus("not available");
        }
    }
Пример #3
0
    // Use this for initialization
    void Start()
    {
        //get the instance of pedometer plugin
        pedometerPlugin = PedometerPlugin.GetInstance();

        //set to zero to hide debug toast messages
        pedometerPlugin.SetDebug(0);

        utilsPlugin = UtilsPlugin.GetInstance();
        utilsPlugin.SetDebug(0);

        //check if step detector is supported
        bool hasStepDetector = utilsPlugin.HasStepDetector();
        bool hasStepCounter  = utilsPlugin.HasStepCounter();

        //if (hasStepDetector) {
        if (hasStepCounter)
        {
            UpdateStepDetectorStatus("available");
            // event listeners
            AddEventListeners();
            //initialze pedometer
            pedometerPlugin.Init();
        }
        else
        {
            UpdateStepDetectorStatus("not available");
        }
    }
Пример #4
0
    //Runs each time game starts
    public void Start()
    {
        pedometerPlugin = PedometerPlugin.GetInstance();
        pedometerPlugin.SetDebug(0);

        pedometerPlugin.Init();
        pedometerPlugin.StartPedometerService(SensorDelay.SENSOR_DELAY_FASTEST);
        steps = pedometerPlugin.GetStepToday();

        //get time as ascii value
        int d1 = DateTime.Now.Hour;

        System.DateTime epochStart = new System.DateTime(2018, 1, 1, 0, 0, 0, System.DateTimeKind.Utc);
        int             cur_time   = (int)(System.DateTime.UtcNow - epochStart).TotalHours;

        //check last time health was calculated
        float healthDeduction = PlayerPrefs.GetFloat("health") - (healthDrainRate * (cur_time - PlayerPrefs.GetFloat("timeOfLastHealthCheck")));

        //Steps should be zero if its a new day
        int oldSteps = PlayerPrefs.GetInt("steps");

        if (oldSteps > steps)
        {
            oldSteps = steps;
            PlayerPrefs.SetInt("steps", steps);
        }

        //reduce health
        PlayerPrefs.SetFloat("health", healthDeduction);
        PlayerPrefs.SetFloat("timeOfLastHealthCheck", cur_time);

        //Load scene from PlayerPrefs
        GameObject sliderObj = GameObject.Find("HealthSlider");

        if (sliderObj != null)
        {
            Slider healthSlider = sliderObj.GetComponent <Slider> ();
            healthSlider.value = PlayerPrefs.GetFloat("health");
        }
        else
        {
            Debug.Log("Slider is null");
        }

        //Load number of berries in button
        GameObject feedObject = GameObject.Find("berryCount");

        if (feedObject != null)
        {
            Text berriesText = feedObject.GetComponent <Text> ();
            feedObject.GetComponentInChildren <Text>().text = "" + PlayerPrefs.GetInt("berries");
        }


        //load slider
    }
Пример #5
0
    void Start()
    {
        //Get steps from save file
        steps = GameObject.Find("SaveManager").GetComponent <SaveManager>().state.steps;

        //Gets instance
        pedometer = PedometerPlugin.GetInstance();

        //Hides debug messages when set to zero
        pedometer.SetDebug(0);

        //Initaialize
        pedometer.Init();
        pedometer.StartPedometerService(sensor);
    }
Пример #6
0
    // Use this for initialization
    void Start()
    {
        //get the instance of pedometer plugin
        pedometerPlugin = PedometerPlugin.GetInstance();

        //set to zero to hide debug toast messages
        pedometerPlugin.SetDebug(0);

        //initialze pedometer
        pedometerPlugin.Init();

        //set this to true to always starts at zero steps, else set to false to continue steps
        pedometerPlugin.SetAlwaysStartAtZero(true);

        //set call back listener for pedometer events
        pedometerPlugin.SetCallbackListener(OnStepCount, OnStepDetect);

        //register sensor event listener
        pedometerPlugin.RegisterSensorListener();
    }
    // Use this for initialization
    void Start()
    {
        //get the instance of pedometer plugin
        pedometerPlugin = PedometerPlugin.GetInstance();

        //set to zero to hide debug toast messages
        pedometerPlugin.SetDebug(0);

        //initialze pedometer
        pedometerPlugin.Init();

        //set this to true to always starts at zero steps, else set to false to continue steps
        pedometerPlugin.SetAlwaysStartAtZero(true);

        //set call back listener for pedometer events
        pedometerPlugin.SetCallbackListener(OnStepCount,OnStepDetect);

        //register sensor event listener
        pedometerPlugin.RegisterSensorListener();
    }