How should I deal with adding new incremental achievements

允我心安 提交于 2019-12-13 03:49:18

问题


I am just now becoming more familiar with how achievements in Google Play Games Services work. Here's a generic example that I'm trying to figure out how I will deal with.

I have these achievements: Kill 5 Zombies, Kill 15 Zombies, 25, 50, etc.

Right now, I plan to increment each achievement when a zombie is killed. So kill 1 zombie and all 4 achievements are incremented by 1.

My question is, when I add another achievement (kill 100 zombies, for example) its incremental counter will start at 0. Let's say I've killed 49 zombies, so the counter for "Kill 50 zombies" would be at 49. How will I be able to add more achievements while still keeping the counter?

Is this normal to be incrementing multiple achievements at the same time? Do other games do this? How will I overcome this when I add new achievements? I want to try to avoid saving locally so any suggestions on how to fully utilize the API would be appreciated.

One of the reasons I'm worried about saving locally is that if I do that, one person can login, get their achievement, then logout and then another person logs in and gets the same achievement unlocked.


回答1:


OK, here's my solution and what I did. As far as I'm aware, this is the best option, but I could be wrong.

I made a "kill zombie" event and linked that event with different achievements. Whenever the "kill zombie" event was fired, it would increment all the "kill X zombies" achievements. However, if I would add another achievement mid-development, it would start one of those achievements at 0. I called these two load methods whenever the user logged in as there's really no point in doing this mid-game.

I fixed this by first loading the achievements with AchievementsClient#load then added an on success listener that then called EventsClient#load. If any achievement related to killing zombies was below the counter on said event, it would increment it to get up to date with the event counter.

This is a good option because it works across devices and makes sure that each achievement is up to date.



来源:https://stackoverflow.com/questions/55876926/how-should-i-deal-with-adding-new-incremental-achievements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!