예제 #1
0
	public void TakeDamage2 (Transform enemy, Color damageColor, float damageFactor)
	{
			// ... and if the player still has health...
			if (!script.IsBlack()) {
				// Make sure the player can't jump.
				//playerControl.jump = false;
		
				// Create a vector that's from the enemy to the player with an upwards boost.
//				Vector3 hurtVector = transform.position - enemy.position + Vector3.up * 5f;
		
				// Add a force to the player in the direction of the vector and multiply by the hurtForce.
//				rigidbody2D.AddForce (hurtVector * hurtForce);
		
				// Reduce the player's health by 10.
				script.applyDamage (damageColor, damageFactor);
				//Debug.Log("Before: \nR:" + health[0] + "\nG:" + health[1] + "\nB:" + health[2]);
				UpdateHealthAmounts();
				//Debug.Log("After: \nR:" + health[0] + "\nG:" + health[1] + "\nB:" + health[2]);
			// Update what the health bar looks like.
				UpdateHealthBar ();

				lastHitTime = Time.time; 
				
		
				Camera.main.GetComponent<CameraShakeScript>().shake = .05f;
				// Play a random clip of the player getting hurt.
				if (Time.time > clipEnd){
						int i = Random.Range (0, ouchClips.Length);
					AudioSource.PlayClipAtPoint(ouchClips[i], transform.position);
					clipEnd = Time.time + ouchClips[i].length;
				}
			}
	}
 void FixedUpdate()
 {
     script.applyDamage(colorLoop[currentState], multiplier);
     if (++step >= maxStep)
     {
         currentState = (currentState + 1) % colorLoop.Length;
         step         = 0;
     }
 }