Exemple #1
0
//	public void idle_mode(){
//
//		Vector2 myVel = myBody.velocity;
//		myVel.x = Random.Range (-30.0f, 30.0f);
//		myVel.y = Random.Range (-10.0f, 18.0f);
//		myBody.velocity = myVel*0.1f;
//	}
//
//	[ServerCallback]
//	void OnTriggerEnter2D(Collider2D other) {
//		if (other.gameObject.CompareTag ("Submarine")) {
//			Debug.Log ("Submarine detected");
//			myBody.transform.position = Vector2.MoveTowards (myBody.transform.position, other.gameObject.transform.position, attack_speed);
//
//		} else if (other.gameObject.CompareTag ("Missile")) {
//			Debug.Log ("Dodging Missile");
//			myBody.transform.position = Vector2.MoveTowards (myBody.transform.position, -other.gameObject.transform.position, evade_speed);
//		}
//	}

//	void OnDestroy(){
//		Radar.RemoveRadarObject (this.gameObject);
//	}
//
    void OnCollisionEnter2D(Collision2D col)
    {
        GameObject      hit    = col.gameObject;
        SubmarineHealth health = hit.GetComponent <SubmarineHealth>();

        health.DecreaseHealth();
//		if(health != null && health.currentHealth > 0f)
//		{
//			health.DecreaseHealth ();
//			//health.currentHealth -= 10f;
//
//            // Blobs should not die upon contact with player, can only be killed by missles...
//			//EnemyBlobHealth enemyHealth = gameObject.GetComponent<EnemyBlobHealth> ();
//			//enemyHealth.DecreaseHealth (hit.tag);
//
//
//		}
//		else if(health != null && health.currentHealth <= 0f)
//		{
//			Debug.Log("Changing to End Panel");
//
//			Scene current = this.gameObject.scene;
//			Debug.Log(current);
//			GameObject[] scenes = current.GetRootGameObjects();
//			foreach(GameObject root in scenes)
//			{
//				Debug.Log(root);
//				if(root.GetComponent<RectTransform>() != null)
//				{
//
//					Debug.Log("found End");
//					GameObject endScene = GameObject.FindGameObjectWithTag("End");
//					for(int i = 0; i < endScene.transform.childCount; i++)
//					{
//						endScene.transform.GetChild(i).gameObject.SetActive(true);
//					}
//					//Debug.Log(endScene);
//					Debug.Log("Finish enabling");
//				}
//				else if(root.GetComponent<NetworkManager>() != null)
//				{
//					root.GetComponent<NetworkManager>().StopHost();
//
//				}
//				//NetworkServer.Reset();
//			}
//			//NetworkServer.Stop
//			//NetworkServer.Shutdown();
//			//NetworkServer.DisconnectAll();
//			NetworkServer.Reset();
//			//NetworkHost host = gameObject.GetComponent<NetworkHost>();
//			//NetworkManager man = host.GetComponent<Network
//			//man.StopHost();
//			//CmdExit();
//
//		}
    }
    void OnCollisionEnter2D(Collision2D col)
    {
        GameObject      hit    = col.gameObject;
        SubmarineHealth health = hit.GetComponent <SubmarineHealth>();

        if (health != null)
        {
            health.DecreaseHealth();
        }
    }
Exemple #3
0
    void OnTriggerEnter2D(Collider2D col)
    {
        GameObject hit = col.gameObject;

        if (hit.GetComponent <SubmarineHealth>() != null)
        {
            SubmarineHealth health = hit.GetComponent <SubmarineHealth>();
            if (health.currentHealth < 100f)
            {
                health.currentHealth = 100f;
            }
            Destroy(this.gameObject);
        }
    }
Exemple #4
0
//	public void idle_mode(){
//
//		Vector2 myVel = myBody.velocity;
//		myVel.x = Random.Range (-30.0f, 30.0f);
//		myVel.y = Random.Range (-10.0f, 18.0f);
//		myBody.velocity = myVel*0.1f;
//	}
//

//	void OnTriggerEnter2D(Collider2D other) {
//		if (other.gameObject.CompareTag ("Missile")) {
//			Debug.Log ("Dodging Missile");
//			gameObject.transform.position = Vector2.MoveTowards (myBody.transform.position, -other.gameObject.transform.position, evade_speed);
//
//		} else if (other.gameObject.CompareTag ("Submarine")) {
//			gameObject.transform.position = Vector2.MoveTowards (myBody.transform.position, other.gameObject.transform.position, attack_speed);
//
//		}
//	}


    void OnCollisionEnter2D(Collision2D col)
    {
        GameObject hit = col.gameObject;

        if (hit.name.Equals("Submarine Player Nic 1(Clone)"))
        {
            SubmarineHealth health = hit.GetComponent <SubmarineHealth>();
            if (health != null)
            {
                health.DecreaseHealth();
            }


//			if (health != null && health.currentHealth != 10.0f) {
//				health.DecreaseHealth ();
//				//health.currentHealth -= 10f;
//
//				// Blobs should not die upon contact with player, can only be killed by missles...
//				//EnemyBlobHealth enemyHealth = gameObject.GetComponent<EnemyBlobHealth> ();
//				//enemyHealth.DecreaseHealth (hit.tag);
//
//
//			} else if (health != null && health.currentHealth == 10.0f) {
//
//				Debug.Log ("Changing to End Panel");
//
//				Scene current = this.gameObject.scene;
//				Debug.Log (current);
//				GameObject[] scenes = current.GetRootGameObjects ();
//				foreach (GameObject root in scenes) {
//					Debug.Log (root);
//					if (root.GetComponent<RectTransform> () != null) {
//
//						Debug.Log ("found End");
//						GameObject endScene = GameObject.FindGameObjectWithTag ("End");
//						for (int i = 0; i < endScene.transform.childCount; i++) {
//							if (i == 4) {
//								if (endScene.transform.GetChild (i).gameObject.transform.position.y != -270) {
//
//									endScene.transform.GetChild (i).gameObject.transform.Translate (0, -320, 0);
//								}
//							}
//
//							endScene.transform.GetChild (i).gameObject.SetActive (true);
//						}
//						//Debug.Log(endScene);
//						Debug.Log ("Finish enabling");
//					} else if (root.GetComponent<NetworkManager> () != null) {
//						root.GetComponent<NetworkManager> ().StopHost ();
//
//					}
//					//NetworkServer.Reset();
//				}
//				//NetworkServer.Stop
//				//NetworkServer.Shutdown();
//				//NetworkServer.DisconnectAll();
//				NetworkServer.Reset ();
//				//NetworkHost host = gameObject.GetComponent<NetworkHost>();
//				//NetworkManager man = host.GetComponent<Network
//				//man.StopHost();
//				//CmdExit();
//
//			} else {
//				Debug.Log ("THIS COULD MEAN BLOB HITTING INTO EACH OTHER");
//			}
        }
    }