예제 #1
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.transform.tag == "Ground" || collision.gameObject.layer == LayerMask.NameToLayer("Enemy") || collision.gameObject.layer == LayerMask.NameToLayer("Hero"))
        {
            isSelected          = false;
            isThrown            = false;
            m_Sprite.localScale = new Vector3(1, 1, 1);

            if (isLanding)
            {
                isLanding = false;

                if (gameObject.layer == LayerMask.NameToLayer("Enemy"))
                {
                    ParticleManager.instance.EmitParticles(impactParticle, transform.position);
                    if (collision.gameObject.layer == LayerMask.NameToLayer("Hero"))
                    {
                        collision.gameObject.GetComponent <HeroManager>().Death(DeathType.Squished, transform);
                    }

                    Destroy(thisObj);
                }

                if (gameObject.tag == "Interactable")
                {
                    if (collision.gameObject.layer == LayerMask.NameToLayer("Hero"))
                    {
                        collision.gameObject.GetComponent <HeroManager>().Death(DeathType.Squished, transform);
                    }
                    else if (collision.gameObject.layer == LayerMask.NameToLayer("Enemy"))
                    {
                        ParticleManager.instance.EmitParticles(impactParticle, collision.transform.position);
                        Destroy(collision.gameObject);
                    }

                    m_Brigidbody.isKinematic = true;
                    anim.SetTrigger("Explosion");
                    explosionAudio.PlaySound();
                }
            }
            else
            {
                if (gameObject.tag == "Interactable")
                {
                    if (collision.gameObject.layer == LayerMask.NameToLayer("Hero"))
                    {
                        Debug.Log("Entro");
                        anim.SetTrigger("Explosion");
                        collision.gameObject.GetComponent <HeroManager>().Death(DeathType.Decapitation, transform);
                        explosionAudio.PlaySound();
                    }
                }
            }
        }
    }
예제 #2
0
    void ShootBullet()
    {
        GameObject b = Instantiate(bullet);

        b.GetComponent <Bullet>().Init(transform.position + (transform.rotation * bulletOffset), transform.up, transform.rotation, gameObject);
        shootingSound.PlaySound();
    }
예제 #3
0
    void Move()
    {
        if (Input.GetMouseButton(1))
        {
            Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            dest = new Vector3(mousePos.x, mousePos.y, 0);
            float AngleRad = Mathf.Atan2(dest.y - transform.position.y, dest.x - transform.position.x);
            // Get Angle in Degrees
            float AngleDeg = (180 / Mathf.PI) * AngleRad;
            // Rotate Object
            transform.rotation = Quaternion.Euler(0, 0, AngleDeg - 90);
        }

        if (Input.GetMouseButtonDown(0))
        {
            audioEmitter.PlaySound();
        }

        isMoving = Vector3.Distance(dest, transform.position) > 0.05f;

        if (isMoving)
        {
            transform.position += (dest - transform.position).normalized * forwardSpeed * Time.deltaTime;
        }
    }
예제 #4
0
    IEnumerator Charmed()
    {
        inLoveAudio.PlaySound();
        startCharmed = false;
        endCharmed   = false;
        anim.SetFloat("State", 4);
        while (!endCharmed)
        {
            yield return(null);
        }

        anim.SetFloat("EnterExit", 0);
        anim.SetFloat("State", 0);
    }
예제 #5
0
    public void Death(DeathType death, Transform enemy)
    {
        anim.SetInteger("DeathIndex", (int)death);
        m_NavAgent.speed = 0;
        deathAudio.PlaySound();

        if (death == DeathType.Decapitation)
        {
            Vector3 dir = (enemy.position - transform.position).normalized;
            heroHead.SetActive(true);
            heroHead.transform.parent = null;
            heroHead.GetComponent <Rigidbody>().AddForce(dir * headForce);
        }

        StartCoroutine(RestartLev());
    }
예제 #6
0
    public void LoadLevel(int levelID)
    {
        button.PlaySound();
        bkg.Stop();

        if (levelID == 1)
        {
            SceneManager.LoadScene("Livello_01Official");
        }
        if (levelID == 2)
        {
            SceneManager.LoadScene("Livello_02Official 1");
        }
        if (levelID == 3)
        {
            SceneManager.LoadScene("Livello_03Official");
        }
        if (levelID == 4)
        {
            SceneManager.LoadScene("Livello_04Official 2");
        }
        if (levelID == 5)
        {
            SceneManager.LoadScene("Livello_05Official");
        }
        if (levelID == 6)
        {
            SceneManager.LoadScene("Livello_06Official 2");
        }
        if (levelID == 7)
        {
            SceneManager.LoadScene("Livello_07Official");
        }
        if (levelID == 8)
        {
            SceneManager.LoadScene("Livello_08Official");
        }
        if (levelID == 9)
        {
            // Da settare
        }
        if (levelID == 10)
        {
            // Da settare
        }
    }
예제 #7
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="instance"></param>
            /// <param name="position"></param>
            /// <param name="soundPath"></param>
            public SoundStage(FXInstance instance, FXSoundStage stageDesc, FXEvent fxEvent, bool looped) : base(instance)
            {
                var sound = instance.fxPlayback.LoadSound(stageDesc.Sound);

                if (sound == null)
                {
                    return;
                }

                emitter               = instance.sw.AllocEmitter();
                emitter.Position      = fxEvent.Origin;
                emitter.DistanceScale = FXFactory.GetRadius(stageDesc.Attenuation);
                emitter.DopplerScale  = 1;
                emitter.VolumeCurve   = null;
                emitter.LocalSound    = false;

                emitter.PlaySound(sound, looped ? PlayOptions.Looped : PlayOptions.None);
            }
예제 #8
0
 public void Die()
 {
     dyingSound.PlaySound();
     GameHandler.Instance.Die();
 }
예제 #9
0
 private void Start()
 {
     explosionAudio = GetComponent <AudioEmitter>();
     explosionAudio.PlaySound();
 }
예제 #10
0
 private void Start()
 {
     heroManager = FindObjectOfType <HeroManager>();
     CharmPlayer();
     spawn.PlaySound();
 }