protected void Notify(QuestInputData data) { foreach (IQuestObserver observer in observers) { observer.OnQuestInput(data); } }
/* * This function is used to handle Pedometer reading * @param * steps: steps taken from the start of session * distance: meters walked from start of sesssion */ private void OnStep(int steps, double distance) { totalDistance = distance + prevDistance; var data = new QuestInputData(INPUT_DISTANCE); data.PutValue(totalDistance); Notify(data); // Save total distance // PlayerPrefs.SetFloat(PREV_DISTANCE, (float) totalDistance); }
/* * This function is used to handle share reading */ public void OnShare(bool shareSucessful) { totalShare += shareSucessful? 1 : 0; // Save share progress PlayerPrefs.SetInt(PREV_SHARE, totalShare); var data = new QuestInputData(INPUT_SHARE); data.PutValue(totalShare); Notify(data); }
public override void Update(QuestInputData data) { shareTotal = (int)data.GetValue(FacebookQuestInput.INPUT_SHARE); // Not correct input method if (shareTotal == 0) { return; } isDone = (prevValue + requireValue <= shareTotal); // Debug.Log(shareStart.ToString() + " " + shareTotal.ToString()); }
public override void Update(QuestInputData data) { double totalDistance = data.GetValue(DistanceQuestInput.INPUT_DISTANCE); // Not correct input device if (totalDistance == 0) { return; } if (totalDistance - disStart >= disRequire) { isDone = true; } disTotal = totalDistance; }
public void OnQuestInput(QuestInputData data) { var newDis = data.GetValue(DistanceQuestInput.INPUT_DISTANCE); var newShare = data.GetValue(FacebookQuestInput.INPUT_SHARE); dbReader.totalDistance = Math.Max(newDis, dbReader.totalDistance); dbReader.totalShare = Math.Max((int)newShare, dbReader.totalShare); manager.UpdateQuest(data); if (manager.QuestIsFinish()) { dbReader.money += manager.GetQuest().rewardMoney; dbReader.exp += manager.GetQuest().rewardExp; manager.SetQuest(QuestFactory.Instance().GetQuest()); dbReader.SaveSimpleData(); } }
public void UpdateQuest(QuestInputData data) { currentQuest.Update(data); // FinishQuest(); }
public abstract void Update(QuestInputData data);