// Para casos en que el weakpoint active algo al ser dañado en vez de destruido public override void RespondToDamagedWeakPoint(string tag = "") { if (currentState == WormStatus.Stunned) { currentState = WormStatus.Recovering; // Luego emtemos un par mas de cosas gigaWormInsides.ChangeShowersEmission(); } }
// public override void ImpactWithTerrain(bool hardEnough) { // Debug.Log("Maws impacting with terrain: " + mawStatus + ", " + hardEnough); // if (mawStatus != MawStatus.Closed && hardEnough) { // gigaWormInsides.transform.position = new Vector3( transform.position.x, gigaWormInsides.transform.position.y, transform.position.z); // currentState = WormStatus.Stunned; GeneralFunctions.PlaySoundEffect(audioSource, stunnedClip); gigaWormInsides.ChangeShowersEmission(); // if (!firstStun) { firstStun = true; carolHelp.TriggerIt(9, "First stun"); } } }
// Llamada desde los weakpoints cuando son destruidos public override void LoseWeakPoint(string tag = "") { switch (currentState) { // Para la etapa inicial case WormStatus.Wandering: goesUnderground = true; currentTimeUnderground = 0; // Del targeteable, hacer variable más clara active = false; // exteriorWeakPoints--; if (interiorWeakPoints == 0) { // Luego veremos si hacemos aqui el cambio al siguiente paso //currentState GeneralFunctions.PlaySoundEffect(audioSource, exteriorWeakPointDestroyedClip); } else { GeneralFunctions.PlaySoundEffect(audioSource, allExteriorWeakPointDestroyedClip); } // Activamos los enemigos del grupo 1 (el 0 es el porpio boss) enemyManager.ActivateEnemies(1, transform.position + (Vector3.up * 100)); break; // Para la final case WormStatus.Stunned: case WormStatus.Recovering: // currentState = WormStatus.Dead; GeneralFunctions.PlaySoundEffect(audioSource, deathClip); // TODO: Hacer la muerte y victoria levelManager.ConfirmVictory(); break; } }
// Update is called once per frame protected override void Update() { // if (player == null) { return; } // base.Update(); // float dt = Time.deltaTime; // Vector3 playerDirection = player.transform.position - transform.position; // UpdateBehaviour(playerDirection, dt); // Lo reseteamos a cada step mawsCollidingPlayer = 0; // //if((currentState == WormStatus.Stunned && !playerOut) || // (currentState == WormStatus.Recovering && !playerOut)) //{ // InsidesDamageToPlayer(dt); //} // Aquí se recupera if (currentState == WormStatus.Stunned) { currentStunDuration += dt; if (currentStunDuration >= maxStunDuration) { currentState = WormStatus.Recovering; currentStunDuration = 0; gigaWormInsides.ChangeShowersEmission(); } } }
protected void UpdateBehaviour(Vector3 playerDirection, float dt) { // switch (currentState) { // Cuando está vagando por ahí case WormStatus.Wandering: float playerDistance = (transform.position - player.transform.position).magnitude; // Que rote alrededor del player si se aleja demasiado // Así no se va a cuenca if (playerDistance > 700) { // Sacar la cruz Vector3 playerCross = Vector3.Cross(playerDirection, Vector3.up); //transform.rotation = Quaternion.LookRotation(playerCross); head.rotation = GeneralFunctions.UpdateRotationInOneAxis(head, playerCross, rotationSpeed, dt); } else { head.Rotate(Vector3.up * dt); } // Velocity no sirve con kinematicos //rb.velocity = transform.forward * 100; // head.Translate(Vector3.forward * currentSpeed * dt); //Debug.Log("I'm wandering"); // if (goesUnderground) { // if (head.position.y > underGroundHeight) { head.Translate(Vector3.up * heightChangeSpeed * dt * -1); } // currentTimeUnderground += dt; if (currentTimeUnderground >= timeUnderground) { goesUnderground = false; } } else if (!goesUnderground && head.position.y < overGroundHeight) { head.Translate(Vector3.up * heightChangeSpeed * dt); } else if (exteriorWeakPoints == 0) { // Aquí pasa a la fase de perseguir currentState = WormStatus.Chasing; currentSpeed = chasingMovementSpeed; active = true; rotationSpeed *= 3; //Debug.Log("Start chasing"); // Por aqui em principio solo pasa una vez carolHelp.TriggerIt(5, "Start chasing"); } else { // Del targeteable, hacer variable más clara active = true; } break; case WormStatus.Chasing: // Que persiga al player head.rotation = GeneralFunctions.UpdateRotationInOneAxis(transform, player.transform.position, rotationSpeed, dt); head.Translate(Vector3.forward * currentSpeed * dt); // Que abra la boca cuando lo tenga cerca UpdateMaw(playerDirection, dt); // Que intente atraparlo de un mordisco (muerte mortísima) // (En el script de collision del terreno de momento de momento) // Que pase a estado stun break; case WormStatus.Stunned: // Vamos a hacer que vaya perdiendo velcodidad en un tiempo if (currentSpeed > 0) { // currentSpeed -= (chasingMovementSpeed / timeUntilCompleteStun) * dt; currentSpeed = Mathf.Max(currentSpeed, 0); // head.Rotate(Vector3.forward * completeStunRotation / timeUntilCompleteStun * dt); // head.Translate(Vector3.forward * currentSpeed * dt); } break; case WormStatus.Recovering: // Basicamente invertiremos el stun if (currentSpeed < chasingMovementSpeed) { // Le metemos un multiplicador al float recoveryMultiplier = 0.5f; // currentSpeed += (chasingMovementSpeed / timeUntilCompleteStun) * dt * recoveryMultiplier; currentSpeed = Mathf.Min(currentSpeed, chasingMovementSpeed); // head.Rotate(-Vector3.forward * completeStunRotation / timeUntilCompleteStun * dt * recoveryMultiplier); } // head.Translate(Vector3.forward * currentSpeed * dt); // if (currentSpeed == chasingMovementSpeed && gigaWormInsides.PlayerOut) { currentState = WormStatus.Chasing; // //Vector3 currentHeadEulers = head.localEulerAngles; //currentHeadEulers.z = 0; //head.localEulerAngles = currentHeadEulers; } break; } }