Hey I'm doing a game that has waves and every 10 waves there's a boss, every wave that you pass there will be more enemies. Wave 0-20, 1 enemy more for wave, wave 20-40, 3 enemies.... Of course you have virtual currency and all stuff. I know how to make it offline but I have never used cloud script, so I don't know to what extent the code has to be put on the server. I mean, It's necessary that I have to call every time to cloudscript to know how many enemies has spawned to know if I have to spawn more or I can save it in a variable on unity? I don't know how to do it well that the player can't cheat on it.
I have searched it a lot, but I haven't found anything interesting...
For now I have done that every time you killed all enemies it runs the cloud script.
if (enemiesSpawned != enemiesToSpawn) { int spawnPointToSpawn = Random.Range(0, spawnPoints.Count); float temp = Random.Range(2, 5); Instantiate(Enemie, spawnPoints[spawnPointToSpawn].transform.position, spawnPoints[spawnPointToSpawn].transform.rotation); enemiesSpawned++; yield return new WaitForSeconds(waitTime); StartCoroutine(Spawn(temp)); } else if(enemiesSpawned == enemiesToSpawn) { DataBaseManager.DBM.NextWave(); StartWaves(); }
Every time that all enemies has spawned I add 1 to enemiesToSpawn and I set enemiesSpawned to 0. For that I think that the player can manipulate the enemiesSpawned or the enemiesToSpawn and cheat in the game. I don't know How doing it because every time you spawn an enemy, make a cloud script call, it's so much maybe.
If you reach to 0 lives you have start the game again and all stats will be reset. For now I have made this to reset the wave stat:
handlers.ResetWave = function(args, context) { var stat = server.GetPlayerStatistics({ PlayFabId: currentPlayerId, StatisticNam es: "CurrentLevel" }); var result = parseInt(stat.Statistics[0].Value); var request = { PlayFabId: currentPlayerId, Statistics: [{ "StatisticName": "Wave", "Value": -(result) }] }; server.UpdatePlayerStatistics(request); };
I think that that's not the best way of doing this. I get the statistic and I update the statistic subtracting the same value.
The last thing is the enemy's script. There will be enemies that have different health and different speed. For that, every time I spawn an enemy I have to take the speed and health from the database? If an enemy has 200 HP It can be modified by the player using cheats? And the speed too?
Thanks for all and sorry for my english.