void findStaticFood() { /* * if (stats.nest != null) { * if(stats.nest.GetComponent<Nest>().foodInventory > 0){ * changeFoodTarget(stats.nest); * } * }*/ //Si la créature est au joueur, elle doit se nourrir dans ses réserves if (att.numPlayer == 1) { //Fonction qui cherchent dans les réserves de stockpiles foreach (TypeResource res in foodTypes) { GameObject foodtemp = p.getFoodinStock(res); if (foodtemp != null) { changeEatTarget(foodtemp); return; } } } else { } if (Foodtarget == null) { Tile t; //Debug.Log ("pos x creature = " + Mathf.FloorToInt (transform.position.x)); //Debug.Log ("pos y creature = " + Mathf.FloorToInt (transform.position.z)); //Taille du carré de vision en haut a droite int posxMax = Mathf.FloorToInt(transform.position.x) + att.rayVision; int posyMax = Mathf.FloorToInt(transform.position.z) + att.rayVision; for (int x = Mathf.FloorToInt(transform.position.x) - att.rayVision; x <= posxMax; x++) //Variable début de boucle, on commence par la Tile la plus en bas a gauche { if (Foodtarget != null) { break; } for (int y = Mathf.FloorToInt(transform.position.z) - att.rayVision; y <= posyMax; y++) { if ((x < 0 || y < 0) || (x >= map.size_x || y >= map.size_z)) { //Si on est en dehors de la map on ne cherche pas. } else { t = att.getTileAt(x, y); if (t.staticEntity != null) { //foreach(string str in typeOfFood){ // on parcourt les repas possible : Plantes ou autres. // Nouvel algo avec comme tag resource pour les static food. (toujours le meme pour le moment) if (t.staticEntity.tag == "Resource") { //On parcours les type de nourriture consommable par la créature foreach (TypeResource type in foodTypes) { if (t.staticEntity.GetComponent <ResourceManager>().getTypeResource() == type) { //pour la meat on la mange direct if (type == TypeResource.MEAT) { Debug.Log("trouver nourriture"); changeEatTarget(t.staticEntity); return; } else { Debug.Log("trouver nourriture"); changeCollectTarget(t.staticEntity); return; } } } /* * if(str == "Tree"){ * if(t.staticEntity.GetComponent<Tree>().nbFruit > 0){ * changeCollectTarget(t.staticEntity); * Debug.Log("trouver Collect"); * return; * } * * * } * else{ * changeFoodTarget(t.staticEntity); * Debug.Log("trouver"); * return; * }*/ } //} } } } } if (Foodtarget == null && vegetarian) { mvt.ForceRandomMove(); } } }