Beispiel #1
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        DontDestroyOnLoad(gameObject);

        foreach (Sound s in sounds)
        {
            s.source      = gameObject.AddComponent <AudioSource>();
            s.source.clip = s.clip;

            s.source.volume      = s.volume;
            s.source.pitch       = s.pitch;
            s.source.loop        = s.loop;
            s.source.playOnAwake = s.playAwake;
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        if (isCombat)
        {
            //detect enemies in range
            hitEnemies = Physics2D.OverlapBoxAll(attackPoint.position, new Vector2(attackRangeX, attackRangeY), 0, enemyLayers);

            hitBreakables = Physics2D.OverlapBoxAll(attackPoint.position, new Vector2(attackRangeX, attackRangeY), 0, breakableLayers);
            if (Time.time >= nextAttack && !isPlaying)
            {
                if (Input.GetButtonDown("Fire1"))
                {
                    Attack();
                    nextAttack = Time.time + 1f / attackRate;
                    AudioManagerSFX.PlaySound("kickEnemy");
                }
            }

            if (Time.time > nextMusic)
            {
                //mp.runSpeed = regSpeed;
                if (Input.GetButtonDown("Berimbau"))
                {
                    Music();
                    nextMusic = Time.time + musicCoolDown;
                }
            }
        }
    }
Beispiel #3
0
    void Attack()
    {
        anim.SetTrigger("Attack");
        mp.runSpeed = 0f;
        Invoke("ResetSpeed", 1f);

        //apply damage
        foreach (Collider2D enemy in hitEnemies)
        {
            var damo = enemy.GetComponent <Enemy>();
            if (damo.currentHealth > attackDamage)
            {
                damo.TakeDamage(attackDamage);
            }
            else
            {
                damo.TakeDamage(damo.currentHealth);
            }
            AudioManagerSFX.PlaySound("enemyHIT");
        }

        foreach (Collider2D breakable in hitBreakables)
        {
            AudioManagerSFX.PlaySound("kickLamp");
            breakable.GetComponent <Breakable>().TakeDamage(attackDamage);
        }
    }
 private void OpenSesame()
 {
     AudioManagerSFX.PlaySound("open");
     doorMessage.SetBool("isOpen", false);
     doorCollider.enabled = false;
     Destroy(this);
 }
Beispiel #5
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Player"))
     {
         AudioManagerSFX.PlaySound("healthUP");
         pc.currentHealth += healthBonus;
         healthBar.SetHealth(pc.currentHealth);
         Destroy(gameObject);
     }
 }
Beispiel #6
0
 // Update is called once per frame
 void Update()
 {
     if (Time.time > nextBall)
     {
         if (Input.GetButtonDown("Kick"))
         {
             AudioManagerSFX.PlaySound("ballIsLife");
             anim.SetTrigger("Ballin");
             Invoke("Shoot", 0.35f);
             cool.ballIsCooling = true;
             nextBall           = Time.time + ballCoolDown;
         }
     }
 }
Beispiel #7
0
    void Die()
    {
        AudioManagerSFX.PlaySound("lampBreak");

        //this is the only breakable object currently, so small healthpickup drop chance
        var r = Random.Range(0, 10);

        if (r > 9)
        {
            drop = Instantiate <HealthPickup>(hp, transform.position + transform.up * -1, transform.rotation);
        }

        this.enabled = false;

        Destroy(gameObject, 2f);
    }
Beispiel #8
0
 void BeatHit()
 {
     if (currentAmount >= 78 && currentAmount <= 100)
     {
         Debug.Log("Hit!");
         beatZoneAnim.SetTrigger("isHit");
         AudioManagerSFX.PlaySound("attackUP");
         attackUP.Play();
         multiplier++;
         mp.runSpeed += 1.5f;
         // Add some kind of value +1 to PlayerCombat?
     }
     else
     {
         AudioManagerSFX.PlaySound("berimBAM");
         Debug.Log("Miss");
         // AudioManagerSFX.PlaySound("berimMiss");
     }
 }
Beispiel #9
0
    void Die()
    {
        dead = true;
        theCanvas.SetActive(false);
        AudioManagerSFX.PlaySound("enemyDied");
        anim.SetBool("isWalking", false);

        anim.SetBool("isDead", true);
        // enemy gameobj is not destroyed, body is left behind for 2 seconds
        this.enabled = false;

        var r = Random.Range(0, 100);

        if (r > 90)
        {
            drop = Instantiate <HealthPickup>(hp, transform.position + transform.right * 1, transform.rotation);
        }

        Destroy(gameObject, 2f);
    }
Beispiel #10
0
    IEnumerator TypeSentence(string sentence, string response)
    {
        dialogueText.text = "";
        responseText.text = "";
        AudioManagerSFX.PlaySound("dialogue");
        foreach (char letter in sentence.ToCharArray())
        {
            dialogueText.text += letter;

            // 1 frame buffer time between each letter rendering
            yield return(null);
        }
        AudioManagerSFX.theSource.Stop();
        if (response == null || response == "")
        {
            response = "Press 'F' to Continue...";
        }
        foreach (char letter in response.ToCharArray())
        {
            responseText.text += letter;
            yield return(null);
        }
    }
