// Use this for initialization void Start() { //get the instance of pedometer plugin pedometerPlugin = PedometerPlugin.GetInstance(); isReady = true; // pedometerPlugin.OnStepCount(OnStepCount,OnStepDetect); // //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 (); // //pedometerPlugin.StartPedometerService (SensorDelay.SENSOR_DELAY_FASTEST); // isReady = true; // // // // } else { // //UpdateStepDetectorStatus ("not available"); // } }
// 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"); } }
// 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"); } }
public void Update() { pedometerPlugin = PedometerPlugin.GetInstance(); levelObj = GameObject.Find("level"); sliderObj = GameObject.Find("xpSlider"); if (levelObj != null && sliderObj != null) { //set level text from memory //int steps = pedometerPlugin.GetTotalStep() - PlayerPrefs.GetInt ("baseSubtract") - PlayerPrefs.GetInt("berrySpent"); int stepsXP = pedometerPlugin.GetTotalStep() - PlayerPrefs.GetInt("baseSubtract"); int levelNumber = stepsXP / STEPS_PER_XP; float toNextLevel = (stepsXP % STEPS_PER_XP) / (float)STEPS_PER_XP; Text levelText = levelObj.GetComponent <Text> (); levelText.GetComponentInChildren <Text>().text = "" + levelNumber; //set xp slider fullness Slider xpSlider = sliderObj.GetComponent <Slider>(); xpSlider.value = toNextLevel; } }
// 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"); } }
public void buyBerries() { pedometerPlugin = PedometerPlugin.GetInstance(); if ((pedometerPlugin.GetTotalStep() - PlayerPrefs.GetInt("baseSubtract") - PlayerPrefs.GetInt("berrySpent") > STEPS_PER_BERRY)) { PlayerPrefs.SetInt("berries", PlayerPrefs.GetInt("berries") + 1); PlayerPrefs.SetInt("berrySpent", PlayerPrefs.GetInt("berrySpent") + STEPS_PER_BERRY); } }
//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 }
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); }
// 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(); }