/** *@funtion KICK_OFF *@brief Comprueba que el balon este en el centro, inicia el tiempo y fuerza el primer pase *@return Retorna exito cuado los jugadores estan cerca de la posicion inicial. **/ private NodeStates KICK_OFF() { if (CurrEvent != FootEvent.KickOff && CurrEvent != FootEvent.HalfTime)//Esto debido a que es el primer nodo a evaluar { return(NodeStates.SUCCESS); } if (KICK_OFF_Node.nodeState == NodeStates.SUCCESS && (CurrEvent == FootEvent.KickOff || CurrEvent == FootEvent.HalfTime)) { return(NodeStates.SUCCESS); } PlayButton = Input.GetKey(KeyCode.Space); timeb4koff -= Time.deltaTime; Locals[9].ControlStates["Kick_Offer"] = true; if (PlayButton) { //Debug.Log("SE PRECIONO LA TECLA ESPACIO"); scorerTime.GState = ScorerTimeHUD.GameState.Playing; //Debug.Log("Patada inicial"); if (bFirstHalf) { CurrEvent = FootEvent.KickOff; } //Esto elimina el hecho de que el evento actual sea un goal; else { CurrEvent = FootEvent.HalfTime; } //Locks down the events return(NodeStates.SUCCESS); } if (timeb4koff < 0) { scorerTime.GState = ScorerTimeHUD.GameState.Playing; Debug.Log("Patada inicial"); timeb4koff = 5f; //Una vez que se logra se esperan 5 s para el siguiente evento if (bFirstHalf) { CurrEvent = FootEvent.KickOff; } //Esto elimina el hecho de que el evento actual sea un goal; else { CurrEvent = FootEvent.HalfTime; } //Locks down the events return(NodeStates.SUCCESS); } //sphere.owner = null; sphere.gameObject.transform.position = center.position; sphere.gameObject.GetComponent <Rigidbody>().drag = 0.5f; return(NodeStates.RUNNING); }
private NodeStates CORNER_DONE() { if (bFirstHalf) { CurrEvent = FootEvent.KickOff; } //Esto elimina el hecho de que el evento actual sea un goal; else { CurrEvent = FootEvent.HalfTime; } //Locks down the events return(NodeStates.SUCCESS); }
private NodeStates THROW_IN_DONE() { if (bFirstHalf) { CurrEvent = FootEvent.KickOff; } //Esto elimina el hecho de que el evento actual sea un saque; else { CurrEvent = FootEvent.HalfTime; } //Locks down the events return(NodeStates.RUNNING); }
/** *@funtion GOAL_KICK *@brief Saque de puerta *@return **/ private NodeStates GOAL_KICK() { if (CurrEvent == FootEvent.LocalGoal || CurrEvent == FootEvent.VisitGoal) { return(NodeStates.FAILURE); } int wLenght = Locals[0].sbehaviors.Length + Locals[0].cbehaviors.Length; // for (int i = 0; i < 10; i++) { for (int j = 0; j < wLenght; j++) { Locals[i].weights[Locals[i].wkeys[j]] = 0f; Visitors[i].weights[Visitors[i].wkeys[j]] = 0f; } Locals[i].weights["ReturnDefault"] = 1; Visitors[i].weights["ReturnDefault"] = 1; } if (Local.checkDestination((int)Destination.Default) && Visit.checkDestination((int)Destination.Default))//Nota, es necesario hacerlo para ambos ya que cada uno tiene su equipo { Debug.Log("KickOff set"); if (sphere.OutPosition.z < 0) { sphere.transform.position = new Vector3(0, 0, -45); //Configurar portero } else { sphere.transform.position = new Vector3(0, 0, 45); } sphere.OutPosition = new Vector3(38, 100, 55); if (bFirstHalf) { CurrEvent = FootEvent.KickOff; } //Esto elimina el hecho de que el evento actual sea un goal; else { CurrEvent = FootEvent.HalfTime; } //Locks down the events return(NodeStates.RUNNING); } return(NodeStates.RUNNING); }
/** *@funtion CheckThrowInSim *@brief Verifica si es simulacion de Saque de banda, este codigo debe volver a escribirse por la forma en la que está definido action node *@return **/ private NodeStates CheckThrowInSim() { if (PlayerPrefs.GetInt("SimType", (int)SimulationType.Regular) == (int)SimulationType.ThrowIn) { if (CheckThrowInSim_Node.nodeState == NodeStates.PENDING) { sphere.OutPosition = new Vector3(38, 0.2f, 20); sphere.LastTouch = Visitors[0]; CurrEvent = FootEvent.ThrowIn; } return(NodeStates.SUCCESS); } return(NodeStates.FAILURE); }
private NodeStates Cambio_Cancha() { //Este codigo es necesario para que una vez que el nodo tenga exito deje de ejecutarse if (Cambio_Cancha_Node.nodeState == NodeStates.SUCCESS) { return(NodeStates.SUCCESS); } //Esto se ejecuta una unica vez if (Cambio_Cancha_Node.nodeState == NodeStates.PENDING) { Vector3[] temp = Local.local_init_position; Local.local_init_position = Visit.visit_init_position; Visit.visit_init_position = temp; } CurrEvent = FootEvent.HalfTime; return(PREPARE_TO_KICK_OFF()); }
/** *@funtion CheckOclusionSim *@brief Verifica si es simulacion de oclusion, este codigo debe volver a escribirse por la forma en la que está definido action node *@return **/ private NodeStates PlayingNS() { if (TimePlayingCS > 0) { CurrEvent = FootEvent.KickOff; TimePlayingCS -= Time.deltaTime; return(PLAYING()); } if (PlayerPrefs.GetInt("SimType", (int)SimulationType.Regular) == (int)SimulationType.Corner) { CurrEvent = FootEvent.Corner; sphere.OutPosition = new Vector3(15, 0.2f, 56); } if (PlayerPrefs.GetInt("SimType", (int)SimulationType.Regular) == (int)SimulationType.ThrowIn) { CurrEvent = FootEvent.ThrowIn; sphere.OutPosition = new Vector3(-38, 0.2f, 0.5f); } sphere.LastTouch = Visitors[0]; return(NodeStates.SUCCESS); }
/** *@funtion CORNER_Setup *@brief Verifica si es un corner o un throw in, en caso de corner ajusta las posiciones iniciales *@return Retorna exito cuado los jugadores estan cerca de la posicion inicial. **/ private NodeStates CORNER_Setup() { //Check if it is a corner if (Mathf.Abs(sphere.OutPosition.z) < 54.5f) { CurrEvent = FootEvent.ThrowIn; return(NodeStates.FAILURE); } if (bFirstHalf) { if (sphere.OutPosition.z > 0) { if (Mathf.Abs(sphere.OutPosition.x) < 3.1 && Mathf.Abs(sphere.OutPosition.y) < 3.2) { CurrEvent = FootEvent.LocalGoal; return(NodeStates.FAILURE); } if (sphere.LastTouch.TeamName == "Local") { CurrEvent = FootEvent.GoalKick; return(NodeStates.FAILURE); } } else { if (Mathf.Abs(sphere.OutPosition.x) < 3.1 && Mathf.Abs(sphere.OutPosition.y) < 3.2) { CurrEvent = FootEvent.VisitGoal; return(NodeStates.FAILURE); } if (sphere.LastTouch.TeamName == "Visit") { CurrEvent = FootEvent.GoalKick; return(NodeStates.FAILURE); } } } else { if (sphere.OutPosition.z < 0) { if (Mathf.Abs(sphere.OutPosition.x) < 3.1 && Mathf.Abs(sphere.OutPosition.y) < 3.2) { CurrEvent = FootEvent.VisitGoal; return(NodeStates.FAILURE); } if (sphere.LastTouch.TeamName == "Visit") { CurrEvent = FootEvent.GoalKick; return(NodeStates.FAILURE); } } else { if (Mathf.Abs(sphere.OutPosition.x) < 3.1 && Mathf.Abs(sphere.OutPosition.y) < 3.2) { CurrEvent = FootEvent.LocalGoal; return(NodeStates.FAILURE); } if (sphere.LastTouch.TeamName == "Local") { CurrEvent = FootEvent.GoalKick; return(NodeStates.FAILURE); } } } if (CurrEvent == FootEvent.Corner && CORNER_Setup_Node.nodeState == NodeStates.SUCCESS) { return(NodeStates.SUCCESS); } int wLenght = Locals[0].sbehaviors.Length + Locals[0].cbehaviors.Length; // for (int i = 0; i < 10; i++) { for (int j = 0; j < wLenght; j++) { Locals[i].weights[Locals[i].wkeys[j]] = 0f; Visitors[i].weights[Visitors[i].wkeys[j]] = 0f; } Locals[i].weights["CornerSetup"] = 1; Visitors[i].weights["CornerSetup"] = 1; } if (Local.checkDestination((int)Destination.Corner) && Visit.checkDestination((int)Destination.Corner))//Nota, es necesario hacerlo para ambos ya que cada uno tiene su equipo { Debug.Log("Corner set"); if (sphere.OutPosition.z < 0) { if (sphere.OutPosition.x < 0) { sphere.transform.position = new Vector3(-37, 0.1f, -55); } else { sphere.transform.position = new Vector3(37, 0.1f, -55); } } else { if (sphere.OutPosition.x < 0) { sphere.transform.position = new Vector3(-37, 0.1f, 55); } else { sphere.transform.position = new Vector3(37, 0.1f, 55); } } sphere.OutPosition = new Vector3(38, 100, 55); TimeInAction = 4f; TimePlayingCS = 14f; return(NodeStates.SUCCESS); } return(NodeStates.RUNNING); }