public Achievement(AchievementInfo info) { achievementInfo = info; identifier = info.identifier; DataService ds = SQLiteDatabaseManager.Instance.ds; persistentAchievement = ds.GetPersistentAchievement(identifier); if (persistentAchievement == null) { persistentAchievement = new PersistentAchievement(); persistentAchievement.identifier = identifier; state = AchievementState.locked; ds.InsertAchievement(persistentAchievement); } delegates = new List <AchievementCompleteDelegate>(); LoadPrerequisite(); LoadAchievementSteps(); CheckForActivation(); CheckToActivateAchievementStep(); CheckForCompletion(); LoadFallthrough(); CheckForFallThroughtCompletion(); }
public static List <AchievementInfo> ReadExcel(string ePath) { List <AchievementInfo> list = new List <AchievementInfo>(); using (System.IO.FileStream stream = System.IO.File.Open(excelPath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read)) { using (ExcelDataReader.IExcelDataReader excelReader = ExcelDataReader.ExcelReaderFactory.CreateOpenXmlReader(stream)) { SetReader(excelReader); excelReader.Read(); for (int i = 1; i < excelReader.RowCount; i++) { excelReader.Read(); AchievementInfo info = new AchievementInfo(); info.id = GetInt(0); info.name = GetString(1); info.introduce = GetString(2); info.unFinishSprite = GetString(3); info.FinshedSprite = GetString(4); info.Count = GetInt(5); list.Add(info); } } } return(list); }
public override int HandlePacket(GamePlayer player, GSPacketIn packet) { int id = packet.ReadInt(); AchievementInfo achievement = player.AchievementInventory.FindAchievement(id); return(0); }
public bool AddAchievementData(AchievementInfo achievementInfo) { bool result; if (!this.IsAchievementFinish(achievementInfo)) { AchievementDataInfo achievementData = new AchievementDataInfo(); achievementData.UserID = this.m_player.PlayerId; achievementData.AchievementID = achievementInfo.ID; achievementData.IsComplete = true; achievementData.CompletedDate = DateTime.Now; achievementData.IsDirty = true; List <AchievementDataInfo> data; Monitor.Enter(data = this.m_data); try { this.m_data.Add(achievementData); } finally { Monitor.Exit(data); } result = true; } else { result = false; } return(result); }
//public SignalScript achievementSignal; public void Setup(AchievementInfo item, AchievementManager manager) { thisItem = item; thisManager = manager; if (thisItem) { itemName.text = thisItem.itemName; itemText.text = thisItem.itemDescription; reward.text = "" + thisItem.reward; if (thisItem.isAchieved) { if (!_achievementTracker._myAchievement.Contains(thisItem)) { _achievementTracker._myAchievement.Add(thisItem); } if (thisItem.isCollected) { ColorBlock colorBlock = collectBtn.colors; colorBlock.disabledColor = Color.clear; collectBtn.colors = colorBlock; collectBtn.interactable = false; } else { collectBtn.interactable = true; } } else { collectBtn.interactable = false; } } }
public void DisplayAchievementInfo(AchievementInfo achInfo, ProfileManager ProfileManager) { // set name text NameText.text = achInfo.Name; // set image background Texture2D texture = ProfileManager.DefaultSprite; foreach (var t in ProfileManager.SpritesAchievements) { if (t.name.Equals(achInfo.Name)) { texture = t; } } this.GetComponent <RawImage>().texture = texture; //set details text (info + completion) DetailsText.text = achInfo.InfoText + "\n"; foreach (var ev in achInfo.EventsToListen) { DetailsText.text += "\n"; int[] values = achInfo.getCompletion(ev); if (values[1] <= values[0]) { DetailsText.text += "[ok] "; } DetailsText.text += ev.ToString() + " : " + values[0] + " / " + values[1]; } }
private int StoreAchievements() { if (this.achievementList.Items.Count == 0) { return(0); } List <AchievementInfo> achievementInfoList = new List <AchievementInfo>(); foreach (ListViewItem listViewItem in this.achievementList.Items) { AchievementInfo tag = listViewItem.Tag as AchievementInfo; if (tag.Achieved != listViewItem.Checked) { tag.Achieved = listViewItem.Checked; achievementInfoList.Add(listViewItem.Tag as AchievementInfo); } } if (achievementInfoList.Count == 0) { return(0); } foreach (AchievementInfo achievementInfo in achievementInfoList) { if (!this.SteamClient.SteamUserStats.SetAchievement(achievementInfo.Id, achievementInfo.Achieved)) { int num = (int)MessageBox.Show((IWin32Window)this, string.Format("An error occured while setting the state for {0}, aborting store.", (object)achievementInfo.Id), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); return(-1); } } return(achievementInfoList.Count); }
private void AchieveInfoSet(RectTransform rt, PAchieve Dinfo) { AchievementInfo achieveInfo = rt.gameObject.GetComponentDefault <AchievementInfo>(); achieveInfo.Click(Achievementsend, Dinfo.id); achieveInfo.SetInfo(Dinfo); }
private void displayInfo() { if (queue.Count > 0) { AchievementInfo achInfo = queue.Peek(); Text.text = achInfo.Name; Texture2D texture = SProfilePlayer.getInstance().DefaultSprite; if (SProfilePlayer.getInstance().SpritesAchievements != null) { foreach (var t in SProfilePlayer.getInstance().SpritesAchievements) { if (t.name.Equals(achInfo.Name)) { texture = t; } } } else { Debug.LogError("Lance la scene depuis le menu !"); } Image.texture = texture; speed = -GameVariables.Achievements.PopUp.speedCome; } }
private void UpdateTitleIcon(AchievementInfo info) { m_spriteArray[(int)SPRITE_TYPE.TYPE_TITLE_QUEST_ICON].gameObject.SetActive(false); m_spriteArray[(int)SPRITE_TYPE.TYPE_TITLE_MATERIAL_ICON].gameObject.SetActive(false); m_spriteArray[(int)SPRITE_TYPE.TYPE_TITLE_ITEM_ICON].gameObject.SetActive(false); if (info.image.Contains("Quest_")) { m_spriteArray[(int)SPRITE_TYPE.TYPE_TITLE_QUEST_ICON].gameObject.SetActive(true); m_spriteArray[(int)SPRITE_TYPE.TYPE_TITLE_QUEST_ICON].spriteName = info.image; m_spriteArray[(int)SPRITE_TYPE.TYPE_TITLE_QUEST_ICON].MakePixelPerfect(); } else if (info.image.Contains("Icon_Shop_")) { m_spriteArray[(int)SPRITE_TYPE.TYPE_TITLE_MATERIAL_ICON].gameObject.SetActive(true); m_spriteArray[(int)SPRITE_TYPE.TYPE_TITLE_MATERIAL_ICON].spriteName = info.image; m_spriteArray[(int)SPRITE_TYPE.TYPE_TITLE_MATERIAL_ICON].MakePixelPerfect(); } else { m_spriteArray[(int)SPRITE_TYPE.TYPE_TITLE_ITEM_ICON].gameObject.SetActive(true); m_spriteArray[(int)SPRITE_TYPE.TYPE_TITLE_ITEM_ICON].spriteName = info.image; m_spriteArray[(int)SPRITE_TYPE.TYPE_TITLE_ITEM_ICON].MakePixelPerfect(); } }
public void AddAchievement(AchievementInfo achInfo) { queue.Enqueue(achInfo); if (queue.Count <= 1) { displayInfo(); } }
// Methods public static List <AchievementConditionInfo> GetAchievementCondition(AchievementInfo info) { if (m_achievementCondition.ContainsKey(info.ID)) { return(m_achievementCondition[info.ID]); } return(null); }
public static List <AchievementRewardInfo> GetAchievementReward(AchievementInfo info) { if (m_achievementReward.ContainsKey(info.ID)) { return(m_achievementReward[info.ID]); } return(null); }
private bool IsAchievementFinish(AchievementInfo achievementInfo) { IEnumerable <AchievementDataInfo> data = from s in this.m_data where s.AchievementID == achievementInfo.ID select s; return(data != null && data.ToList <AchievementDataInfo>().Count > 0); }
public void Subscribe(AchievementEvent listen, AchievementInfo ach) { if (!listeners.ContainsKey(listen)) { listeners.Add(listen, new List <AchievementInfo>()); Completion.Add(listen, 0); } listeners[listen].Add(ach); }
public void ClaimAchievement(Type levelBaseType, int achivementLevelIndex) { AchievementInfo achievementinfo = InfoResolver.Resolve <FortInfo>().Achievement.AchievementTypes[levelBaseType]; Array achivementLevelInfos = (Array)achievementinfo.GetType().GetProperty("LevelInfoes").GetValue(achievementinfo, new object[0]); if (achivementLevelIndex >= achivementLevelInfos.Length) { throw new Exception("Claim Achievement AchievementLevelInfoes out of index"); } //AchivementLevelInfo achivementLevelInfo = (AchivementLevelInfo)achivementLevelInfos.GetValue(achivementLevelIndex); string achievementId = achievementinfo.Id; AchievementStoredData achievementStoredData = ServiceLocator.Resolve <IStorageService>().ResolveData <AchievementStoredData>(); if (achievementStoredData == null) { achievementStoredData = new AchievementStoredData(); } if (achievementStoredData.Achievements.ContainsKey(achievementId) && achievementStoredData.Achievements[achievementId] <= achivementLevelIndex) { return; //throw new Exception("Achievement Already Claimed"); } achievementStoredData.Achievements[achievementId] = achivementLevelIndex; ServiceLocator.Resolve <IStorageService>().UpdateData(achievementStoredData); string[] possibleAchievementIds = achivementLevelInfos.Cast <AchievementLevelInfo>() .Take(achivementLevelIndex + 1) .Select(info => info.Id) .ToArray(); AchievementCache achievementCache = ServiceLocator.Resolve <IStorageService>().ResolveData <AchievementCache>(); if (achievementCache == null) { achievementCache = new AchievementCache(); } foreach (string possibleAchievementId in possibleAchievementIds) { if (!achievementCache.ServerAchievementIds.ContainsKey(possibleAchievementId)) { achievementCache.ServerAchievementIds.Add(possibleAchievementId, false); } } ServiceLocator.Resolve <IStorageService>().UpdateData(achievementCache); AchievementLevelInfo achievementLevelInfo = (AchievementLevelInfo)achivementLevelInfos.GetValue(achivementLevelIndex); ScoreBalance scoreBalance = ResolveAchievementScoreBalance(achievementLevelInfo.Id); ServiceLocator.Resolve <IUserManagementService>() .AddScoreAndBalance(scoreBalance.Score, scoreBalance.Balance); ServiceLocator.Resolve <IAnalyticsService>().StatAchievementClaimed(achievementLevelInfo.Id, scoreBalance); ServiceLocator.Resolve <IEventAggregatorService>().GetEvent <AchievementClaimedEvent>().Publish(new LevelBaseAchievementClaimedEventArgs((LevelBaseAchievementInfo)achievementinfo, achivementLevelIndex)); }
private void UpdateRewardIcon(AchievementInfo info) { m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_GEMS_ICON].gameObject.SetActive(false); m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_ITEM_ICON].gameObject.SetActive(false); m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_MATERIAL_ICON].gameObject.SetActive(false); m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_DOG_ICON].gameObject.SetActive(false); if (info.CheckGoodsType) { m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_GEMS_ICON].gameObject.SetActive(true); m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_GEMS_ICON].spriteName = Util.GetGoodsIconName(Util.GetGoodsTypeByIndex((int)info.rewardIndex)); m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_GEMS_ICON].MakePixelPerfect(); m_labelArray[(int)LABEL_TYPE.TYPE_REWARD_COUNT].text = string.Format("{0}", info.rewardCount); } else if (info.CheckDogType) { DogInfo dogInfo = WorldManager.instance.m_dataManager.m_dogData.GetDogData(info.rewardIndex); m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_DOG_ICON].gameObject.SetActive(true); m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_DOG_ICON].spriteName = string.Format("Icon_{0}", WorldManager.instance.m_dataManager.m_SkinTexture.GetTexureName(dogInfo.basicSkin)); m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_DOG_ICON].MakePixelPerfect(); m_labelArray[(int)LABEL_TYPE.TYPE_REWARD_COUNT].text = ""; } else { ITEM_TYPE parseType = Util.ParseItemMainType(info.rewardIndex); if (parseType.Equals(ITEM_TYPE.DOGTICKET)) { m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_DOG_ICON].gameObject.SetActive(true); m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_DOG_ICON].spriteName = WorldManager.instance.GetGUISpriteName(info.rewardIndex); m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_DOG_ICON].MakePixelPerfect(); m_labelArray[(int)LABEL_TYPE.TYPE_REWARD_COUNT].text = ""; } else if (Util.CheckAtlasByItemType(parseType)) { m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_MATERIAL_ICON].gameObject.SetActive(true); m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_MATERIAL_ICON].spriteName = WorldManager.instance.GetGUISpriteName(info.rewardIndex); m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_MATERIAL_ICON].MakePixelPerfect(); } else { m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_ITEM_ICON].gameObject.SetActive(true); m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_ITEM_ICON].spriteName = WorldManager.instance.GetGUISpriteName(info.rewardIndex); m_spriteArray[(int)SPRITE_TYPE.TYPE_REWARD_ITEM_ICON].MakePixelPerfect(); } m_labelArray[(int)LABEL_TYPE.TYPE_REWARD_COUNT].text = string.Format("{0}", info.rewardCount); } }
private async Task ReloadAchievementsAsync(bool reloadImages) { EnableInteraction(false); lv.Items.Clear(); var achCount = SteamUserStats.GetNumAchievements(); var achIds = new List <string>(); for (var i = 0u; i < achCount; i += 1) { var achId = SteamUserStats.GetAchievementName(i); achIds.Add(achId); } foreach (var achId in achIds) { Bitmap icon = null; if (reloadImages) { icon = await GetAchievementIconAsync(achId); if (icon != null) { iml.Images.Add(achId, icon); } } var ach = AchievementInfo.Query(achId); var lvi = new ListViewItem(); lvi.Text = ach.DisplayName; if (icon != null || !reloadImages) { lvi.ImageKey = achId; } lvi.SubItems.Add(BoolToStr(ach.IsAchieved)); lvi.SubItems.Add(ach.Description); lvi.SubItems.Add(ach.ApiName); lvi.SubItems.Add(BoolToStr(ach.IsHidden)); lvi.Tag = ach; lv.Items.Add(lvi); } lblStats.Visible = true; UpdateStatsText(); EnableInteraction(true); }
public static List <AchievementConditionInfo> GetAchievementCondition(AchievementInfo info) { if (AchievementMgr.m_achievementCondition.ContainsKey(info.ID)) { return(AchievementMgr.m_achievementCondition[info.ID]); } else { return((List <AchievementConditionInfo>)null); } }
private bool CheckAchievementData(AchievementInfo info) { bool result; if (info.EndDate < DateTime.Now) { result = false; } else { if (info.NeedMaxLevel < this.m_player.Level) { result = false; } else { if (info.IsOther == 1 && this.m_player.PlayerCharacter.ConsortiaID <= 0) { result = false; } else { if (info.IsOther == 2 && this.m_player.PlayerCharacter.SpouseID <= 0) { result = false; } else { if (info.PreAchievementID != "0,") { string[] tempArry = info.PreAchievementID.Split(new char[] { ',' }); for (int i = 0; i < tempArry.Length; i++) { if (!this.IsAchievementFinish(AchievementMgr.GetSingleAchievement(Convert.ToInt32(tempArry[i])))) { result = false; return(result); } } result = true; } else { result = true; } } } } } return(result); }
public static List <AchievementRewardInfo> GetAchievementReward(AchievementInfo info) { if (AchievementMgr.m_achievementReward.ContainsKey(info.ID)) { return(AchievementMgr.m_achievementReward[info.ID]); } else { return((List <AchievementRewardInfo>)null); } }
private void NotifyAchievement(AchievementInfo achInfo) { if (achInfo != null) { if (!playerAchievements.IsAchievementUnlocked(achInfo.id)) { HUDManager.GetInstance().Toast(HUDManager.ToastType.ACHIEVEMENT_TOAST, "Achievement unlocked", achInfo.sprite, 2.5f, 0.25f, true); playerAchievements.UnlockAchievement(achInfo.id); } } }
private static AchievementInfo[] CopyAchievements(AchievementInfo[] achievements) { var newAchievements = new AchievementInfo[achievements.Length]; for (var i = 0; i < achievements.Length; i++) { newAchievements[i] = new AchievementInfo(achievements[i]); } return(newAchievements); }
private void AddAchievementIcon(AchievementInfo info, Image icon) { if (icon == null) { info.ImageIndex = 0; } else { info.ImageIndex = this.achievementIcons.Images.Count; this.achievementIcons.Images.Add(info.Achieved ? info.Icon : info.IconGray, icon); } }
public static AchievementLevelInfo GetNextClaimableAchievementLevelInfo(this IAchievementService achievementService, Type levelBaseType) { int index = achievementService.GetAchievementClaimedIndex(levelBaseType) + 1; AchievementInfo achievementInfo = InfoResolver.Resolve <FortInfo>().Achievement.AchievementTypes[levelBaseType]; Array value = (Array)levelBaseType.GetProperty("LevelInfo").GetValue(achievementInfo, new object[0]); if (index >= value.Length) { return(null); } return((AchievementLevelInfo)value.GetValue(index)); }
//----------------------------------------------------------------------------- // Purpose: Unlock this achievement //----------------------------------------------------------------------------- /// <summary> /// 解锁一个成就 /// </summary> /// <param name="achievement"></param> private void UnlockAchievement(AchievementInfo achievement) { achievement.m_bAchieved = true; // the icon may change once it's unlocked //achievement.m_iIconImage = 0; // mark it down SteamUserStats.SetAchievement(achievement.m_apiName); // Store stats end of frame m_bStoreStats = true; }
public bool CheckAchieveRewardComplete(AchievementInfo info) { foreach (SAchieveInfo sInfo in m_sAchieveInfoTable.Values) { AchievementInfo aInfo = WorldManager.instance.m_dataManager.m_achievementData.GetInfo(sInfo.achCode); if (aInfo != null && aInfo.achIndex.Equals(info.achIndex) && aInfo.index >= info.index) { return(true); } } return(false); }
public void HandleAchievementGrant(ICommandContext context, [Parameter("Achievement id to grant.")] ushort achievementId) { AchievementInfo info = GlobalAchievementManager.Instance.GetAchievement(achievementId); if (info == null) { context.SendMessage($"Invalid achievement id {achievementId}!"); return; } context.GetTargetOrInvoker <Player>().AchievementManager.GrantAchievement(achievementId); }
public void Unsubscribe(AchievementEvent listen, AchievementInfo ach) { var list = listeners[listen]; list.Remove(ach); if (list.Count <= 0) { listeners.Remove(listen); } else { listeners[listen] = list; } }
public AchievementItem(int index, GameObject root) { id = index; this.root = root; playerData = PlayerDataOperator.Instance.playerData; acInfo = AchievementInfoMgr.Instance.infoList[id]; acImage = Find <Image>("Img_Light"); txt_Name = Find <Text>("Txt_Name"); txt_Introduce = Find <Text>("Txt_Introduce"); txt_Name.text = acInfo.name; txt_Introduce.text = acInfo.introduce; SetAcImage(); EventCenter.AddListener(EventType.AcItemUpdate, SetAcImage); }