Beispiel #11
0
    private void OnTriggerEnter2D(Collider2D hitInfo)
    {
        Debug.Log(hitInfo.name);
        Enemy       enemy   = hitInfo.GetComponent <Enemy>();
        Rigidbody2D enemyRb = hitInfo.GetComponent <Rigidbody2D>();

        if (enemy != null && !didHit)
        {
            AudioManagerSFX.PlaySound("ballHIT");
            didHit = true;
            //KNOCKBACK CODE
            enemy.speed = enemy.speed / 2;
            Vector2 difference = enemyRb.transform.position - transform.position;
            difference = difference.normalized * thrust;
            enemyRb.AddForce(difference, ForceMode2D.Impulse);

            //Instantiate(impactEffect, transform.position, transform.rotation);

            StartCoroutine(KnockCo(enemyRb, enemy));

            enemy.TakeDamage(damage);
        }
    }
Beispiel #12
0
    // Update is called once per frame
    void Update()
    {
        if (!canMove)
        {
            rb.velocity = Vector2.zero;
            horizontal  = 0f;
            vertical    = 0f;
            return;
        }
        else
        {
            horizontal = Input.GetAxis("Horizontal");
            vertical   = Input.GetAxis("Vertical");
            // rolling = new Vector3(horizontal * rollSpeed, vertical * rollSpeed, 0.0f);
        }

        if (stepOffset > 0)
        {
            stepOffset -= Time.deltaTime;
        }
        if (stepOffset <= 0)
        {
            stepOffset = 0;
        }

        if (canMove && (Input.GetButton("Horizontal") || Input.GetButton("Vertical")) && stepOffset == 0)
        {
            AudioManagerSFX.PlaySound("run");
            // Can change this to adjust speed of footstep sounds
            stepOffset = 0.3f;
        }

        if (rollTime > 0)
        {
            rollTime -= Time.deltaTime;
        }

        if (!isDodging)
        {
            if (direction != 0)
            {
                if (Input.GetButtonDown("Dodge"))
                {
                    AudioManagerSFX.PlaySound("dodge");
                    isDodging = true;
                    animator.SetTrigger("Dodging");
                    StartCoroutine(BeginDodgeRoll());
                }
            }

            if (Input.GetKeyDown(KeyCode.A))
            {
                direction = 1;
            }
            else if (Input.GetKeyDown(KeyCode.D))
            {
                direction = 2;
            }
            else if (Input.GetKeyDown(KeyCode.W))
            {
                direction = 3;
            }
            else if (Input.GetKeyDown(KeyCode.S))
            {
                direction = 4;
            }
        }
    }
Beispiel #13
0
    public void EnemyAttack()
    {
        var pc = target.GetComponent <PlayerCombat>();

        if (pc.currentHealth < 0)
        {
            isAttacking = false;
        }

        if (isAttacking && !isBlocking && !isStunned)
        {
            //detect player in range
            Collider2D[] hitPlayer = Physics2D.OverlapBoxAll(attackPoint.position, new Vector2(attackRangeX, attackRangeY), 0, playerLayer);

            var r = Random.Range(0, 100);
            if (r < 60)
            {
                //60% probability WEAK
                attackType = 1;
            }
            else if (r > 60 && r < 75)
            {
                //15% probability STRONG
                attackType = 2;
            }
            else if (r >= 75 && r < 90)
            {
                //15% probability VOMIT
                attackType = 3;
            }
            else if (r >= 90)
            {
                //10% probability BLOCK
                attackType = 4;
            }

            anim.SetBool("isWalking", false);

            switch (attackType)
            {
            case 1:
                anim.SetTrigger("basicAttack");
                AudioManagerSFX.PlaySound("basicAttack");
                Debug.Log("weak attack");
                foreach (Collider2D player in hitPlayer)
                {
                    pc.TakeDamage(attackDamage);
                }
                break;

            case 2:
                anim.SetTrigger("strongAttack");
                AudioManagerSFX.PlaySound("strongAttack");
                Debug.Log("strong attack");
                foreach (Collider2D player in hitPlayer)
                {
                    pc.TakeDamage(strongDamage);
                }
                break;

            case 3:
                anim.SetTrigger("Vomit");
                Debug.Log("vomit");
                Vector2 direction = Vector2.right;
                if (GetComponentInChildren <SpriteRenderer>().flipX)
                {
                    direction = Vector2.left;
                }
                flight = Vomiting.CreateVomit(vomitPrefab, pukePoint, direction);
                Invoke("ByeVomit", despawn);
                break;

            case 4:
                stopped = false;
                Debug.Log("blocking");
                speed = speed / 2;
                anim.SetBool("isBlocking", true);
                anim.SetTrigger("Block");
                anim.SetBool("isWalking", false);
                isBlocking = true;
                if (!stopped)
                {
                    Invoke("StopBlock", 3f);
                }
                break;

            default:
                Debug.Log("welp that happened");
                break;
            }
        }
    }