void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == tagPrey) { //agent.SetDestination(new Vector3(0,0,0)); // Destroy(collision.gameObject); MoveVipere controlCollisionPrey = collision.gameObject.GetComponent <MoveVipere>(); if (controlCollisionPrey.touched == false) { controlCollisionPrey.touched = true; // access this particular touched variable collision.gameObject.transform.position = homePoule; } else { // print(gameObject.name + " : Get out of my way !!") ; } } else if (collision.gameObject.tag == tagFriend) { MovePoule controlCollisiontFriend = collision.gameObject.GetComponent <MovePoule>(); if (controlCollisiontFriend.touched == true && touched == false) { controlCollisiontFriend.touched = false; } else { // print("Pardon copain"); } } }
bool amiArreteEnVue(out Vector3 cible) { if (friendListMinusMe.Count != 0) { // test seulement dans le cas ou le renard est seule (test unitaire) List <GameObject> friendArrestedVisibleList = new List <GameObject>(); cible = Vector3.zero; unCamaradeALiberer = false; foreach (GameObject camarade in friendListMinusMe) { MovePoule controlFriendArrested = camarade.GetComponent <MovePoule>(); bool friendArrested = controlFriendArrested.touched; // access this particular touched variable // on teste si la prey est a distance de vue .................................. et dans le champ de vision ........................................................................... et s'il n'y a pas une proie plus proche if (((camarade.transform.position - agent.transform.position).magnitude < sightRange) && (Vector3.Angle(camarade.transform.position - agent.transform.position, agent.transform.forward) < sightAngle) && (friendArrested == true)) { unCamaradeALiberer = true; friendArrestedVisibleList.Add(camarade); } } Transform tempResult = getClosest(friendArrestedVisibleList); cible = tempResult.position; return(unCamaradeALiberer); } else { cible = new Vector3(0.0f, 0.0f, 0.0f); unCamaradeALiberer = false; return(unCamaradeALiberer); } }
bool CibleEnVue(out Vector3 result) { if (preyList.Length != 0) // test seulement dans le cas ou le renard est seule (test unitaire) { List <GameObject> preyVisibleList = new List <GameObject>(); result = Vector3.zero; enChasse = false; for (int i = 0; i < preyList.Length; i++) { GameObject prey = preyList[i]; MovePoule controlTouchedPrey = prey.GetComponent <MovePoule>(); preyTouched = controlTouchedPrey.touched; // access this particular touched variable // on teste si la prey est a distance de vue .................................. et dans le champ de vision ........................................................................... et s'il n'y a pas une proie plus proche if (((prey.transform.position - agent.transform.position).magnitude < sightRange) && (Vector3.Angle(prey.transform.position - agent.transform.position, agent.transform.forward) < sightAngle) && (preyTouched == false)) { enChasse = true; preyVisibleList.Add(prey); } } Transform tempResult = getClosest(preyVisibleList); result = tempResult.position; return(enChasse); } else { result = new Vector3(0.0f, 0.0f, 0.0f); enChasse = false; return(enChasse); } }
bool endOfGame() { for (int j = 0; j < preyList.Length; j++) { prey = preyList[j]; MovePoule controlTouchedPrey = prey.GetComponent <MovePoule>(); preyTouched = controlTouchedPrey.touched; if (preyTouched) { for (int k = 0; k < predatorList.Length; k++) { predator = predatorList[k]; MoveVipere controlTouchedPredator = predator.GetComponent <MoveVipere>(); predatorTouched = controlTouchedPredator.touched; if (predatorTouched == false) { return(false); } } } else { return(false); } } return(true); }
bool endOfGame() { for (int j = 0; j < preyList.Length; j++) { prey = preyList[j]; MovePoule controlTouchedPrey = prey.GetComponent <MovePoule>(); preyTouched = controlTouchedPrey.touched; if (preyTouched == false) { return(false); } } return(true); }
bool getPlusProcheAmiArrete(out Vector3 result) { List <GameObject> friendArreteList = new List <GameObject>(); amiArrete = false; foreach (GameObject friend in friendListMinusMe) { MovePoule controlTouchedFriend = friend.GetComponent <MovePoule>(); bool friendTouched = controlTouchedFriend.touched; // access this particular touched variable // on teste si la prey est a distance de vue .................................. et dans le champ de vision ........................................................................... et s'il n'y a pas une proie plus proche if (friendTouched == true) { friendArreteList.Add(friend); amiArrete = true; } } Transform tempResult = getClosest(friendArreteList); result = tempResult.position; return(amiArrete); }
bool prisPourCible(out Vector3 result) { for (int i = 0; i < predatorList.Length; i++) { GameObject predator = predatorList[i]; MovePoule controlPredatorTouched = predator.GetComponent<MovePoule>(); predatorTouched = controlPredatorTouched.touched; // access this particular touched variable if ( ((predator.transform.position - agent.transform.position).magnitude < sightRange) && (predatorTouched == false) ) { Vector3 cibleDir = predator.transform.position - agent.transform.position; if (Vector3.Angle(cibleDir, agent.transform.forward) < sightAngle) { result = predator.transform.position; prisEnChasse = true; return true; } } } result = Vector3.zero; return false; }
bool AmiArreteEnVue(out Vector3 result) { List <GameObject> friendArreteList = new List <GameObject>(); jeNeSuisPasSeul = false; for (int j = 0; j < friendListMinusMe.Length; j++) { GameObject friend = friendListMinusMe[j]; Debug.Log(friend.name); MovePoule controlTouchedFriend = friend.GetComponent <MovePoule>(); friendTouched = controlTouchedFriend.touched; // access this particular touched variable // on teste si la prey est a distance de vue .................................. et dans le champ de vision ........................................................................... et s'il n'y a pas une proie plus proche if (friendTouched == true) { friendArreteList.Add(friend); jeNeSuisPasSeul = true; } } Transform tempResult = getClosest(friendArreteList); result = tempResult.position; return(jeNeSuisPasSeul); }