コード例 #1
0
    public void takeDamage(float damage)
    {
        playerHitted       = true;
        MusicSource.volume = 2.7f;
        MusicSource.pitch  = Random.Range(0.8f, 1.1f);
        MusicSource.PlayOneShot(MusicClip);
        healthBar.addValue(-damage);
        if (healthBar.Value < 0.0001f)
        {
            //player is dead...
            GameVariables.DisableWeapons();
            GameVariables.ChangeToHero();
            isDead = true;

            if (Checkpoint != null)
            {
                Vector3 checkpointPos = Checkpoint.transform.position;
                GlobalControl.Set      = true;
                GlobalControl.Position = new Vector3(checkpointPos.x, checkpointPos.y + 2.1f, checkpointPos.z + 2.0f);
                GlobalControl.Rotation = new Quaternion(0, 0.7f, 0, 1.0f);
            }

            Die();
        }
    }