コード例 #1
0
    public void TakeDamage(int count)
    {
        if (IsInvlunerable)
        {
            return;
        }

        int newLifeCount = LifeCount - count;

        if (newLifeCount < 0)
        {
            // Start respawn
            _respawnPos    = GameManager.Instance.LevelGenerator.GetRespawnPosition(this.gameObject);
            _respawnPos.z  = transform.position.z;
            _timeToRespawn = Vector3.Distance(transform.position, _respawnPos) / RespawnSpeed;
            _respawnDir    = (_respawnPos - transform.position).normalized;
            ToggleRespawning(true);
        }
        else
        {
            var cameraController = GameManager.Instance.Cameras[PlayerId].GetComponent <CameraController>();
            if (cameraController)
            {
                cameraController.Shake(0.15f, 0.15f);
            }

            BloodParticleSystem.Stop();
            BloodParticleSystem.Play();

            Instantiate(HeartSpawner, transform.position, Quaternion.identity);
        }
        LifeCount = newLifeCount;

        SoundUtil.PlayRandomSound(HitSounds, _audioSource);
    }
コード例 #2
0
    private void Apply(CharacterLogic character)
    {
        switch (Type)
        {
        case PlatformType.Thorny:
        {
            if (character.IsInvlunerable)
            {
                return;
            }

            active_ = false;
            character.TakeDamage(1);
            GetComponent <SpriteRenderer>().color = new Color(0, 0, 0, 0);
            Particles.Play();

            SoundUtil.PlayRandomSound(Sounds, _audioSource);

            break;
        }

        default:
            break;
        }
    }
コード例 #3
0
    public bool Heal(int count)
    {
        int newCount = Mathf.Min(MaxLives, LifeCount + count);

        if (newCount == LifeCount)
        {
            return(false);
        }

        LifeCount = newCount;

        SoundUtil.PlayRandomSound(HealSounds, _audioSource);

        return(true);
    }
コード例 #4
0
    public void OnLanded(Vector2 velocity)
    {
        if (velocity.y < -0.3f)
        {
            var cameraController = GameManager.Instance.Cameras[PlayerId].GetComponent <CameraController>();
            if (cameraController)
            {
                cameraController.Shake(
                    Interpolate(ScreenShakeVelocityMin, ScreenShakeVelocityMax, velocity.y, ShakeTime),
                    Interpolate(ScreenShakeVelocityMin, ScreenShakeVelocityMax, velocity.y, ShakeIntensity)
                    );
            }

            SoundUtil.PlayRandomSound(LandingSounds, _audioSource);
        }
        else if (velocity.y < -0.1f)
        {
            SoundUtil.PlayRandomSound(LandingSoftSounds, _audioSource);
        }
    }