示例#1
0
        void Start()
        {
            NormalFlings = Flings.CreateNormalFlings();
            if (UninfectedHitPool == null)
            {
                UninfectedHitPool = ObjectPool.Create(Assets.EffectAssets.UninfectedHitPrefab);
            }


            flasher = GetComponent <SpriteFlasher>();
            if (DamageSound == null)
            {
                DamageSound = Assets.AudioAssets.DamageEnemy;
            }
        }
示例#2
0
        public void PlayHitEffect(HitInfo hit, Vector3 effectsOffset = default(Vector3))
        {
            if (!firedOnCurrentFrame)
            {
                firedOnCurrentFrame = true;

                WeaverAudio.PlayAtPoint(DamageSound, transform.position, channel: AudioChannel.Sound);

                if (doFlashEffects)
                {
                    flasher.FlashNormalHit();
                }

                GameObject hitParticles = Instantiate(Assets.EffectAssets.UninfectedHitPrefab, transform.position + effectsOffset, Quaternion.identity);
                //GameObject hitParticles = Pooling.Instantiate(Assets.EffectAssets.UninfectedHitPrefab, transform.position + effectsOffset, Quaternion.identity);

                var direction = DirectionUtilities.DegreesToDirection(hit.Direction);

                switch (direction)
                {
                case CardinalDirection.Up:
                    SetRotation2D(hitParticles.transform, 45f);
                    break;

                case CardinalDirection.Down:
                    SetRotation2D(hitParticles.transform, 225f);
                    break;

                case CardinalDirection.Left:
                    SetRotation2D(hitParticles.transform, -225f);
                    break;

                case CardinalDirection.Right:
                    SetRotation2D(hitParticles.transform, -45f);
                    break;
                }

                Flings.SpawnFlings(NormalFlings, transform.position + effectsOffset, direction);
            }
        }