コード例 #1
0
 internal void Remove()
 {
     if (postRender)
     {
         PostRenderManager.Remove(this);
     }
     else
     {
         DrawingManager.Remove(this);
     }
 }
コード例 #2
0
        public ParticleEmitter2D(string id, ParticleEmitterInfo info,
                                 int drawLayer, bool postDraw)
            : base(id)
        {
            this.drawLayer = drawLayer;

            if (postDraw)
            {
                PostRenderManager.Add(this);
            }
            else
            {
                DrawingManager.Add(this);
            }

            attachments = new AttachmentPool(info.Attachments);

            if (info.CycleType != null)
            {
                object obj = AssemblyManager.CreateInstance(info.CycleType);

                if (obj != null)
                {
                    spawnCycle              = obj as IntervalCycle;
                    spawnCycle.OnSpawn     += new OnSpawnEvent(GenerateParticles);
                    spawnCycle.OnCompleted += new OnSpawningCompleteEvent(OnCompletedSpawning);
                }
            }

            if (info.EmittionType != null)
            {
                object obj = AssemblyManager.CreateInstance(info.EmittionType);

                if (obj != null)
                {
                    emittionType = obj as IEmitter2D;
                }
            }

            if (info.RenderType != null)
            {
                object obj = AssemblyManager.CreateInstance(info.RenderType);

                if (obj != null)
                {
                    renderMethod = obj as IRenderer2D;
                }
            }

            lifeTime = new FloatRange(info.MinLifeTime, info.MaxLifeTime);
            mass     = new FloatRange(info.MinMass, info.MaxMass);
        }
コード例 #3
0
        public override void Destroy()
        {
            if (postRender)
            {
                PostRenderManager.Remove(this);
            }
            else
            {
                DrawingManager.Remove(this);
            }

            base.Destroy();
        }
コード例 #4
0
ファイル: Sprite.cs プロジェクト: Albert-Bennett/EonEngine
        /// <summary>
        /// Creates a new Sprite.
        /// </summary>
        /// <param name="id">The id of the Sprite.</param>
        /// <param name="drawLayer">The layer to draw the Sprite on.</param>
        /// <param name="textureFilepath">The filepath of Sprite's texture.</param>
        /// <param name="colour">The colour to draw the Sprite in (Texture map only).</param>
        /// <param name="postRender">Wheather or not this Sprite sholud be post rendered.</param>
        /// <param name="normalMapFilepath">The filepath of the Sprite's normal map.</param>
        /// <param name="distortionMapFilepath">The filepath of the Sprite's distortion map.</param>
        /// <param name="offset">The positional offset of the Sprite.</param>
        /// <param name="scale">The scale of the sprite.</param>
        /// <param name="rotation">The rotation of the Sprite.</param>
        /// <param name="spriteEffect">The particular Sprite effect to be applied to the Sprite.</param>
        public Sprite(string id, int drawLayer, string textureFilepath,
                      Color colour, bool postRender, string normalMapFilepath, string distortionMapFilepath,
                      Vector2 offset, Vector2 scale, float rotation, SpriteEffects spriteEffect)
            : base(id)
        {
            if (drawLayer == -1)
            {
                if (postRender && PostRenderManager.MaximumLayer > 0)
                {
                    drawLayer = PostRenderManager.MaximumLayer;
                }
                else if (DrawingManager.MaximumLayer > 0)
                {
                    drawLayer = DrawingManager.MaximumLayer;
                }
                else
                {
                    drawLayer = 0;
                }
            }

            this.drawLayer = drawLayer;

            this.textureFilepath       = textureFilepath;
            this.normalMapFilepath     = normalMapFilepath;
            this.distortionMapFilepath = distortionMapFilepath;

            this.offset = offset;
            this.scale  = scale;

            this.colour       = colour;
            this.rotation     = rotation;
            this.spriteEffect = spriteEffect;

            if (Common.PreviousScreenResolution != Vector2.One)
            {
                ScreenResolutionChanged();
            }

            this.postRender = postRender;

            if (postRender)
            {
                PostRenderManager.Add(this);
            }
            else
            {
                DrawingManager.Add(this);
            }
        }
コード例 #5
0
        /// <summary>
        /// Creates a new ParticleEmitter.
        /// </summary>
        /// <param name="info">The information file for the ParticleEmitter.</param>
        /// <param name="postRender">Wheather or not Particles should be post rendered.</param>
        /// <param name="drawLayer">The layer to render the Particles on.</param>
        public ParticleEmitter(ParticleEmitterInfo info, bool postRender, int drawLayer)
        {
            this.info       = info;
            this.drawLayer  = drawLayer;
            this.postRender = postRender;

            this.id = info.ID;

            if (postRender)
            {
                PostRenderManager.Add(this);
            }
            else
            {
                DrawingManager.Add(this);
            }
        }
コード例 #6
0
        protected override void Initialize()
        {
            try
            {
                texture = Common.ContentManager.Load <Texture2D>(textureFilepath);
            }
            catch
            {
                throw new NullReferenceException(textureFilepath);
            }

            try
            {
                normalMap = Common.ContentManager.Load <Texture2D>(normalMapFilepath);
            }
            catch
            {
                throw new NullReferenceException(normalMapFilepath);
            }

            try
            {
                distortion = Common.ContentManager.Load <Texture2D>(distortionMapFilepath);
            }
            catch
            {
                throw new NullReferenceException(distortionMapFilepath);
            }

            xAmount = texture.Width / maxColumns;
            yAmount = texture.Height / maxRows;

            sourceRect = new Rectangle(0, 0, xAmount, yAmount);

            if (postRender)
            {
                PostRenderManager.Add(this);
            }
            else
            {
                DrawingManager.Add(this);
            }

            base.Initialize();
        }
