public void SendDamageMessage(GameObject obj, int shooterID) { int id = _players.IndexOf(obj); IHaveHealth health = _players[id].GetComponent(typeof(IHaveHealth)) as IHaveHealth; float currentHealth = health.GetHealth(); string s = SerializationScript.SerializePlayerHealth(id, currentHealth, shooterID); SendData(s, 1, true); }
internal void UpdateHealth(string[] splitCode) { int id = int.Parse(splitCode[1]); int shooterID = int.Parse(splitCode[3]); float currentHealth = float.Parse(splitCode[2]); IHaveHealth target = network.GetPlayerOfID(id).GetComponent(typeof(IHaveHealth)) as IHaveHealth; float damage = target.GetHealth() - currentHealth; target?.TakeDamage(damage, shooterID); if (shooterID * -1 == _myID) { target?.SimulateDamage(network.GetPlayerOfID(id).transform.position + Vector3.up, damage); } }
public float GetHealth() { return(parentHealth.GetHealth()); }