/// <summary> /// Spawns a blood drop. /// </summary> /// <returns>The blood drop.</returns> private SpaceBloodDrop SpawnBloodDrop() { GameObject bloodDropObj = GameObject.Instantiate(m_bloodDrop.gameObject) as GameObject; bloodDropObj.SetActive(true); SpaceBloodDrop bloodDrop = bloodDropObj.AddComponentNoDupe <SpaceBloodDrop>(); m_bloodDrops.Add(bloodDrop); return(bloodDrop); }
/// <summary> /// Creates a blood explosion. /// </summary> private void CreateBloodExplosion() { while (m_bloodDrops.Count < m_bloodDropCount) { // Randomize move direction Vector3 moveDir = new Vector3(0.0f, Random.Range(m_splatterRangeY.x, m_splatterRangeY.y), 0.0f); // Spawn half of the blood drops on the left side of the character if (m_bloodDrops.Count < m_bloodDropCount * 0.5f) { moveDir.x = -1.0f; } // Spawn the other blood drops on the right side else { moveDir.x = 1.0f; } moveDir = moveDir.normalized; // Spawn and initialize blood drop SpaceBloodDrop bloodDrop = SpawnBloodDrop(); bloodDrop.Initialize(moveDir); // Position blood drop a certain distance from the center along the move direction bloodDrop.transform.position = m_splatterPos.position + moveDir * m_bloodDropSpawnDistFromCenter; } }