Esempio n. 1
0
        public void Draw(SpriteBatch spriteBatch, Vector2 globalToScreen, Vector2 screenSize)
        {
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive); // ставим режим смешивания Addictive

            for (int i = 0; i < _pool.Length; i++)                           // рисуем все частицы
            {
                Particle particle = _pool[i];
                if (particle.isUsed)
                {
                    FloatRectangle screenRect = new FloatRectangle(globalToScreen, screenSize);
                    if (screenRect.Contains(particle.Position))
                    {
                        particle.Draw(spriteBatch, globalToScreen);
                    }
                }
                _pool[i] = particle;
            }

            spriteBatch.End();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="entities">Global list of entities.</param>
        public void DetectEntitiesInThisTile(List <Entity.Entity> globalEntities)
        {
            for (int i = 0; i < globalEntities.Count; i++)
            {
                if (loc.Contains(new Vector2(globalEntities[i].location.X, globalEntities[i].location.Y)))
                {
                    // Allow entites to know what tile they are at!
                    globalEntities[i].CurrentCollisionTile = this;

                    entities.Add(globalEntities[i]);

                    // Add this entity to 8 surrounding boxes (relative to top left corner)
                    AddAdjacent(globalEntities[i]);
                }
                else
                {
                    continue;
                }
            }
        }