First Android Game - Part 14 - Syncing LevelsAug 10, 2023This is part 14 of making my first Android Game. If you missed part13, you can find it hereI want to have a way to sync the background images and level increase across the network. I only want the master client to send this. In ScoreManager.cs, I added back the AddLevel() functionThe AddLevel() function would call the RPC function called AddLevelRPC that increases the level text and invokes the event LevelIncreaseEvent. This event has the background change subscribed to itTo test if this works, in Update(), when I press "A" I would call the AddLevel() functionSince the photonview is needed and the ScoreManager.cs is attached to the ScoreBoard prefab, the prefab must be put into the resources folderThe scoreboard prefab has PhotonView component attached to itTo change the background, I am looping through an array. To make sure I don't get index out of range, I would do a check to see if spriteIndex has passed the sprite array countUsing the "A" key to test. The background changes, level increases, and it gets synced across the networkNow I need to choose when to incrase a level. Level 2 occurs if 5 potato enemies gets destroyed. In ScoreManager, I created a int property called PotatoEnemyDestroyed that checks if 5 potato enemies get destroyed, then call AddLevel()The Enemy getting destroyed in EnemyBase.cs was modified so that there is a virtual EnemyDestroyed that will call EnemyDestroyedRPC function. The RPC function logic is the same as before where it spawns the explosionThe Enemy.cs that inherits from EnemyBase.cs will override EnemyDestroyed, in here I will set the property PotatoEnemyDestroyed to 1, so that the number of enemy destroyed will increase by 1I uncommented Level2() and Level3() in EnemyCannonSpawnInstance.csLevel2Routine() and Level3Routine() in EnemyCannonSpawnInstance.cs is modified so that I check if the anywhere in the list is null, since we destroy the enemy instead of disabling the enemy which was done when this game was only 1 playerCheck out the youtube video button above to see the results! See the next blog part 15 hereRecent blogsSee all blogs