コード例 #7
0
        /// <summary>
        /// Creates a new Skeleton.
        /// </summary>
        /// <param name="id">The unique identification
        /// name to give to the Skeleton.</param>
        /// <param name="limbsDeffination">The file that contains the
        /// information about the limbs for the Skeleton.</param>
        /// <param name="drawLayer">The layer to draw the Skeleton on.</param>
        /// <param name="colour">The colour to draw the Skeleton.</param>
        /// <param name="postDraw">Wheather or not the skeleton should
        /// be drawn after everthing else.</param>
        public Skeleton(string id, SkeletonDeff limbsDeffination,
                        int drawLayer, bool postDraw)
            : base(id)
        {
            this.limbsDeff = limbsDeffination;
            this.drawLayer = drawLayer;

            this.postDraw = postDraw;

            if (postDraw)
            {
                PostRenderManager.Add(this);
            }
            else
            {
                DrawingManager.Add(this);
            }
        }
コード例 #8
0
        public void Dispose()
        {
            if (tiles != null)
            {
                tiles.Clear();
                tiles = null;
            }

            renderTiles.Clear();

            if (postRender)
            {
                PostRenderManager.Remove(this);
            }
            else
            {
                DrawingManager.Remove(this);
            }
        }
コード例 #9
0
ファイル: TextItem.cs プロジェクト: Albert-Bennett/EonEngine
        /// <summary>
        /// Creates a new TextItem.
        /// </summary>
        /// <param name="id">The unique ID to give the TextItem.</param>
        /// <param name="drawLayer">The layer to draw the TextItem on.</param>
        /// <param name="text">The text to use in the TextItem.</param>
        /// <param name="fontFilepath">The filepath for the font to be used.</param>
        /// <param name="position">The position of the TextItem.</param>
        /// <param name="colour">The colour to draw the TextItem in.</param>
        /// <param name="rotation">The rotation of the TextItem.</param>
        /// <param name="scale">The scale of the TextItem.</param>
        /// <param name="origin">The point to rotate the TextItem around.</param>
        /// <param name="postRender">Wheather or not the TextItem should be post rendered.</param>
        public TextItem(string id, int drawLayer, string text, string fontFilepath,
                        Vector2 position, Color colour, float rotation, float scale,
                        Vector2 origin, bool postRender)
            : base(id)
        {
            try
            {
                font = Common.ContentManager.Load <SpriteFont>(fontFilepath);
            }
            catch (Exception)
            {
                throw new ArgumentNullException("The font " + fontFilepath + " wasn't found.");
            }

            pos        = position;
            rot        = rotation;
            this.scale = scale;

            this.drawLayer = drawLayer;

            this.text   = text;
            this.origin = origin;
            this.colour = colour;

            if (Common.PreviousScreenResolution != Vector2.One)
            {
                ScreenResolutionChanged();
            }

            this.postRender = postRender;

            if (!postRender)
            {
                DrawingManager.Add(this);
            }
            else
            {
                PostRenderManager.Add(this);
            }
        }
コード例 #10
0
        internal void Initialize(bool postRender, int startCol,
                                 int startRow, int maxCols, int maxRows,
                                 out int colStoppedAt, out int rowStoppedAt, out Vector2 finalPos)
        {
            this.postRender = postRender;

            tiles = new List <Tile>();

            int rowLimit = CalculateRowLimit(maxRows, startRow);

            int[] colLimits = new int[rowLimit];

            int colLimit = 0;

            finalPos = initialPos;

            for (int row = startRow; row < startRow + rowLimit; row++)
            {
                colLimit = CalculateColumnLimit(maxCols, startCol, row);
                colLimits[row - startRow] = colLimit;

                for (int column = startCol; column < startCol + colLimit; column++)
                {
                    int refNum = attachedTo.LayerDeff.Tiles[row, column];

                    if (refNum != -1)
                    {
                        Tile t = new Tile()
                        {
                            Size             = attachedTo.Size,
                            _Position        = finalPos,
                            RefferenceNumber = refNum,
                            Number           = tiles.Count
                        };

                        tiles.Add(t);
                    }

                    finalPos.X += attachedTo.Size.X + attachedTo.Offset.X;
                }

                if (row + 1 < startRow + rowLimit)
                {
                    finalPos.X = initialPos.X;
                }

                finalPos.Y += -attachedTo.Size.Y + attachedTo.Offset.Y;
            }

            rowStoppedAt = startRow + rowLimit;
            colStoppedAt = startCol + CalculateColumnsLimitMax(colLimits);

            int c = CalculateColumnsLimitMax(colLimits);

            bounds = new Rectangle((int)initialPos.X, (int)(initialPos.Y - (c * attachedTo.Size.Y)),
                                   (int)(c * attachedTo.Size.X), (int)(rowLimit * attachedTo.Size.Y));

            if (postRender)
            {
                PostRenderManager.Add(this);
            }
            else
            {
                DrawingManager.Add(this);
            }
        }