// Configure a new sprite item data object properties, (could be new or recycled).
 protected override void ConfigureSpriteItemData(BaseSpriteItemData data)
 {
     // A new bolt is getting prepared, so let's schedule the sound effect.
     if (m_SkyProfile.IsFeatureEnabled(ProfileFeatureKeys.ThunderFeature))
     {
         Invoke("PlayThunderBoltSound", m_ThunderSoundDelay);
     }
 }
        // Select where the next sprite will be rendered at.
        protected override void CalculateSpriteTRS(BaseSpriteItemData data, out Vector3 spritePosition, out Quaternion spriteRotation, out Vector3 spriteScale)
        {
            // Create some variety in rain drop sizes.
            float minScale     = m_SplashScale * (1.0f - m_SplashScaleVarience);
            float uniformScale = Random.Range(minScale, m_SplashScale);

            spritePosition = data.spritePosition;
            spriteRotation = Quaternion.identity;
            spriteScale    = new Vector3(uniformScale, uniformScale, uniformScale);
        }
        public void Start()
        {
            state = SpriteState.Animating;

            // Schedule the start/end time of this sprite sheet animation in the GPU.
            startTime = BaseSpriteItemData.CalculateStartTimeWithDelay(delay);

            endTime = BaseSpriteItemData.CalculateEndTime(startTime,
                                                          spriteSheetData.frameCount,
                                                          spriteSheetData.frameRate);
        }
        // Setup any per-instance data you need to pass.
        protected override void PrepareDataArraysForRendering(int instanceId, BaseSpriteItemData data)
        {
            RainSplashData splash = data as RainSplashData;

            // We could probably move this into the shader to save some CPU calculations if necessary.
            Vector3 screenPoint = m_DepthCamera.WorldToScreenPoint(splash.spritePosition);
            Vector2 cameraUV    = new Vector2(screenPoint.x / m_DepthCamera.pixelWidth, screenPoint.y / m_DepthCamera.pixelHeight);

            splash.depthTextureUV = cameraUV;

            m_StartSplashYPositions[instanceId] = splash.spritePosition.y;
            m_DepthUs[instanceId] = splash.depthTextureUV.x;
            m_DepthVs[instanceId] = splash.depthTextureUV.y;
        }
        // Get or create a instance data field for a particle.
        BaseSpriteItemData DequeueNextSpriteItemData()
        {
            BaseSpriteItemData data = null;

            if (m_Available.Count == 0)
            {
                data = CreateSpriteItemData();
            }
            else
            {
                data = m_Available.Dequeue();
            }

            m_Active.Add(data);

            return(data);
        }
        void GenerateNewSprites()
        {
            int spawnCount = GetNextSpawnCount();

            Vector3    spritePosition;
            Vector3    spriteScale;
            Quaternion spriteRotation;

            for (int i = 0; i < spawnCount; i++)
            {
                // Dequeue a sprite item data, and configure it.
                BaseSpriteItemData data = DequeueNextSpriteItemData();
                data.spriteSheetData = m_SpriteSheetLayout;

                ConfigureSpriteItemData(data);
                CalculateSpriteTRS(data, out spritePosition, out spriteRotation, out spriteScale);

                data.SetTRSMatrix(spritePosition, spriteRotation, spriteScale);
                data.Start();
            }
        }
        // Select where the next sprite will be rendered at.
        protected override void CalculateSpriteTRS(BaseSpriteItemData data, out Vector3 spritePosition, out Quaternion spriteRotation, out Vector3 spriteScale)
        {
            LightningSpawnArea area = GetRandomLightningSpawnArea();

            float boltScale = CalculateLightningBoltScaleForArea(area);

            spriteScale = new Vector3(boltScale, boltScale, boltScale);

            spritePosition = GetRandomWorldPositionInsideSpawnArea(area);

            // Always face the sprite textures towards the main camera.
            if (Camera.main == null)
            {
                Debug.LogError("Can't billboard lightning to viewer since there is no main camera tagged.");
                spriteRotation = area.transform.rotation;
            }
            else
            {
                spriteRotation = Quaternion.LookRotation(spritePosition - Camera.main.transform.position, Vector3.up);
            }
        }
 void ReturnSpriteItemData(BaseSpriteItemData splash)
 {
     splash.Reset();
     m_Active.Remove(splash);
     m_Available.Enqueue(splash);
 }
 // Setup any per-instance data you need to pass.
 protected abstract void PrepareDataArraysForRendering(int instanceId, BaseSpriteItemData data);
 // Configure a new sprite item data object properties, (could be new or recycled).
 protected abstract void ConfigureSpriteItemData(BaseSpriteItemData data);
 // Select where the next sprite will be rendered at.
 protected abstract void CalculateSpriteTRS(BaseSpriteItemData data, out Vector3 spritePosition, out Quaternion spriteRotation, out Vector3 spriteScale);
 // Configure a new sprite item data object properties, (could be new or recycled).
 protected override void ConfigureSpriteItemData(BaseSpriteItemData data)
 {
     data.spritePosition = CreateWorldSplashPoint();
     data.delay          = Random.Range(0.0f, .5f);
 }
예제 #13
0
 // Setup any per-instance data you need to pass.
 protected override void PrepareDataArraysForRendering(int instanceId, BaseSpriteItemData data)
 {
     // No custom properties.
 }