public void OnDrop(Vector3 sprayDirection) { if (m_Owner != null && m_Owner.CompareTag("Player")) { GameController.Main.CreateWorldspaceText("-" + m_DisplayName, m_Owner.transform.position, Color.red); } VoxelModel model = GetComponentInChildren <VoxelModel>(); if (model != null) { model.CreateDebris(sprayDirection); } Destroy(gameObject); }
public void OnDamaged(GameObject source) { Vector3 sprayDirection = source.transform.forward; bool isDead = false; // No weapons remaining if (m_LeftHandWeapon == null && m_RightHandWeapon == null) { VoxelModel model = GetComponentInChildren <VoxelModel>(); if (model != null) { Vector3 direction = transform.position - source.transform.position; model.CreateDebris(direction); } isDead = true; Destroy(gameObject); } // Only 1 weapon in right hand else if (m_LeftHandWeapon == null) { DropWeapon(m_RightHandWeapon, sprayDirection); } // Only 1 weapon in left hand else if (m_RightHandWeapon == null) { DropWeapon(m_LeftHandWeapon, sprayDirection); } // Both weapons, so pick at random else { int rand = Random.Range(0, 2); if (rand == 0) { DropWeapon(m_RightHandWeapon, sprayDirection); } else { DropWeapon(m_LeftHandWeapon, sprayDirection); } } GameController.Main.OnCharacterDamage(this, isDead); }