コード例 #1
0
ファイル: AIDamageTrigger.cs プロジェクト: Auggst/FPS-Demo
    private void OnTriggerStay(Collider other)
    {
        if (!_animator)
        {
            return;
        }

        if (other.gameObject.CompareTag("Player") && _animator.GetFloat(_parameterHash) > 0.9f)
        {
            if (GameSceneManager.instance && GameSceneManager.instance.bloodParticles)
            {
                ParticleSystem system = GameSceneManager.instance.bloodParticles;

                system.transform.position = transform.position;
                system.transform.rotation = Camera.main.transform.rotation;

                var settings = system.main;
                settings.simulationSpace = ParticleSystemSimulationSpace.World;
                system.Emit(_bloodParticlesBurstAmount);
            }

            if (_gameSceneManager != null)
            {
                PlayerInfo info = _gameSceneManager.GetPlayerInfo(other.GetInstanceID());
                if (info != null && info.characterManager != null)
                {
                    info.characterManager.TakeDamage(_damageAmount);
                }
            }
        }
    }
コード例 #2
0
    private void OnTriggerStay(Collider collider)
    {
        if (!animator)
        {
            return;
        }

        if (collider.gameObject.CompareTag("Player") && animator.GetFloat(parameterHash) > 0.9f)
        {
            if (GameSceneManager.Instance && GameSceneManager.Instance.BloodParticles)
            {
                ParticleSystem system = GameSceneManager.Instance.BloodParticles;

                system.transform.position = transform.position;
                system.transform.rotation = Camera.main.transform.rotation;
                ParticleSystemSimulationSpace spaceMode = system.main.simulationSpace;
                spaceMode = ParticleSystemSimulationSpace.World;
                system.Emit(bloodParticlesBurstAmount);
            }

            if (gameSceneManager != null)
            {
                PlayerInfo info = gameSceneManager.GetPlayerInfo(collider.GetInstanceID());

                if (info != null && info.characterManager != null)
                {
                    info.characterManager.TakeDamage(damageAmount, doDamageSound && firstContact, doPainSound);
                }
            }

            firstContact = false;
        }
    }
コード例 #3
0
    // -------------------------------------------------------------
    // Name	:	OnTriggerStay
    // Desc	:	Called by Unity each fixed update that THIS trigger
    //			is in contact with another.
    // -------------------------------------------------------------
    void OnTriggerStay(Collider col)
    {
        // If we don't have an animator return
        if (!_animator)
        {
            return;
        }

        // If this is the player object and our parameter is set for damage
        if (col.gameObject.CompareTag("Player") && _animator.GetFloat(_parameterHash) > 0.9f)
        {
            if (GameSceneManager.instance && GameSceneManager.instance.bloodParticles)
            {
                ParticleSystem system = GameSceneManager.instance.bloodParticles;

                // Temporary Code
                //system.transform.position = transform.position;
                //system.transform.rotation = Camera.main.transform.rotation;

                system.simulationSpace = ParticleSystemSimulationSpace.World;
                system.Emit(_bloodParticlesBurstAmount);
            }

            if (_gameSceneManager != null)
            {
                PlayerInfo info = _gameSceneManager.GetPlayerInfo(col.GetInstanceID());
                if (info != null && info.characterManager != null)
                {
                    info.characterManager.TakeDamage(_damageAmount, _doDamageSound && _firstContact, _doPainSound);
                }
            }
            _firstContact = false;
        }
    }
コード例 #4
0
    void OnTriggerStay(Collider other)
    {
        if (!_animator)
        {
            return;
        }

        if (other.CompareTag("Player") && _animator.GetFloat(_parameter) > .9f)
        {
            if (_gameSceneManager && GameSceneManager.instance.bloodParticles)
            {
                ParticleSystem system = GameSceneManager.instance.bloodParticles;
                system.transform.position = transform.position;
                // To make sure the blood goes forward
                system.transform.rotation = Camera.main.transform.rotation;
                system.simulationSpace    = ParticleSystemSimulationSpace.World;
                system.Emit(_bloodParticleBurstAmount);
            }

            if (_gameSceneManager != null)
            {
                PlayerInfo       playerInfo       = _gameSceneManager.GetPlayerInfo(other.GetInstanceID());
                CharacterManager characterManager = other.GetComponent <CharacterManager>();
                characterManager.TakeDamage(_damageAmount, _doDamageSound && _firstContact, _doPainSound);
            }

            _firstContact           = false;
            _resetFirstContactTimer = 0f;
        }
    }