Ejemplo n.º 1
0
    //  n'écrase plus le joueur
    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.tag == "Player")
        {
            GameObject coll = collision.gameObject;

            //  désactive les controle
            PlayerCharacter2D p = coll.GetComponent <PlayerCharacter2D>();

            Rigidbody2D rbp = coll.GetComponent <Rigidbody2D>() as Rigidbody2D;
            rbp.collisionDetectionMode = CollisionDetectionMode2D.Continuous;

            if (p)
            {
                p.setEnableInput(true);
            }

            //  agrandir le joueur
            Sequence decrase = DOTween.Sequence();
            decrase.Append(coll.transform.DOScaleY(m_ScaleY, 0.2f));
            //decrase.Insert(0.0f, m_Player.transform.DOMoveY(m_Player.transform.position.y + 0.4f, 0.2f));

            decrase.Play();
        }
    }
Ejemplo n.º 2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        GameObject coll = other.gameObject;

        if (m_Player == coll)
        {
            //  désactive les controle
            PlayerCharacter2D p = coll.GetComponent <PlayerCharacter2D>();

            Rigidbody2D rbp = m_Player.GetComponent <Rigidbody2D>() as Rigidbody2D;
            rbp.collisionDetectionMode = CollisionDetectionMode2D.Discrete;
            //rbp.constraints = RigidbodyConstraints2D.FreezeAll;

            if (p)
            {
                p.setEnableInput(false);
            }

            //  rapetisse le joueur
            Sequence ecrase = DOTween.Sequence();

            ecrase.Append(m_Player.transform.DOScaleY(1.0f, 0.2f));
            ecrase.Insert(0.0f, m_Player.transform.DOMoveY(m_Player.transform.position.y - 0.4f, 0.2f));
            ecrase.Play();
            //Invoke("p.setEnableInput(false)", m_MovingRate + 0.1f);
        }
    }
Ejemplo n.º 3
0
    public IEnumerator RespawnPlayer(PlayerCharacter2D perso)
    {
        //TODO: Ajout d'un son pour l'attente
        yield return(new WaitForSeconds(spawnDelay));

        if (FindObjectOfType <AudioManager>() != null)
        {
            FindObjectOfType <AudioManager>().Play("RespawnPlayer");
        }

        perso.gameObject.transform.position = spawnPoint.position;
        perso.gameObject.transform.rotation = spawnPoint.rotation;
        perso.SoinPerso(999999);

        //Detache le grappin si on meurt en etant attache
        if (perso.GetComponent <GrappleBeam>().isGrappleAttached)
        {
            perso.GetComponent <GrappleBeam>().UseGrapple();
        }

        //  si le joueur à été écrasé avant de mourir, réactive les controles et remet le scale comme il faut;
        if (perso.gameObject.transform.lossyScale.y < 1.5f)
        {
            Rigidbody2D rbp = perso.GetComponent <Rigidbody2D>() as Rigidbody2D;
            rbp.collisionDetectionMode = CollisionDetectionMode2D.Continuous;

            perso.setEnableInput(true);

            perso.gameObject.transform.localScale = new Vector3(5.0f, 5.0f, 1.0f);
        }

        perso.gameObject.SetActive(true);

        if (playerPrefab != null)
        {
            //Instantiate(playerPrefab, spawnPoint.position, Quaternion.identity);
            if (spawnPrefab != null)
            {
                Transform clone = Instantiate(spawnPrefab, spawnPoint.position, spawnPoint.rotation) as Transform;
                Destroy(clone.gameObject, 3f);
            }
        }

        perso.joueurStats.immortel = false;
    }
Ejemplo n.º 4
0
    //  si le joueur est détecter, l'écrase et lui fait des DMG
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Player")
        {
            GameObject coll = collision.gameObject;

            if (m_getScale == false)
            {
                m_ScaleY   = coll.transform.lossyScale.y;
                m_getScale = true;
            }

            if (dommageHit == (dommageHit | (1 << coll.layer)))
            {
                Personnages en = coll.GetComponent <Personnages>() as Personnages;
                en.DommagePerso(m_dmg);
            }

            if (m_descend == false)
            {
                //  désactive les controle
                PlayerCharacter2D p = coll.GetComponent <PlayerCharacter2D>();

                Rigidbody2D rbp = coll.GetComponent <Rigidbody2D>() as Rigidbody2D;
                rbp.collisionDetectionMode = CollisionDetectionMode2D.Discrete;

                if (p)
                {
                    p.setEnableInput(false);
                }

                //  rapetisse le joueur
                Sequence ecrase = DOTween.Sequence();

                ecrase.Append(coll.transform.DOScaleY(1.0f, 0.2f));
                ecrase.Insert(0.0f, coll.transform.DOMoveY(coll.transform.position.y - 0.4f, 0.2f));
                ecrase.Play();
            }
        }
    }