// handles the event after the player drops an item into the quest game object void OnQuestDrop(GameObject questPlaceholder, GameObject droppedItem) { // Workaround since Unity always adds the "(Clone)" string to the game objects name string droppedItemRefID = droppedItem.name.Replace("(Clone)", ""); if (stepVM.IsAcceptedByQuest(questPlaceholder.name, droppedItemRefID)) { Quest quest = stepVM.GetQuest(questPlaceholder.name); quest.IsSolved = true; if (OnItemAcceptedByQuest != null) { OnItemAcceptedByQuest(droppedItemRefID); } // quest is solved. go to the quest.OnSolved step if (quest.OnSolved != null || quest.OnSolved != "") { StepVM svm = levelVM.GetStepVM(quest.OnSolved); InitStep(svm); } } }
// the player loads a saved game void OnPlayerStatusModelChanged() { inventoryVM.ItemsIdList = playerStatusModel.Items; Level level = gameModel.GetLevel(playerStatusModel.Level); LevelVM levelVM = new LevelVM(level); StepVM stepVM = levelVM.GetStepVM(playerStatusModel.Step); stepVM.ItemIdsListFilter = inventoryVM.ItemsIdList; gameComponent.ShowLoadingPrefab(); // give the game a bit time to destroy the current content // before loading the new one // this is a Workaround since NGUI seems to have a problem // get the game objects if the the game os loaded // in the same step as it were saved StartCoroutine(DelayInit(levelVM, stepVM)); }