void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.tag == "Player") { keylam.enabled = true; DataTravel fexs = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <DataTravel>(); if (fexs.efectos == 1) { mus.Play(); } DoorExit exit = GameObject.FindGameObjectWithTag("door").GetComponent <DoorExit>(); exit.key = true; Destroy(gameObject, 1f); } else if (other.gameObject.tag == "Enemigo" || other.gameObject.tag == "BalaEnm") { GameObject.FindGameObjectWithTag("Spawn").SendMessage("avalible"); GameObject.FindGameObjectWithTag("Spawn").SendMessage("avalible"); GameObject.FindGameObjectWithTag("Spawn").SendMessage("keyRespa"); Destroy(gameObject); } else if (other.gameObject.tag == "Bala") { GameObject.FindGameObjectWithTag("Spawn").SendMessage("avalible"); GameObject.FindGameObjectWithTag("Spawn").SendMessage("avalible"); GameObject.FindGameObjectWithTag("Spawn").SendMessage("avalible"); GameObject.FindGameObjectWithTag("Spawn").SendMessage("keyRespa"); Destroy(gameObject); } }
void OnCollisionEnter2D(Collision2D other) { Physics2D.IgnoreLayerCollision(8, 14); if (other.gameObject.tag == "BalaEnm") { if (shield) { shield = false; } else { vida -= balaDiscont; if (vida <= 0) { PlayerControler lo = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerControler>(); lo.vivo = false; dispMax = -5; if (vi) { vi = false; GameObject.FindGameObjectWithTag("Spawn").SendMessage("Spw"); GameObject.FindGameObjectWithTag("Spawn").SendMessage("Corazones"); yo.isKinematic = true; Respawn ved = GameObject.FindGameObjectWithTag("Spawn").GetComponent <Respawn>(); vidass = ved.vidas; punta = ved.puntaje; if (vidass <= 0f) { if (punta >= menPuntua) { canvas.cullingMode = AnimatorCullingMode.AlwaysAnimate; canvas.Play("CanNomb"); } else { GameObject.FindGameObjectWithTag("Spawn").SendMessage("perdi"); } } } } } } else if (other.gameObject.tag == "Key") { DoorExit llave = GameObject.FindGameObjectWithTag("door").GetComponent <DoorExit>(); llave.key = true; } else if (other.gameObject.tag == "Shield") { shield = true; } else if (other.gameObject.tag == "BalaDis") { balDis += 0.5f; } else if (other.gameObject.tag == "BalaPlus") { dispMax += 1; } else if (other.gameObject.tag == "Healtim") { Respawn ru = GameObject.FindGameObjectWithTag("Spawn").GetComponent <Respawn>(); ru.vidas += 1; GameObject.FindGameObjectWithTag("Spawn").SendMessage("Corazones"); } else if (other.gameObject.tag == "Velocity") { PlayerControler vels = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerControler>(); vels.MovementSpeed += 0.03f; if (vels.MovementSpeed >= 0.11f) { vels.MovementSpeed = 0.11f; } } else if (other.gameObject.tag == "ExploEnm") { vida -= explo; Instantiate(vibrand, new Vector3(0, 0, 0), Quaternion.identity); Vibrate dure = GameObject.FindGameObjectWithTag("Vibra").GetComponent <Vibrate>(); dure.vibDurac = 0.15f; if (vida <= 0) { PlayerControler lo = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerControler>(); lo.vivo = false; dispMax = -5; if (vi) { vi = false; GameObject.FindGameObjectWithTag("Spawn").SendMessage("Spw"); GameObject.FindGameObjectWithTag("Spawn").SendMessage("Corazones"); yo.isKinematic = true; Respawn ved = GameObject.FindGameObjectWithTag("Spawn").GetComponent <Respawn>(); vidass = ved.vidas; punta = ved.puntaje; if (vidass <= 0f) { if (punta >= menPuntua) { canvas.cullingMode = AnimatorCullingMode.AlwaysAnimate; canvas.Play("CanNomb"); } else { GameObject.FindGameObjectWithTag("Spawn").SendMessage("perdi"); } } } } } }
private void ExecuteAscendMove() { Enemy enemy = null; Vector3 target; if (IsOnLadder(Vector2.up, RaycastPoint.position, 1f)) { enemy = GetSquareEnemy(Vector2.up, RaycastPoint.position, 1f); if (enemy != null) { AttackEnemy(Vector2.up, enemy); } else { transform.DOMoveY(transform.position.y + 1f, MoveDelay).OnComplete(() => StartCoroutine(EnableMovement())); } AudioSource.PlayOneShot(AscendLadderAudioClip); return; } DoorExit door = GetSquareDoor(); if (door != null) { door.LoadScene(); return; } enemy = GetSquareEnemy(LastMoveDirection, RaycastPoint.position, 1f); if (enemy != null) { // We are adjacent to an enemy, so treat the jump as a regular move action. ExecuteRegularMove(new Vector2(LastMoveDirection.x, 0f)); return; } enemy = GetSquareEnemy(LastMoveDirection, RaycastPoint.position, 2f); if (enemy != null) { // An enemy is at our target jump location, so we will attack the enemy and land one space ahead. AttackEnemy(LastMoveDirection, enemy); target = new Vector3(transform.position.x + LastMoveDirection.x, transform.position.y, 0f); PerformMove(target, 1f); return; } bool isFarSquareOpen = IsSquareOpen(LastMoveDirection, RaycastPoint.position, 2f); bool isNearSquareOpen = IsSquareOpen(LastMoveDirection, RaycastPoint.position, 1f); Vector2 raycastTarget; float moveTargetPositionX; if (isFarSquareOpen) { raycastTarget = new Vector2(RaycastPoint.position.x + (LastMoveDirection.x * 2), RaycastPoint.position.y); moveTargetPositionX = transform.position.x + (LastMoveDirection.x * 2); } else { raycastTarget = new Vector2(RaycastPoint.position.x + LastMoveDirection.x, RaycastPoint.position.y); moveTargetPositionX = transform.position.x + LastMoveDirection.x; } // The jump target is open, so do a two space move. target = new Vector3(moveTargetPositionX, transform.position.y, 0f); PerformMove(target, 1f); }