- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Bullet : MonoBehaviour
- {
-
- private PlayerLife playerLife;
- private PlayerController playerController;
-
- public float bulletlifeTime = 2;
-
- public int rangedBossSlimeAttack = 15;
- void Start()
- {
- Destroy(gameObject, bulletlifeTime);
- playerLife = FindObjectOfType<PlayerLife>();
- playerController = FindObjectOfType<PlayerController>();
- }
- private void OnCollisionEnter2D(Collision2D collision)
- {
- if (collision.gameObject.tag == "Player")
- {
- playerController.flashActive = true;
- playerController.flashCounter = playerController.flashLength;
- if (playerController.shield == true && rangedBossSlimeAttack > playerController.defensePlayer)
- {
- playerLife.life -= rangedBossSlimeAttack - playerController.defensePlayer;
- }
- else if (playerController.shield == false)
- {
- playerLife.life -= rangedBossSlimeAttack;
- }
- Destroy(gameObject);
- }
- }
- }