<commit_before>﻿using UnityEngine;
using System.Collections;

//[RequireComponent(typeof(AudioSource))]
public class ApplyDamage : MonoBehaviour {
	public int HealthPoints;
	public int ArmorPoints;
	public GameObject Explosion;
//	public AudioClip HitConfirmedSound;

	private int BaseMissileDamage;
	private int BaseBulletDamage;
	private string[] Tags;

	// Use this for initialization
	void Start () {
		//Default variables
		if (HealthPoints == 0)
			HealthPoints = 100;

		if (ArmorPoints == 0)
			ArmorPoints = 0;

		BaseMissileDamage = 25;
		BaseBulletDamage = 10;
	}
	
	// Update is called once per frame
	void Update () {
		if (HealthPoints <= 0)
			Die();
	}

	void OnCollisionEnter(Collision collision) {
		foreach (ContactPoint contactpoint in collision.contacts){
			Tags = contactpoint.otherCollider.tag.Split(',');
			// Do not apply damage if colliding with an child object. Like a missile the player or enemy fired it self.
			if (this.tag != Tags[1]) {
				// Damage types
				// TODO Armor code
				switch (Tags[0]) {
				case "Missile":
					//Debug.Log("Missile hit!");
					HealthPoints -= BaseMissileDamage;
	//				if (contactpoint.thisCollider.tag == "Enemy" && contactpoint.thisCollider.tag != "Player")
	//					audio.PlayOneShot(HitConfirmedSound, 0.7F);
					break;
				case "Bullet":
					//Debug.Log("Bullet hit!");
					HealthPoints -= BaseBulletDamage;
					break;
				default:
					break;
				}
			}
		}
	}
	<commit_msg>Fixed crash when enemy/player collided with objects other than missiles.<commit_after>﻿using UnityEngine;
using System.Collections;

//[RequireComponent(typeof(AudioSource))]
public class ApplyDamage : MonoBehaviour {
	public int HealthPoints;
	public int ArmorPoints;
	public GameObject Explosion;
//	public AudioClip HitConfirmedSound;

	private int BaseMissileDamage;
	private int BaseBulletDamage;
	private string[] Tags;

	// Use this for initialization
	void Start () {
		//Default variables
		if (HealthPoints == 0)
			HealthPoints = 100;

		if (ArmorPoints == 0)
			ArmorPoints = 0;

		BaseMissileDamage = 25;
		BaseBulletDamage = 10;
	}
	
	// Update is called once per frame
	void Update () {
		if (HealthPoints <= 0)
			Die();
	}

	void OnCollisionEnter(Collision collision) {
		foreach (ContactPoint contactpoint in collision.contacts){
			if (contactpoint.otherCollider.tag.Contains(",")) {
				Tags = contactpoint.otherCollider.tag.Split(',');
				// Do not apply damage if colliding with an child object. Like a missile the player or enemy fired it self.
				if (this.tag != Tags[1]) {
					// Damage types
					// TODO Armor code
					switch (Tags[0]) {
					case "Missile":
						//Debug.Log("Missile hit!");
						HealthPoints -= BaseMissileDamage;
						//                if (contactpoint.thisCollider.tag == "Enemy" && contactpoint.thisCollider.tag != "Player")
						//                    audio.PlayOneShot(HitConfirmedSound, 0.7F);
						break;
					case "Bullet":
						//Debug.Log("Bullet hit!");
						HealthPoints -= BaseBulletDamage;
						break;
					default:
						break;
					}
				}
				else{
					// Other apply damage code here. e.g environmental
				}
			}
		}
	}
	
{'fraction_non_alphanumeric': 0.11238095238095239, 'fraction_numerical': 0.009523809523809525, 'mean_word_length': 3.0242656449553, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '216557', 'n_tokens_mistral': 1205, 'n_tokens_neox': 968, 'n_words': 273}