Esempio n. 1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Player"))
        {
            PlayerCharacter2D pc = other.GetComponent <PlayerCharacter2D>();

            switch (PickupType)
            {
            case "Health":
                pc.SoinPerso(Valeur);
                break;

            case "Missile":
                pc.joueurStats.nbMissile += Valeur;
                if (pc.joueurStats.nbMissile > pc.joueurStats.nbMissileMax)
                {
                    pc.joueurStats.nbMissile = pc.joueurStats.nbMissileMax;
                }
                pc.UpdateMissileUI();
                break;

            default:
                break;
            }

            if (FindObjectOfType <AudioManager>())
            {
                FindObjectOfType <AudioManager>().Play("PickupSound");
            }
            Destroy(gameObject);
        }
    }
Esempio n. 2
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;
    }