void Start() { //PlayerPrefs.DeleteAll();//TODO: delete this //Ищем только миссии, которые еще не выполнялись и текущие тоже ищем Dictionary <string, string> currentMissionsKeyData = CurrentMissionsSerializer.GetCurrentMissionsKeyData(misionCurrentTag); for (int i = 0; i < missions.Length; i++) { Mission missionPrefab = missions [i]; string id = missionPrefab.name; missionPrefab.SetId(id); if (!IsMissionFinished(id)) { prefabKeyDictionary [missionPrefab] = id; if (currentMissionsKeyData.ContainsKey(id)) { Mission mission = InstantiateMission(missionPrefab); mission.Unserialize(currentMissionsKeyData [id].ToString()); currentMissions.Add(mission); } else { availableMissionsPrefabs.Add(missionPrefab); } } else { finishedMissionsNumber++; } } EmmitMissions(true); }
//IMissionListener public void MissionProgressChanged(Mission mission) { if (!mission.oneLife) { CurrentMissionsSerializer.SaveMissionData(mission); } }
public void MissionFinished(Mission mission) { finishedMissionsNumber++; GlobalOptions.GetPlayerScript().Yahoo(); SetMissionFinished(mission.GetId()); currentMissions.Remove(mission); if (currentMissions.Count == 0) { NotifyNoMissions(); } thisLifeFinishedMissions.Add(mission); CurrentMissionsSerializer.SaveCurrentMissions(currentMissions, misionCurrentTag); CurrentMissionsSerializer.RemoveMissionData(mission); timeOutTime = Time.time + GetTimeOut(); }
public virtual void EmmitMissions(bool force = false) { if (!force && (GlobalOptions.gameState != GameStates.GAME || IsTimeOut())) { return; } if (currentMissions.Count == 0) //инициализируем текущую { Mission currentMission = GetOneMissionObject(); if (currentMission != null) { NotifyHasMissions(); currentMissions.Add(currentMission); } CurrentMissionsSerializer.SaveCurrentMissions(currentMissions, misionCurrentTag); } }
private void TryToGetNextFromEmmitted(bool force = false) { if (!force && (GlobalOptions.gameState != GameStates.GAME || IsTimeOut())) { return; } if (currentMissions.Count == 0) //инициализируем текущую { if (emmittedMissionsPrefabs.Count > 0) { Mission missionPrefab = (Mission)emmittedMissionsPrefabs [0]; Mission currentMission = InstantiateMission(missionPrefab); emmittedMissionsPrefabs.RemoveAt(0); currentMissions.Add(currentMission); CurrentMissionsSerializer.SaveCurrentMissions(currentMissions, misionCurrentTag); //save CurrentMissionsSerializer.SaveCurrentMissions(emmittedMissionsPrefabs, misionEmmittedTag); } } }
void Start() { this.name = this.name.Replace("(Clone)", ""); //Ищем только миссии, которые еще не выполнялись и текущие тоже ищем Dictionary <string, string> currentMissionsKeyData = CurrentMissionsSerializer.GetCurrentMissionsKeyData(misionCurrentTag); Dictionary <string, string> emittedMissionsKeyData = CurrentMissionsSerializer.GetCurrentMissionsKeyData(misionEmmittedTag); for (int i = 0; i < missions.Length; i++) { Mission missionPrefab = missions [i]; string id = missionPrefab.name; missionPrefab.SetId(id); if (!IsMissionFinished(id)) { prefabKeyDictionary [missionPrefab] = id; if (currentMissionsKeyData.ContainsKey(id)) { Mission mission = InstantiateMission(missionPrefab); mission.Unserialize(currentMissionsKeyData [id].ToString()); currentMissions.Add(mission); } else if (emittedMissionsKeyData.ContainsKey(id)) { emmittedMissionsPrefabs.Add(missionPrefab); } else { availableMissionsPrefabs.Add(missionPrefab); } } else { finishedMissionsNumber++; } } //инициализируем cлоты (куплены они или нет) for (int i = 0; i < slots.Length; i++) { Slot slot = slots [i]; slot.Init(); } EmmitMissions(false); }
public void EmmitMissions(bool force = false) { TryToGetNextFromEmmitted(); if (force || canEmmitMissions()) { Mission currentMission = null; TryToGetNextFromEmmitted(true); if (currentMissions.Count == 0) //инициализируем текущую { currentMission = GetOneMissionObject(); if (currentMission != null) { NotifyHasMissions(); currentMissions.Add(currentMission); } CurrentMissionsSerializer.SaveCurrentMissions(currentMissions, misionCurrentTag); } //emmitted int numberOfBoughtSlots = NumberOfBoughtSlots(); if (emmittedMissionsPrefabs.Count < numberOfBoughtSlots - 1) { for (int i = emmittedMissionsPrefabs.Count; i < numberOfBoughtSlots - 1; i++) { if (availableMissionsPrefabs.Count > 0) { Mission missionPrefab = (Mission)availableMissionsPrefabs [0]; availableMissionsPrefabs.Remove(missionPrefab); emmittedMissionsPrefabs.Add(missionPrefab); } } CurrentMissionsSerializer.SaveCurrentMissions(emmittedMissionsPrefabs, misionEmmittedTag); } lastMissionEmmitTime = GlobalOptions.GetLongFromDateTime(System.DateTime.UtcNow); MissionsUpdated(); } }
public override void EmmitMissions(bool force = false) { if (!PersonInfo.tutorial) { return; } if (!force && (GlobalOptions.gameState != GameStates.GAME || IsTimeOut())) { return; } if (currentMissions.Count == 0) //инициализируем текущую { Mission currentMission = GetOneMissionObject(); if (currentMission != null) { currentMissions.Add(currentMission); } else { PersonInfo.FinishTutorial(); } CurrentMissionsSerializer.SaveCurrentMissions(currentMissions, misionCurrentTag); } }
public void MissionActivated(Mission mission) { CurrentMissionsSerializer.SaveMissionData(mission); }