/* * MatrixLetter.cs * Authors: * Copyright (c) 2007-2008 Cornell University This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System.Collections.Generic; using Microsoft.Xna.Framework.Graphics; namespace StarJack { class MatrixLetter:TextEntity { public static float blurDelay = 33.0f; public static float LifeTime = 105.0f; private int curBlur = 0; private List mBlur; private List mLifeTimes; public override int Height { get { return base.Height; } set { base.Height = value; foreach (TextEntity te in mBlur) { te.Height = value ; } } } public override int Width { get { return base.Width; } set { base.Width = value; foreach (TextEntity te in mBlur) { te.Width = value; } } } protected float mElapsed; public MatrixLetter(string text):base(text) { mBlur = new List(); mLifeTimes = new List(); for(int i = 0 ; i <(int)(LifeTime/blurDelay);i++) { mBlur.Add(new TextEntity(text)); mBlur[i].Depth = Room.Depth.UIText; mLifeTimes.Add(0.0f); } mElapsed = 0.0f; } public override void LoadContent(Microsoft.Xna.Framework.Content.ContentManager content) { foreach (TextEntity te in mBlur) { te.LoadContent(content); } base.LoadContent(content); } public override void Update(Microsoft.Xna.Framework.GameTime time) { mElapsed += time.ElapsedGameTime.Milliseconds; if (mElapsed >= blurDelay) { mElapsed = mElapsed - blurDelay; mLifeTimes[curBlur] = LifeTime; mBlur[curBlur].X = this.X; mBlur[curBlur].Y = this.Y; curBlur++; if (curBlur >= mLifeTimes.Count) { curBlur = 0; } } for (int a = 0; a < mBlur.Count; a++) { if (mLifeTimes[a] > 0) { mLifeTimes[a] -= time.ElapsedGameTime.Milliseconds; if (mLifeTimes[a] < 0) { mLifeTimes[a] = 0.0f; } } } base.Update(time); } public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch pSpriteBatch) { for (int a = 0; a < mBlur.Count; a++) { if (mLifeTimes[a] > 0) { mBlur[a].Color = new Color(mShadowColor.R, mShadowColor.G, mShadowColor.B, (byte)(255 * (mLifeTimes[a]) / LifeTime)); mBlur[a].Draw(pSpriteBatch); } } base.Draw(pSpriteBatch); } } }