예제 #1
0
파일: Caveira1.cs 프로젝트: Eiglimar/Omnos
    //Funcao para fazer piscar quando for atacado!

    /*IEnumerator Flash(float time, float intervalTime)
     * {
     *      float elapsedTime = 0f;
     *      int index = 0;
     *      while(elapsedTime < time )
     *      {
     *              //altera as cores entre amarelo e vermelho!(ou nas cores que estiverem no array!)
     *              mat.color = colors[index % 2];
     *
     *              elapsedTime += Time.deltaTime;
     *              index++;
     *              yield return new WaitForSeconds(intervalTime);
     *      }
     *      //faz o personagem voltar a cor normal!
     *      mat.color = Color.white;
     * }*/

    public void Damage(int dano)
    {
        //myBody.AddForce (new Vector2(190, 80));
        //StartCoroutine (Flash (0.5f, 0.05f));
        SoundFXController.PlaySound(soundFx.CAVEIRA_DAMAGE);
        currentHealth -= dano;
    }
예제 #2
0
파일: Dinheiro.cs 프로젝트: Eiglimar/Omnos
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.tag == "Player")
     {
         SoundFXController.PlaySound(soundFx.DINHEIRO);
         int valorAtual = PlayerPrefs.GetInt("Player_Dinheiro");
         int valorNovo  = valorAtual + valor;
         PlayerPrefs.SetInt("Player_Dinheiro", valorNovo);
         Destroy(this.gameObject);
     }
 }
예제 #3
0
    //Toma dano
    public void Damage(int dmg)
    {
        SoundFXController.PlaySound(soundFx.DANO_PERSONAGEM);

        int tiraDano = (dmg - (defesa / 2));

        //Debug.Log("Cor do personagem antes!"+mat.color);

        StartCoroutine(Flash(0.5f, 0.05f));

        rb2D.AddForce(new Vector2(140, 10));

        currentHealth -= dmg;
    }
예제 #4
0
 void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
         DontDestroyOnLoad(this);
     }
     else
     {
         if (this != _instance)
         {
             DestroyImmediate(this.gameObject);
         }
     }
 }
예제 #5
0
    public void MagicAttack()
    {
        bulletTimer += Time.deltaTime;

        if (bulletTimer >= shootInterval)
        {
            SoundFXController.PlaySound(soundFx.CAVEIRA_MAGICA_ATAQUE);
            Vector2 direction = target.transform.position - transform.position;
            direction.Normalize();

            GameObject bulletClone;
            bulletClone = Instantiate(bullet, shootPoint.transform.position, shootPoint.transform.rotation) as GameObject;
            bulletClone.GetComponent <Rigidbody2D> ().velocity = direction * bulletSpeed;
            bulletTimer = 0;
        }
    }
예제 #6
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.tag == "Player")
     {
         if (tipoRecupera == "Vida")
         {
             SoundFXController.PlaySound(soundFx.COMENDO_PERSONAGEM);
             per.RecuperaVida(valorRecupera);
         }
         else if (tipoRecupera == "Mana")
         {
             SoundFXController.PlaySound(soundFx.COMENDO_PERSONAGEM);
             per.RecuperaMana(valorRecupera);
         }
         Destroy(this.gameObject);
     }
 }
예제 #7
0
파일: Caveira1.cs 프로젝트: Eiglimar/Omnos
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Player")
     {
         if (physicalAttack && morreu == false)
         {
             SoundFXController.PlaySound(soundFx.CAVEIRA_ATAQUE);
             col.gameObject.GetComponent <Personagem> ().Damage(dano);
         }
     }
     else if (col.gameObject.tag == "espinhos")
     {
         this.Damage(maxHealth);
     }
     else if (col.gameObject.tag == "agua")
     {
         this.Damage(maxHealth);
     }
 }
