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); }
void OnTriggerEnter2D(Collider2D hitInfo) { EnemyHealthPoint enemyHP = hitInfo.GetComponent <EnemyHealthPoint> (); if (enemyHP != null) { enemyHP.TakeDamage(damage); Destroy(gameObject); } }
public static object DeserializeEnemyHealthPoint(byte[] data) { EnemyHealthPoint result = new EnemyHealthPoint { viewId = BitConverter.ToInt32(data, 0), healthPoint = BitConverter.ToInt32(data, 4) }; return(result); }