Beispiel #1
0
        public Rectangle OnBeginRender()
        {
            double elapsed = this.m_Dispose.Elapsed;

            if (elapsed >= (double)this.m_SolidDuration + 1.0)
            {
                this.Visible = false;
                MessageManager.Remove((IMessage)this);
                return(this.m_ImageRect = this.m_Rectangle = Rectangle.Empty);
            }
            if (elapsed >= (double)this.m_SolidDuration)
            {
                this.Alpha = (float)(1.0 - (elapsed - (double)this.m_SolidDuration));
            }
            if (this.m_Owner.MessageFrame == Renderer.m_ActFrames)
            {
                this.m_Owner.MessageY -= this.Height + 2;
                this.X       = this.m_Owner.MessageX - this.Width / 2;
                this.Y       = this.m_Owner.MessageY;
                this.Visible = true;
            }
            else
            {
                this.Visible = false;
            }
            if (this.m_Owner is Item && !((Agent)this.m_Owner).InWorld)
            {
                if (this.X < 2)
                {
                    this.X = 2;
                }
                else if (this.X + this.Width > Engine.ScreenWidth - 2)
                {
                    this.X = Engine.ScreenWidth - 2 - this.Width;
                }
                if (this.Y < 2)
                {
                    this.Y = 2;
                }
                else if (this.Y + this.Height > Engine.ScreenHeight - 2)
                {
                    this.Y = Engine.ScreenHeight - 2 - this.Height;
                }
            }
            else
            {
                if (this.X < Engine.GameX + 2)
                {
                    this.X = Engine.GameX + 2;
                }
                else if (this.X + this.Width > Engine.GameX + Engine.GameWidth - 2)
                {
                    this.X = Engine.GameX + Engine.GameWidth - 2 - this.Width;
                }
                if (this.Y < Engine.GameY + 2)
                {
                    this.Y = Engine.GameY + 2;
                }
                else if (this.Y + this.Height > Engine.GameY + Engine.GameHeight - 2)
                {
                    this.Y = Engine.GameY + Engine.GameHeight - 2 - this.Height;
                }
            }
            this.m_Rectangle.X      = this.X;
            this.m_Rectangle.Y      = this.Y;
            this.m_Rectangle.Width  = this.Width;
            this.m_Rectangle.Height = this.Height;
            this.m_ImageRect.X      = this.X + this.Image.xMin;
            this.m_ImageRect.Y      = this.Y + this.Image.yMin;
            this.m_ImageRect.Width  = this.Image.xMax - this.Image.xMin + 1;
            this.m_ImageRect.Height = this.Image.yMax - this.Image.yMin + 1;
            return(this.m_Rectangle);
        }