/// <summary> /// OnCollisionEnter is called when this collider/rigidbody has begun /// touching another rigidbody/collider. /// </summary> /// <param name="other">The Collision data associated with this collision.</param> void OnCollisionEnter(Collision other) { if (other.gameObject.tag == "ball") { Destroy(other.gameObject); // destroy balloon PopScript.pos = other.contacts[0].point; PopScript.Pop(); animator.SetBool("hit", true); //Renderer objRenderer = gameObject.GetComponent<Renderer>(); //objRenderer.materials[0].color.a = 0f; // Color fadeColor = objRenderer.materials[0].color; // while(fadeColor.a > 0f){ // fadeColor.a -= Time.deltaTime/FadeTime; // objRenderer.materials[0].color = fadeColor; // } Vector3 itemPos = gameObject.transform.position; Destroy(gameObject, 3.0f); //yield WaitForSeconds(3.0f); if (gameObject.tag == "enemyDao") { Instantiate(portion, itemPos, Quaternion.identity); } else if (gameObject.tag == "enemyBazzi") { Instantiate(sizeup, itemPos, Quaternion.identity); } spawnedBall = Instantiate(m_BallPrefab); } }
public override void MyBehaviour(PopScript other) { base.MyBehaviour(other); //HAWKS WASTE EACH OTHER FOOS if (other is Hawk) { //other.Die(); //Die(); EnergyRemaining = 0; other.EnergyRemaining = 0; } //...BUT THEY STEAL ALL THE FOOD FROM DOVES... else if (other is Dove) { EnergyRemaining += other.EnergyRemaining; other.EnergyRemaining = 0; //SpawnHeart(); } //...AND THEY HAVE A GOOD CHANCE TO KILL A GUARDIAN. else if (other is Guardian) { int randomChance = Random.Range(0, 100); if (randomChance < 75) { other.Die(); } } }
public virtual void MyRoutine(Ray myRay) { if (Physics.Raycast(myRay, out hit)) { if (hit.distance < rayDistance) { GameObject target = hit.collider.gameObject; if (target.tag == "Pop" && !hadEncounter && !target.GetComponent <PopScript>().isDying) { PopScript other = hit.collider.gameObject.GetComponent <PopScript>(); MyBehaviour(other); } } } }
public override void MyBehaviour(PopScript other) { base.MyBehaviour(other); //DOVES GIFT FOOD TO EVERYONE BUT SACRIFICES THEMSELVES TO GUARDIANS if (other is Guardian) { print("I gave food to a Guardian."); other.EnergyRemaining += EnergyRemaining; EnergyRemaining = 0; } else { other.EnergyRemaining += EnergyRemaining / 2; EnergyRemaining /= 2; } //SpawnHeart(); }
public override void MyBehaviour(PopScript other) { base.MyBehaviour(other); //GUARDIANS PROTECT DOVES FROM HARM FOR A LITTLE TIME... if (other is Dove) { other.hadEncounter = true; } //...THEY 'STEAL' FOOD ONLY FROM HAWKS... else if (other is Hawk) { EnergyRemaining += other.EnergyRemaining; other.EnergyRemaining = 0; //SpawnHeart(); } //..AND IGNORE EACH OTHERS else if (other is Guardian) { hadEncounter = false; } }
public virtual void MyBehaviour(PopScript other) { hadEncounter = true; }