public void CmdSetAggro(ConstantsDictionary.PLAYERS player, float threat) { if (!isServer) { return; } threatLevels[(int)player] += threat; RpcChangeThreat(threatLevels); }
public void CmdTakeDotDamage(float percentage, float duration, ConstantsDictionary.PLAYERS player, float threat) { if (!isServer) { return; } coroutine = TakeDotDamage(percentage, duration, player, threat); StopCoroutine(coroutine); StartCoroutine(coroutine); }
//percentage is the percentage of HP to remove per tick, duration is the total duration of the damage //and tick is the delay between the application of the damage in seconds public IEnumerator TakeDotDamage(float percentage, float duration, ConstantsDictionary.PLAYERS player, float threat) { float timePassed = 0.0f; float amount = maxHealth * percentage / 100f; threat /= 3; while (timePassed < duration) { CmdTakeDamage(amount, player, threat); yield return(new WaitForSeconds(1f)); timePassed += 1f; } }
public void CmdTakeDamage(float amount, ConstantsDictionary.PLAYERS player, float threat) { if (!isServer) { return; } currentHealth -= amount; if (currentHealth <= 0) { currentHealth = 0; RpcSetDead(); } CmdSetAggro(player, threat); //GetComponent<Animator>().SetBool("NewThreat",true); enemyController.RpcSetAnimBool("NewThreat", true); }