Esempio n. 1
0
        public void Awake()
        {
            Interval = CoolOffTime + 0.25f;      // Start with a delay to allow time for scene to load
            Camera   = Camera.main;

            ContactFilter = new ContactFilter2D
            {
                layerMask   = lm,
                useTriggers = false,
            };

            ProjectileManager = ProjectileManager.Instance;

            // If projectile type is not set, use default
            if (ProjectilePrefab == null)
            {
                ProjectilePrefab = ProjectileManager.Instance.GetProjectilePrefab(0);
            }
            isStopped = true;

            if (shootAtBeginning)
            {
                Interval = 0;
            }
        }
Esempio n. 2
0
        public void UpdateBufferData(ProjectilePrefab projectileType, ProjectileData data)
        {
            if (projectileType.Index != LastAccessedProjectileTypeIndex)
            {
                LastAccessedProjectileTypeIndex = projectileType.Index;
                LastAccessedRenderer            = IndirectRenderers[LastAccessedProjectileTypeIndex];
            }

            LastAccessedRenderer.UpdateBufferData(projectileType.BufferIndex, data);
            projectileType.IncrementBufferIndex();
        }
Esempio n. 3
0
        void Initialize()
        {
            if (!Initialized)
            {
                // Grab a list of Projectile Types founds in assets folder "ProjectilePrefabs"
                GameObject[] projectileTypes = Resources.LoadAll <GameObject>("ProjectilePrefabs");
                ProjectilePrefabs      = new List <ProjectilePrefab>();
                IndirectRenderers      = new Dictionary <int, IndirectRenderer>();
                ProjectileTypeCounters = new Dictionary <int, ProjectileTypeCounters>();

                // Process projectile types
                int currentIndex = 0;
                for (int n = 0; n < projectileTypes.Length; n++)
                {
                    ProjectilePrefab type = projectileTypes[n].GetComponent <ProjectilePrefab>();

                    // if script is not attached, then we skip as it is invalid.
                    if (type == null)
                    {
                        continue;
                    }

                    type.Initialize(currentIndex);
                    ProjectilePrefabs.Add(type);

                    // If material is set to be a static color ensure we do not send color data to shader
                    IndirectRenderers.Add(currentIndex, new IndirectRenderer(type.GetMaxProjectileCount(), type.Material, type.Mesh, type.IsStaticColor));
                    ProjectileTypeCounters.Add(currentIndex, new ProjectileTypeCounters());

                    currentIndex++;
                }

                EmittersArray = new ProjectileEmitterBase[MaxEmitters];

                // Get a list of all emitters in the scene
                RegisterEmitters();

                Initialized = true;
            }
        }