예제 #8
0
    void FixedUpdate()
    {
        //pular
        jump = Input.GetButtonDown("Jump");

        //pega se estiver na layer Ground
        grounded = Physics2D.OverlapCircle(groundCheck.position, 0.15f, whatIsGround);


        //se tiver pulando e estiver no chao e nao tiver dando o double jump
        if (jump && (grounded || !doubleJump))
        {
            //som do pulo
            SoundFXController.PlaySound(soundFx.JUMP);

            rb2D.velocity = new Vector2(0, 0);              // anula a velocidade que o personagem está caindo e assim o segundo pulo tera uma forca controlada de impulso
            rb2D.AddForce(new Vector2(0, jumpHeight));      // aplica a forca no eixo y para que o personagem "pule"

            //se tiver no ar e nao tiver dado o double jump pode dar o double jump!
            if (!grounded && !doubleJump)
            {
                doubleJump = true;
            }
        }
        else if (grounded)       // se tiver no chao desabilita o double jump!
        {
            doubleJump = false;
        }


        //ajusta a camera para verificar se o persoagem acabou de nascer
        if (startPos.position == transform.position)
        {
            //morreu = false;
            cam.transform.position = new Vector3(transform.position.x, cam.transform.position.y, cam.transform.position.z);
        }
    }
예제 #9
0
    // Update is called once per frame
    //public override void Update ()
    void Update()
    {
        //animacao do pulo!
        myAnimator.SetBool("grounded", grounded);
        //myAnimator.SetFloat ("speedY",rb2D.velocity.y);
        //base.Update ();


        //se cair morreu
        if (transform.position.y <= -12.0f)
        {
            //this.Damage (maxHealth);
            Die();
            currentHealth = 0;
        }

        if (!wallCheck)
        {
            // verifica se nao esta colidindo com algum objeto na frente
            rb2D.velocity = new Vector2(slide * moveSpeed, rb2D.velocity.y);             // se eu deixar o y em 0 o personagem não vai pular
            //Debug.Log ("Não está batendo");
        }

        //caminhar
        slide = Input.GetAxis("Horizontal");
        if (slide != 0)
        {
            walking = true;
        }
        else
        {
            walking = false;
        }

        if (walking)
        {
            Vector2 moveDir = new Vector2(slide * moveSpeed, rb2D.velocity.y);
            rb2D.velocity = moveDir;
            flip(slide);
        }

        myAnimator.SetBool("walk", walking);


        //para fazer interacao de informacoes e npcs
        if (Input.GetButtonDown("Fire1") && interacaoObj != null)
        {
            //Debug.Log ("Aqui tem alguma interacao...");

            //txtInteracaoRecebido = interacaoObj.SendMessage ("Interacao",SendMessageOptions.DontRequireReceiver); // nome do metodo de interacao e opcao(opcional porém importante)
            if (interacaoObj != null)
            {
                txtInteracaoRecebido = interacaoObj.GetComponent <InteracaoDialog> ().Interacao();
                txtCaixaDialogo.text = txtInteracaoRecebido;
                //Controle de aparicao da caixa de dialogo
                caixaDialogo.SetActive(interagindo);

                if (interagindo)
                {
                    interagindo = false;
                }
                else
                {
                    interagindo = true;
                }
            }
            else
            {
                interagindo = false;
            }
        }

        //se nao tiver mais no objeto de interacao a caixa de dialogo fica desativada!
        if (interacaoObj == null)
        {
            caixaDialogo.SetActive(false);
        }

        if (Input.GetKeyDown(KeyCode.C) && !attack1)
        {
            SoundFXController.PlaySound(soundFx.ATAQUE_ESPADA);
            attack1               = true;
            attackTimer           = attackCd;
            attackTrigger.enabled = true;
        }

        if (attack1)
        {
            if (attackTimer > 0)
            {
                attackTimer -= Time.deltaTime;
            }
            else
            {
                attack1 = false;
                attackTrigger.enabled = false;
            }
        }

        myAnimator.SetBool("attack1", attack1);

        //preencher a barra de vida
        healthBar.fillAmount = (float)currentHealth / maxHealth;

        //controla a quantidade de vida
        if (currentHealth > maxHealth)
        {
            currentHealth = maxHealth;
        }
        // se nao tiver mais vida morre
        if (currentHealth <= 0)
        {
            Die();
        }

        //preencher a barra de mana
        manaBar.fillAmount = (float)currentMana / maxMana;

        //controla a quantidade de vida
        if (currentMana > maxMana)
        {
            currentMana = maxMana;
        }
        // se nao tiver mais mana deixa zerada!
        if (currentMana <= 0)
        {
            currentMana = 0;
        }
    }
예제 #10
0
 // Use this for initialization
 void Start()
 {
     audioFonte = GetComponent <AudioSource> ();
     instance   = this;
 }