void Update() { if (Vector2.Distance(player.transform.position, transform.position) < alert_distance && active && !died) { Character1.Alert(); active = false; StartCoroutine(Attack1()); } if (Vector2.Distance(player.transform.position, transform.position) > alert_distance + 2 && !active) { active = true; monster_life.SetActive(false); anim.SetBool("Attack", false); Character1.NoAlert(); if (!died) { StopAllCoroutines(); } rigi.velocity = Vector2.zero; } if (monster_life.GetComponent <MonsterLife>().Damaged) { monster_life.GetComponent <MonsterLife>().Damaged = false; monster_life.SetActive(false); StopAllCoroutines(); died = true; StartCoroutine(Die()); } }
void Update() { if (Vector2.Distance(Player.transform.position, transform.position) < 3f && Active && !Died) { Character1.Alert(); Active = false; StartCoroutine(Attack()); } if (Vector2.Distance(Player.transform.position, transform.position) > 5f && !Active) { Active = true; MonsterLife.SetActive(false); Anim.SetBool("Attack", false); Character1.NoAlert(); if (!Died) { StopAllCoroutines(); } Rigi.velocity = Vector2.zero; } if (MonsterLife.GetComponent <MonsterLife>().Damaged) { MonsterLife.GetComponent <MonsterLife>().Damaged = false; MonsterLife.SetActive(false); StopAllCoroutines(); Died = true; StartCoroutine(Die()); } }
void OnTriggerEnter2D(Collider2D Col) { if (Col.CompareTag("Player")) { HeroIsHere = true; Character1.Alert(); } }
void OnTriggerStay2D(Collider2D Col) { if (Col.CompareTag("Player") && Damage) { Character1.Alert(); Character1.MinusHp(); } }
// Start is called before the first frame update private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Player") { StartCoroutine(GameObject.FindGameObjectWithTag("Player").GetComponent <Character1>().DragBack()); Character1.Alert(); Character1.MinusHp(15); } }
private void OnTriggerEnter2D(Collider2D Col) { if (Col.CompareTag("Player") && Attack == true) { Character1.Alert(); Anim.SetInteger("Stage", 1); StartCoroutine(WaitAttack()); StartCoroutine(EnableLife()); Attack = false; } }
// Start is called before the first frame update void OnTriggerEnter2D(Collider2D Collider) { if (Collider.CompareTag("Player")) { switch (on) { case true: Character1.Alert(); break; case false: Character1.NoAlert(); break; } } }
IEnumerator Attack() { Character1.Alert(); Anim.speed = 0; yield return(new WaitForSeconds(0.5f)); Col.isTrigger = true; Anim.speed = 1; Rigi.AddForce((Player.transform.position - transform.position) * Force, ForceMode2D.Impulse); yield return(new WaitForSeconds(1f)); Rigi.drag = 20; Anim.SetBool("Attack", false); yield return(new WaitForSeconds(3f)); Col.isTrigger = false; Rigi.drag = 0; Active = true; Character1.NoAlert(); }
// Update is called once per frame void Update() { Rigi.velocity = Vec * Force; if (Vector2.Distance(Player.transform.position, gameObject.transform.position) < 3 && IsAttacked == false && Alive) { StopAllCoroutines(); StartCoroutine(Attack()); Character1.Alert(); IsAttacked = true; alert = true; } if (Vector2.Distance(Player.transform.position, gameObject.transform.position) > 3 && Alive) { MonsterLife.SetActive(false); IsAttacked = false; if (alert) { StopAllCoroutines(); Character1.NoAlert(); StartCoroutine(Going()); alert = false; Vec = Vector2.zero; } } if (MonsterLife.GetComponent <MonsterLife>().Damaged) { MonsterLife.GetComponent <MonsterLife>().Damaged = false; HP--; if (HP < 1) { StopAllCoroutines(); IsAttacked = true; Alive = false; StartCoroutine(Die()); Character1.NoAlert(); gameObject.GetComponent <State>().dead = true; return; } StartCoroutine(Drag()); } }
// Update is called once per frame void Update() { if (Vector2.Distance(Player.transform.position, gameObject.transform.position) < 5 && IsAttacked == false && Alive) { Character1.Alert(); StartCoroutine(Jump()); IsAttacked = true; alert = true; } if (Vector2.Distance(Player.transform.position, gameObject.transform.position) > 5 && Alive) { MonsterLife.SetActive(false); Anim.SetInteger("Vector", 1); StopAllCoroutines(); IsAttacked = false; if (alert) { Character1.NoAlert(); alert = false; } } if (MonsterLife.GetComponent <MonsterLife>().Damaged) { MonsterLife.GetComponent <MonsterLife>().Damaged = false; HP--; if (HP < 1) { StopAllCoroutines(); IsAttacked = true; Alive = false; StartCoroutine(Die()); Character1.NoAlert(); return; } StartCoroutine(Drag()); } }
// Update is called once per frame void Update() { if (AreaTrigger.Step && Stage == 0) { Stage = 1; CanDoDamage = true; Character1.Alert(); StartCoroutine(TileDissapear()); TC2.gameObject.SetActive(false); TC3.gameObject.SetActive(false); GameObject.Find("BOSS2").GetComponent <BossMode>().StartTimer(); } if (Heart.Damaged) { StopAllCoroutines(); StartCoroutine(Bushed()); Heart.Damaged = false; Lifes--; slider.value = Lifes; if (Lifes < 11 && Lifes > 7 && Stage == 1) { Stage = 2; StageCount = 0; } if (Lifes < 7 && Lifes > 1 && Stage == 2) { Stage = 3; StageCount = 0; } if (Lifes < 2 && Stage != 4) { Stage = 4; StageCount = 0; } } if (CanDoDamage) { BossMode.BossAttacks++; CanDoDamage = false; switch (Stage) { case 0: break; case 1: ChooseAttack1(); break; case 2: ChooseAttack2(); break; case 3: ChooseAttack3(); break; case 4: ChooseAttack4(); break; } } }
void Update() { if (BossModeflag == true && ActiveArea.GetComponent <ActiveOnStep>().Active&& !Active) { Active = true; ActiveArea.GetComponent <ActiveOnStep>().Active = false; GameObject.Find("Boss").GetComponent <BossMode>().StartTimer(); } if (Lifes < 1 && LastStady == false) { slider.SetActive(false); Heart.SetActive(false); } if (Lifes < 1 && Heart.GetComponent <MonsterLife>().Damaged&& LastStady) { StopAllCoroutines(); StartCoroutine(Die()); Anim.SetBool("Died", true); Heart.SetActive(false); Phrases[3].SetActive(true); EventSavingSystem.UsedEvents[8] = true; slider.gameObject.SetActive(false); StartCoroutine(TileAppear()); return; } if (Lifes < 1 && Vector2.Distance(Player.transform.position, transform.position) > Distance + 3 && LastStady) { StopAllCoroutines(); Heart.SetActive(false); Phrases[4].SetActive(true); EventSavingSystem.UsedEvents[9] = true; Destroy(gameObject); slider.gameObject.SetActive(false); StartCoroutine(TileAppear()); return; } if (Heart.GetComponent <MonsterLife>().Damaged) { StopAllCoroutines(); Heart.GetComponent <MonsterLife>().Damaged = false; StartCoroutine(Drag(Player.transform.position)); } if (Col.IsTouching(TC1) || Col.IsTouching(TC2) || Col.IsTouching(TC3) || Col.IsTouching(TC4) || Col.IsTouching(TC5)) { Col.isTrigger = false; } if (Active) { TC5.gameObject.SetActive(true); GameObject.Find("AudioSystem").GetComponent <AudioSystem>().CallMusic(3); if (!Tilelock) { StartCoroutine(TileDissapear()); Tilelock = true; } Character1.Alert(); Rigi.drag = 100; slider.SetActive(true); //Heart.GetComponent<MonsterLife>().HitEnable = true; Heart.SetActive(false); Active = false; slider.gameObject.SetActive(false); Anim.SetBool("Attack", true); TypeAttack = (TypeAttack == 0) ? 1 : Random.Range(1, 5); if (Lifes > 1) { BossMode.BossAttacks++; switch (TypeAttack) { case 1: StartCoroutine(Attack1()); break; case 2: StartCoroutine(Attack2()); break; case 3: StartCoroutine(Attack3()); break; case 4: StartCoroutine(Attack4()); break; } } else if (Lifes < 4 && Lifes > 0) { StartCoroutine(Attack5()); } } }