public void ApplyToPlayer() { //add game health if (playerProperties.health.enabled) { //interval is greater than zero, start a coroutine for adding health if (playerProperties.health.interval > 0) { GameHandler.instance.StopCoroutine("AddHealthRoutine"); GameHandler.instance.StartCoroutine("AddHealthRoutine", playerProperties.health); } else { //we haven't defined an interval, one-time add health float healthDiff = playerProperties.health.value; if (playerProperties.health.type == TDValue.percentual) { healthDiff = (int)(GameHandler.maxHealth * playerProperties.health.value); } GameHandler.AddHealth(healthDiff); } } //add game resources, similar to adding game health if (playerProperties.resources.enabled) { if (playerProperties.resources.interval > 0) { GameHandler.instance.StopCoroutine("SetResourcesRoutine"); GameHandler.instance.StartCoroutine("SetResourcesRoutine", playerProperties.resources); } else { for (int i = 0; i < playerProperties.resources.value.Length; i++) { float resDiff = playerProperties.resources.value[i]; if (playerProperties.resources.type == TDValue.percentual) { resDiff = (int)(GameHandler.resources[i] * playerProperties.resources.value[i]); } GameHandler.SetResources(i, resDiff); } } } }