示例#1
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();
            }
        }
    }
示例#2
0
    void Pickup(Collider2D player)
    {
        //fait de quoi sur le player
        GameObject        monjoueur = GameObject.FindGameObjectWithTag("Player");
        PlayerCharacter2D pc        = (PlayerCharacter2D)monjoueur.GetComponent(typeof(PlayerCharacter2D));

        if (pc == null)
        {
            Debug.Log("Player not found");
            return;
        }

        if (pc.upgrading)
        {
            return;
        }
        else
        {
            pc.upgrading = true;
        }

        //pc.ToggleUpgrade(UpgradeName);

        if (!pc.HasUpgrade(UpgradeName) || (UpgradeName == "Missile" && pc.HasUpgrade("Missile")))
        {
            switch (UpgradeName)
            {
            case "MorphBall":
                pc.ToggleUpgrade(UpgradeName);
                pc.gameObject.AddComponent(typeof(MorphBall));
                break;

            case "MorphBomb":
                pc.ToggleUpgrade(UpgradeName);
                break;

            case "GrappleBeam":
                pc.ToggleUpgrade(UpgradeName);
                pc.AddWeapon("GrappleBeam");
                pc.gameObject.GetComponent <GrappleBeam>().enabled = true;
                pc.gameObject.GetComponent <GrappleBeam>().UpdateGUI(false);
                break;

            case "Missile":
                pc.joueurStats.nbMissileMax += 5;
                pc.joueurStats.nbMissile     = pc.joueurStats.nbMissileMax;
                if (pc.HasUpgrade("Missile"))
                {
                    pc.UpdateMissileUI();
                }
                else
                {
                    pc.ToggleUpgrade(UpgradeName);
                    pc.AddWeapon("Missile");
                }
                Debug.Log("missile max 1: " + pc.joueurStats.nbMissileMax);
                break;

            case "MissileExpansion":
                pc.joueurStats.nbMissileMax += 5;
                pc.joueurStats.nbMissile     = pc.joueurStats.nbMissileMax;
                pc.UpdateMissileUI();
                break;

            case "HealthExpansion":
                pc.joueurStats.vieMax += 100;
                pc.joueurStats.vie     = pc.joueurStats.vieMax;
                pc.UpdateHealthBar();
                break;

            default:
                Debug.Log("Upgrade non spécifiée ou non reconnue");
                pc.gameObject.AddComponent(typeof(TestUpgradeBehavior));
                break;
            }

            gameObject.GetComponent <Animator>().Play("Disapear");
        }

        GetComponent <DialogueTrigger>().TriggerDialogue();

        Destroy(gameObject, 0.25f);
    }