public override void UpdateState(TorretaEstatica torreta) { if (torreta.playerDetected == true) { torreta.StopAllCoroutines(); torreta.TransitionToState(torreta.attackState); } }
IEnumerator Wait(TorretaEstatica agent) { Debug.Log("Inicio conteo"); yield return(new WaitForSeconds(agent.timeIdle)); ///Se ejecuta despues de X segundos Debug.Log("Cambio a estado de rotar!"); agent.TransitionToState(agent.rotateState); }
public override void UpdateState(TorretaEstatica torreta) { if (torreta.playerDetected == true) { torreta.TransitionToState(torreta.attackState); } else { torreta.transform.rotation = Quaternion.Slerp(torreta.transform.rotation, Quaternion.Euler(torreta.angles[torreta.angleIndex]), Time.deltaTime * torreta.speedRotation); if (torreta.transform.eulerAngles.y >= (torreta.angles[torreta.angleIndex].y - 1)) { Debug.Log("Llegue al angulo destino"); torreta.angleIndex = (torreta.angleIndex + 1) % torreta.angles.Length; torreta.TransitionToState(torreta.idleState); } } }
public override void UpdateState(TorretaEstatica torreta) { if (torreta.playerDetected == true) { var lookRotation = Quaternion.LookRotation(torreta.playerTarget.transform.position - torreta.transform.position); torreta.transform.rotation = Quaternion.Slerp(torreta.transform.rotation, lookRotation, torreta.speedRotation * Time.deltaTime); //Disparar if (nextFire < Time.time) { torreta.FireBullet(); nextFire = Time.time + rateFire; } } else { torreta.TransitionToState(torreta.idleState); } }
public abstract void UpdateState(TorretaEstatica torreta);
public abstract void EnterState(TorretaEstatica torreta);
public override void EnterState(TorretaEstatica torreta) { Debug.Log("Entro estado atacar!"); torreta.currentState = AgentState.Attack; }
public override void EnterState(TorretaEstatica torreta) { Debug.Log("Inicio Estado de espera!"); torreta.currentState = AgentState.Idle; torreta.Coroutine(Wait(torreta)); }
public override void EnterState(TorretaEstatica torreta) { Debug.Log("Entro a estado de rotación"); torreta.currentState = AgentState.Rotation; }