Beispiel #1
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;
    }
Beispiel #2
0
    public void Contact(int dmg, PlayerCharacter2D pl, float f)
    {
        //Rigidbody2DExt.AddExplosionForce(pl.GetComponent<Rigidbody2D>(), f, firePoint.position, r, upM, ForceMode2D.Force);
        var dir = my_transform.position - pl.transform.position;
        //Debug.Log(dir);
        Vector3 baseForce = -dir.normalized * f;

        baseForce.x *= 2f;
        //baseForce.x += Mathf.Sign(baseForce.x)*10f;

        if (dir.y > -0.9f && dir.y < 0.9f)
        {
            Vector2 upp = Vector2.up * 10f;
            pl.GetComponent <Rigidbody2D>().AddForce(upp, ForceMode2D.Impulse);
            baseForce.y = 0;
        }

        //Debug.Log(baseForce);
        pl.GetComponent <Rigidbody2D>().AddForce(baseForce);
        pl.DommagePerso(dmg);
    }
Beispiel #3
0
    public void Explosion(int dmg, PlayerCharacter2D pl, float fireRate)
    {
        if (CanAttack)
        {
            if (effetAttaquePrefab != null)
            {
                Transform      clone = Instantiate(effetAttaquePrefab, firePoint.position, firePoint.rotation) as Transform;
                ShockWaveForce wave  = clone.GetComponent <ShockWaveForce>();
                wave.radius = statAttaque.eRadius * 1.3f;

                Destroy(clone.gameObject, 1f);
            }

            attaqueCooldown = fireRate;

            if (Rigidbody2DExt.AddExplosionForce(pl.GetComponent <Rigidbody2D>(), statAttaque.ePower, firePoint.position, statAttaque.eRadius, statAttaque.upwardsModifier))
            {
                pl.DommagePerso(dmg);
            }
        }
    }
Beispiel #4
0
    private void Update()
    {
        // Read the inputs.
        //bool crouch = Input.GetKey(KeyCode.LeftControl);
        float h = CrossPlatformInputManager.GetAxis("Horizontal");

        //float primaryAttack = Input.GetAxis("Fire1");

        // Pass all parameters to the character control script.
        m_Character.Move(h, false, m_Jump);
        m_Jump = false;

        if (CrossPlatformInputManager.GetButtonDown("Fire1") || CrossPlatformInputManager.GetAxis("Fire1") != 0)
        {
            m_Character.UseWeapon();
        }

        if (Input.GetAxisRaw("Fire3") != 0)
        {
            if (m_isAxisInUse == false)
            {
                m_Character.Viser();
                m_isAxisInUse = true;
            }
        }
        if (Input.GetAxisRaw("Fire3") == 0)
        {
            if (m_isAxisInUse)
            {
                m_Character.Viser();
            }

            m_isAxisInUse = false;
        }

        if (CrossPlatformInputManager.GetButtonDown("WeaponSelectUp"))
        {
            m_Character.WeaponSwitch(true);
        }

        if (CrossPlatformInputManager.GetButtonDown("WeaponSelectDown"))
        {
            m_Character.WeaponSwitch(false);
        }

        //Rappel pour le grappin
        if (CrossPlatformInputManager.GetAxis("Vertical") != 0)
        {
            if (m_Character.GetComponent <GrappleBeam>().isGrappleAttached)
            {
                m_Character.GetComponent <GrappleBeam>().HandleGrappleLength(CrossPlatformInputManager.GetAxis("Vertical"));
            }
        }

        if (CrossPlatformInputManager.GetButtonDown("UpgradeCheat"))
        {
            if (!upgradeCheatFlag)
            {
                Debug.Log("All upgrade active");
                m_Character.ToggleUpgrade("MorphBall");
                m_Character.gameObject.AddComponent(typeof(MorphBall));

                m_Character.ToggleUpgrade("MorphBomb");

                m_Character.ToggleUpgrade("Missile");
                m_Character.AddWeapon("Missile");

                Debug.Log("missile max 1: " + m_Character.joueurStats.nbMissileMax);

                m_Character.ToggleUpgrade("GrappleBeam");
                m_Character.AddWeapon("GrappleBeam");
                m_Character.gameObject.GetComponent <GrappleBeam>().enabled = true;
                m_Character.gameObject.GetComponent <GrappleBeam>().UpdateGUI(false);

                m_Character.joueurStats.nbMissileMax += 5;
                m_Character.joueurStats.nbMissile     = m_Character.joueurStats.nbMissileMax;
                m_Character.UpdateMissileUI();

                Debug.Log("missile max 2: " + m_Character.joueurStats.nbMissileMax);

                m_Character.joueurStats.vieMax += 100;
                m_Character.joueurStats.vie     = m_Character.joueurStats.vieMax;
                m_Character.UpdateHealthBar();
                upgradeCheatFlag = true;
            }
            else
            {
                Debug.Log("Upgrade cheat deja activé");
            }
        }

        if (CrossPlatformInputManager.GetButtonDown("TriggerAction1"))
        {
            //m_Character.PrintAllUpgrade();
        }

        if (CrossPlatformInputManager.GetButton("Run"))
        {
            m_Character.IsRunning = true;
        }
        else
        {
            m_Character.IsRunning = false;
        }

        if (!m_Jump)
        {
            // Read the jump input in Update so button presses aren't missed.
            m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");
        }

        if (Input.GetKeyDown(KeyCode.I))
        {
            m_Character.joueurStats.immortel = !m_Character.joueurStats.immortel;
        }

        if (Input.GetKeyDown(KeyCode.K))
        {
            GameMaster.KillJoueur(m_Character);
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            if (GameObject.Find("Boss_Ecrabouilleur") != null)
            {
                boss bo = GameObject.Find("Boss_Ecrabouilleur").GetComponent <boss>();
                bo.CheatLifeBoss();
            }

            if (GameObject.Find("BossTeleporteur") != null)
            {
                bossTeleport boTp = GameObject.Find("BossTeleporteur").GetComponent <bossTeleport>();
                boTp.CheatLifeBoss();
            }
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            if (GameObject.Find("Spawn_Folder") != null)
            {
                AllSpawners all = GameObject.Find("Spawn_Folder").GetComponent <AllSpawners>();
                all.SpawnAllEnnemis();
            }
        }
    }