Ejemplo n.º 1
0
    public static byte[] SerializeHealthPoint(object obj)
    {
        EnemyHealthPoint ehc = (EnemyHealthPoint)obj;

        byte[] result = new byte[8];
        BitConverter.GetBytes(ehc.viewId).CopyTo(result, 0);
        BitConverter.GetBytes(ehc.healthPoint).CopyTo(result, 4);
        return(result);
    }
Ejemplo n.º 2
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        EnemyHealthPoint enemyHP = hitInfo.GetComponent <EnemyHealthPoint> ();

        if (enemyHP != null)
        {
            enemyHP.TakeDamage(damage);
            Destroy(gameObject);
        }
    }
Ejemplo n.º 3
0
    public static object DeserializeEnemyHealthPoint(byte[] data)
    {
        EnemyHealthPoint result = new EnemyHealthPoint
        {
            viewId      = BitConverter.ToInt32(data, 0),
            healthPoint = BitConverter.ToInt32(data, 4)
        };

        return(result);
    }