示例#1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.GetComponent <GroundHandler>() != null)
        {
            grounded = true;
        }

        if (collision.gameObject.GetComponent <ObstacleHandler>() != null ||
            collision.gameObject.tag == "Finish")
        {
            GameHandler.instance.ShowGameOverState();
            GameHandler.instance.finalMeter = (int)MeterTravelled;
            GameHandler.instance.finalScore = PlayerScore;
            GameHandler.instance.SetFinalMeter((int)MeterTravelled);
            GameHandler.instance.SetFinalScore(PlayerScore);
            GameHandler.instance.isGameOver = true;

            sound.Stop("Bike");
            sound.Play("PlayerDead");
            sound.Play("PlayerDead2");
            Instantiate(DeathFX, transform.position, transform.rotation);

            if (PlayerScore > currentHighestScore)
            {
                currentHighestScore = PlayerScore;
                SavePlayer();
            }
            Destroy(gameObject);
        }
    }
示例#2
0
    /// <summary>
    /// Sets the proper weapon upgrade based on the total number of kills
    /// </summary>
    private void SetWeaponUpgrade()
    {
        // go through the weapon upgrades, starting with the highest first
        foreach (WeaponUpgrade wu in weaponUpgrades)
        {
            // if the total kills is equal to this weapon upgrade threshold
            if (TotalPastaKills == wu.totalKillThreshold)
            {
                // set the weapon type and turn it on
                weapon.WeaponType = wu.weaponType;
                weapon.Toggle(true);

                // play a sound to let the user know a new weapon upgrade is available
                soundFXManager.Play("upgrade_available");

                // show that a new weapon upgrade is available
                guiManager.ShowNewWeaponAvailable(true);

                break;
            }
        }
    }
    protected override void CheckInput()
    {
        SoundFXManager sfxManager = GameObject.Find("SoundFXManager").GetComponent <SoundFXManager>();

        if (canMove)
        {
            base.CheckInput();
            if (isClimbing)
            {
                velocity.y = Input.GetAxisRaw(AxisName.Vertical.ToString()) * climbSpeed;
                animator.SetBool("Climbing", true);
            }
            else
            {
                animator.SetBool("Climbing", false);
            }
            if (velocity.x != 0)
            {
                if (!initSound)
                {
                    sfxManager.Play("Walk");
                    initSound = true;
                }
            }
            else
            {
                initSound = false;
                sfxManager.StopPlaying("Walk");
            }
            animator.SetBool(Lvl2PlayerAnimStates.Walking.ToString(), Input.GetButton(AxisName.Horizontal.ToString()));
        }
        else
        {
            velocity = Vector2.zero;
            sfxManager.StopPlaying("Walk");
        }
    }