Beispiel #1
0
    //start off in a random direction
    //if you collide with the Room layer you bounce off
    //if you collide with the player you deal damage and bounce off

    void Start()
    {
        fly  = GameObject.FindGameObjectWithTag("FireFly").GetComponent <FireFlyResources>();
        pr   = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerResources>();
        anim = GetComponent <Animator>();
        rb   = GetComponent <Rigidbody2D>();
        br   = GetComponentInParent <BossResources>();
        startTimeBtwDamage = fly.rateOfFire;
        terra       = GetComponentInParent <SpawnOfTerra>();
        ps          = GetComponentsInChildren <ParticleSystem>();
        movement    = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f));
        rb.velocity = movement * 5;
    }
Beispiel #2
0
 public void TakeDamage(GameObject damager)
 {
     if (!invincible)
     {
         fire = GameObject.FindGameObjectWithTag("FireFly").GetComponent <FireFlyResources>();
         if (health > 0.5f)
         {
             GetComponent <SpriteRenderer>().color = Color.HSVToRGB(0, 100, 100);
             if (armor > 0.5f && damager.CompareTag("FireFly"))
             {
                 armor -= fire.damagePerTick;
             }
             else if (armor > 0 && !damager.CompareTag("FireFly"))
             {
                 armor -= 0.5f;
             }
             else if (armor <= 0)
             {
                 health -= 0.5f;
             }
             if (!death)
             {
                 FindObjectOfType <AudioManager>().TakeDamagePlayerSound();
             }
             OnValueChanged.Invoke();
         }
         else
         {
             if (damager.CompareTag("FireFly"))
             {
                 anim.SetBool("DeathFire", true);
                 FindObjectOfType <AudioManager>().DeathPlayerFireSound();
             }
             else
             {
                 anim.SetBool("DeathNormal", true);
                 FindObjectOfType <AudioManager>().DeathPlayerSound();
             }
             health -= fire.damagePerTick;
             GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Static;
             OnValueChanged.Invoke();
             death = true;
             Invoke("DeathScreen", 2.5f);
         }
         invincible = true;
         Invoke("resetInvulnerability", invinsibleAmount);
     }
 }
Beispiel #3
0
 private void Awake()
 {
     firefly = GameObject.FindGameObjectWithTag("FireFly").GetComponent <FireFlyResources>();
 }
Beispiel #4
0
 // Start is called before the first frame update
 void Start()
 {
     firefly = GameObject.FindGameObjectWithTag("FireFly").GetComponent <FireFlyResources>();
     player  = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerResources>();
     anim    = GetComponent <Animator>();
 }
Beispiel #5
0
 private void Awake()
 {
     pc        = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();
     resources = GetComponent <FireFlyResources>();
 }
Beispiel #6
0
 private void OnEnable()
 {
     pc        = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();
     resources = GetComponent <FireFlyResources>();
     FindObjectOfType <AudioManager>().AppearFireSound();
 }
Beispiel #7
0
 private void Start()
 {
     fire             = GetComponent <FireFlyResources>();
     Cursor.visible   = false;
     Cursor.lockState = CursorLockMode.Confined;
 }