Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class bossmorre : MonoBehaviour {
- //iniciotestevar
- public float timeToInvencibility = 2;
- private float currentTimeToInvencibility = 0;
- public float timeToBlink = 0.05f;
- private float currentTimeToBlink = 0;
- private bool invencibility = false;
- public Renderer rendererboss;
- //fimtestevar
- bool isDead = false;
- int vida = 10;
- float tmr = 0;
- float aguardar = 5.0f;
- void Update(){
- if (vida <= 0) {
- isDead = true;
- // tornar invisivel
- }
- if (isDead) {
- tmr += 1.0f * Time.deltaTime;
- if (tmr > aguardar) {
- Application.LoadLevel ("Level02");
- }
- }
- //teste
- if (invencibility) {
- currentTimeToBlink+= Time.deltaTime;
- if(currentTimeToBlink > timeToBlink) {
- currentTimeToBlink =0;
- rendererboss.enabled = !rendererboss.enabled;
- }
- currentTimeToInvencibility += Time.deltaTime;
- if (currentTimeToInvencibility > timeToInvencibility) {
- invencibility = false;
- rendererboss.enabled = true;
- currentTimeToInvencibility = 0;
- }
- }
- }
- void OnTriggerEnter2D(Collider2D col){
- if(col.transform.tag.ToLower()=="player" && !invencibility){
- vida--;
- //teste
- invencibility = true;
- }
- }
- void OnGUI(){
- Rect rLbl = new Rect(0,0,200,200);
- // criar mensagem de tela concluida
- if(isDead){
- GUI.Label(rLbl,"Missão Completa");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement