Exemplo n.º 1
0
    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);
    }
Exemplo n.º 2
0
    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);
        }
    }
Exemplo n.º 3
0
 public float GetHealth()
 {
     return(parentHealth.GetHealth());
 }