Esempio n. 1
0
		public CardDisplay(GraphicsDevice GraphDev, int Height, int Width, TextureFont Font) : base(GraphDev, Height, Width) {
			this.OpenEffect = DisplayEffect.Fade;
			this.CloseEffect = DisplayEffect.Fade;
			this.BackgroundColor = new Color(255, 255, 255, 0);
			cFont = Font;

			cIsFullCard = true;
		}
        /// <summary>
        /// Initialize a new instance of the class by using a previously prepared texture font
        /// </summary>
        /// <param name="GraphicsDev">Connection to the Graphics device</param>
        /// <param name="ImageFont">Texture font object to use when drawing the text</param>
        /// <param name="Region">Region on the screen to draw the console</param>
        public GameConsole(GraphicsDevice GraphicsDev, TextureFont ImageFont, Rectangle Region) : base(GraphicsDev, null, Region)
        {
            cFontColor      = new Color(Color.LightBlue, 1.0f);
            BackgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.75f);

            cFont = ImageFont;

            Initialize();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MDLN.MGTools.GameConsole"/> class.
        /// </summary>
        /// <param name="GraphicsDev">Connection to the Graphics device</param>
        /// <param name="ContentMgr">Connection to the content manager</param>
        /// <param name="FontFile">Image file container the font texture</param>
        /// <param name="Region">Region on the screen to draw the console</param>
        public GameConsole(GraphicsDevice GraphicsDev, ContentManager ContentMgr, string FontFile, Rectangle Region) : base(GraphicsDev, null, Region)
        {
            cFont = new TextureFont();

            cFontColor      = new Color(Color.LightBlue, 1.0f);
            BackgroundColor = new Color(0.1f, 0.5f, 0.5f, 0.75f);

            //cFont.FontTexture = ContentMgr.Load<Texture2D>(FontFile);
            cFont.FontTexture = Texture2D.FromStream(GraphicsDev, new FileStream(FontFile, FileMode.Open));

            Initialize();
        }
Esempio n. 4
0
		protected override void LoadContent() {
			cDrawBatch = new SpriteBatch(cGraphDevMgr.GraphicsDevice);

			cSolidTexture = new Texture2D(cGraphDevMgr.GraphicsDevice, 1, 1);
			//cSolidTexture.SetData (new[] { new Color(255, 255, 255, 100) });
			//cSolidTexture.SetData (new[] { new Color(0, 0, 0, 100) });
			cSolidTexture.SetData (new[] { Color.White });

			foreach (Textures CurrTexture in Enum.GetValues(typeof(Textures))) {
				cTextureDict.Add(CurrTexture, Content.Load<Texture2D>(Tools.Tools.GetEnumDescriptionAttribute(CurrTexture)));
			}

			cShader = Content.Load<Effect>("ShaderEffect");
			cShipShader = Content.Load<Effect>("BumpMap");
			cShipShader.Parameters["NormalMap"].SetValue(cTextureDict[Textures.ShipNormal]);

			cFont = new TextureFont(cTextureDict[Textures.Font]);
			cDevConsole = new MDLN.MGTools.GameConsole(cGraphDevMgr.GraphicsDevice, Content, "Font.png", 0, 0, cGraphDevMgr.GraphicsDevice.Viewport.Bounds.Width, cGraphDevMgr.GraphicsDevice.Viewport.Bounds.Height / 2);
			cDevConsole.CommandSent += CommandSentEventHandler;
			cDevConsole.OpenEffect = DisplayEffect.SlideDown;
			cDevConsole.CloseEffect = DisplayEffect.SlideUp;

			cPlayerShip = new Ship(cGraphDevMgr.GraphicsDevice, 50);
			cPlayerShip.BackgroundColor = new Color(100, 100, 100, 0); //Set background completely transparent
			cPlayerShip.ShipTexture = cTextureDict[Textures.Ship];
			cPlayerShip.Visible = true;
			cPlayerShip.Top = cGraphDevMgr.GraphicsDevice.Viewport.Bounds.Height / 2;
			cPlayerShip.Left = cGraphDevMgr.GraphicsDevice.Viewport.Bounds.Width / 2;
			//cPlayerShip.ImageInitialAngle = 1.570796f; //Offset for image pointing up instead of right
			cPlayerShip.MouseRotate = true;

			cPlayerBullets = new ParticleEngine2D(cGraphDevMgr.GraphicsDevice);
			cPlayerBullets.DrawBlendingMode = BlendState.Additive;
			cPlayerBullets.ShaderEffect = cShader;

			cEnemyBullets = new ParticleEngine2D(cGraphDevMgr.GraphicsDevice);
			cEnemyBullets.DrawBlendingMode = BlendState.Additive;

			cAsteroids = new ParticleEngine2D(cGraphDevMgr.GraphicsDevice);
			cAsteroids.WrapScreenEdges = true;

			cUFOs = new ParticleEngine2D(cGraphDevMgr.GraphicsDevice);
			//cUFOs.ShaderEffect = cShipShader;
			cUFOs.WrapScreenEdges = true;

			cSparkles = new ParticleEngine2D(cGraphDevMgr.GraphicsDevice);
			cSparkles.DrawBlendingMode = BlendState.Additive;
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="MDLN.MGTools.GameConsole"/> class.
		/// </summary>
		/// <param name="GraphicsDev">Connection to the Graphics device</param>
		/// <param name="ContentMgr">Connection to the content manager</param>
		/// <param name="FontFile">Image file container the font texture</param>
		/// <param name="Region">Region on the screen to draw the console</param>
		public GameConsole(GraphicsDevice GraphicsDev, ContentManager ContentMgr, string FontFile, Rectangle Region) : base(GraphicsDev, null, Region) {
			cFont = new TextureFont();

			cFontColor = new Color(Color.LightBlue, 1.0f);
			BackgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.75f);

			cFont.FontTexture = ContentMgr.Load<Texture2D>(FontFile);

			cMaxLines = (ClientRegion.Height / cFont.CharacterHeight) - 1; //Remove 1 line for the command input

			cPriorKeys = new KeyboardState();

			cCommandHist = new Queue<string>();
			cHistCtr = 0;

			cCommand = "> ";
			cLines = new List<string>();

			AccessKey = Keys.OemTilde;
			UseAccessKey = false;
		}
Esempio n. 6
0
		protected override void LoadContent() {
			Rectangle ButtonArea = new Rectangle();
			int MiniCardHeight, MiniCardWidth;

			Content.RootDirectory = INTERFACECONTENTDIR;

			foreach (Textures CurrTexture in Enum.GetValues(typeof(Textures))) {
				cTextureDict.Add(CurrTexture, Content.Load<Texture2D>(Tools.Tools.GetEnumDescriptionAttribute(CurrTexture)));
			}

			cFont = new TextureFont(cTextureDict[Textures.Font]);

			ButtonArea.Width = (int)(cGraphDevMgr.GraphicsDevice.Viewport.Width * BUTTONWIDTHPERCENT);
			ButtonArea.Height = (cGraphDevMgr.GraphicsDevice.Viewport.Height - Enum.GetValues(typeof(MenuButtons)).Length) / Enum.GetValues(typeof(MenuButtons)).Length;
			ButtonArea.X = cGraphDevMgr.GraphicsDevice.Viewport.Width - ButtonArea.Width;
			ButtonArea.Y = 0;
			foreach (MenuButtons CurrBtn in Enum.GetValues(typeof(MenuButtons))) {
				cMenuBtns.Add(CurrBtn, new Button(cGraphDevMgr.GraphicsDevice, null, ButtonArea.Y, ButtonArea.X, ButtonArea.Height, ButtonArea.Width));
				cMenuBtns[CurrBtn].Text = Tools.Tools.GetEnumDescriptionAttribute(CurrBtn);
				cMenuBtns[CurrBtn].Font = cFont;
				cMenuBtns[CurrBtn].Visible = true;
				cMenuBtns[CurrBtn].BackgroundColor = Color.Navy;
				cMenuBtns[CurrBtn].FontColor = Color.AntiqueWhite;

				ButtonArea.Y += ButtonArea.Height + 1;
			}

			cMenuBtns[MenuButtons.Menu].Click += new ClickEvent(MenuClick);
			cMenuBtns[MenuButtons.OpenDoor].Click += new ClickEvent(OpenDoorClick);
			cMenuBtns[MenuButtons.DrawMonster].Click += new ClickEvent(SpawnMonsterClick);
			cMenuBtns[MenuButtons.Abilities].Click += new ClickEvent(AbilitiesClick);
			cMenuBtns[MenuButtons.Treasure].Click += new ClickEvent(TreasureClick);

			cFullCardFrame = new FullCardPanel(cGraphDevMgr.GraphicsDevice, cGraphDevMgr.GraphicsDevice.Viewport.Height, (int)(cGraphDevMgr.GraphicsDevice.Viewport.Width / 3));
			cFullCardFrame.BackgroundColor = Color.DarkViolet;
			cFullCardFrame.Font = cFont;

			cDevConsole = new GameConsole(cGraphDevMgr.GraphicsDevice, Content, "Font.png", cGraphDevMgr.GraphicsDevice.Viewport.Width, cGraphDevMgr.GraphicsDevice.Viewport.Height / 2);
			cDevConsole.AccessKey = Keys.OemTilde;
			cDevConsole.UseAccessKey = true;
			cDevConsole.OpenEffect = DisplayEffect.SlideDown;
			cDevConsole.CloseEffect = DisplayEffect.SlideUp;
			cDevConsole.CommandSent += new CommandSentEventHandler(CommandEvent);

			cDevConsole.AddText(String.Format("Viewport Height={0} Width={1}", cGraphDevMgr.GraphicsDevice.Viewport.Height, cGraphDevMgr.GraphicsDevice.Viewport.Width));

			MiniCardHeight = (int)(((cGraphDevMgr.GraphicsDevice.Viewport.Height - 10) / 3) - 10);
			MiniCardWidth = (int)(200f * ((float)MiniCardHeight / 175f));

			for (int Ctr = 0; Ctr < 3; Ctr++) {
				cCardsInPlay.Add(new CardMini(cGraphDevMgr.GraphicsDevice, MiniCardHeight, MiniCardWidth));
				cCardsInPlay[Ctr].Font = cFont;
				cCardsInPlay[Ctr].FontColor = Color.DarkSlateGray;
				cCardsInPlay[Ctr].Visible = true;
				cCardsInPlay[Ctr].BackgroundColor = new Color(0, 0, 0, 0);
				cCardsInPlay[Ctr].Top = 3;
				cCardsInPlay[Ctr].Left = 3 + (Ctr * (MiniCardWidth + 3));
				cCardsInPlay[Ctr].Click += new ClickEvent(CardInPlayClick);
			}

			LoadMonsterDeck(DECKXMLFILE);
		}
Esempio n. 7
0
		/// <summary>
		/// Load all external content files that are needed
		/// </summary>
		protected override void LoadContent() {
			TextureFont Font;

			Content.RootDirectory = INTERFACECONTENTDIR;

			Font = new TextureFont(Content.Load<Texture2D>("Font.png"));

			try {
				cDevConsole = new GameConsole(cGraphDevMgr.GraphicsDevice, Content, "Font.png", cGraphDevMgr.GraphicsDevice.Viewport.Width, cGraphDevMgr.GraphicsDevice.Viewport.Height / 2);
				cDevConsole.AccessKey = Keys.OemTilde;
				cDevConsole.UseAccessKey = true;
				cDevConsole.OpenEffect = DisplayEffect.SlideDown;
				cDevConsole.CloseEffect = DisplayEffect.SlideUp;
				cDevConsole.CommandSent += new CommandSentEventHandler(CommandEvent);
			} catch (Exception ExErr) {
				System.Windows.Forms.MessageBox.Show("Failed to initialize console: " + ExErr.GetType().ToString() + " - " + ExErr.Message);
				Exit();
				return;
			}

			cDevConsole.AddText(String.Format("Viewport Height={0} Width={1}", cGraphDevMgr.GraphicsDevice.Viewport.Height, cGraphDevMgr.GraphicsDevice.Viewport.Width));

			//Build card deck frames
			cAOFrame = new DeckFrame(cGraphDevMgr.GraphicsDevice, cGraphDevMgr.GraphicsDevice.Viewport.Height, cGraphDevMgr.GraphicsDevice.Viewport.Width / 2);
			cAOFrame.Visible = true;
			cAOFrame.CloseEffect = DisplayEffect.SlideUp;
			cAOFrame.OpenEffect = DisplayEffect.SlideDown;
			cAOFrame.Font = Font;
			cAOFrame.MaxCardsShown = 1;

			cOLFrame = new DeckFrame(cGraphDevMgr.GraphicsDevice, cGraphDevMgr.GraphicsDevice.Viewport.Height, cGraphDevMgr.GraphicsDevice.Viewport.Width / 2);
			cOLFrame.Left = cGraphDevMgr.GraphicsDevice.Viewport.Width / 2;
			cOLFrame.Visible = true;
			cOLFrame.CloseEffect = DisplayEffect.SlideUp;
			cOLFrame.OpenEffect = DisplayEffect.SlideDown;
			cOLFrame.Font = Font;
			cOLFrame.CardClick += OLCardClickedHandler;
			
			//build config frame
			cOpenConfig = new Button(cGraphDevMgr.GraphicsDevice, null, 0, 0, 100, 100);
			cOpenConfig.Font = Font;
			cOpenConfig.FontColor = new Color(0.1f, 0.1f, 0.1f, 1.0f);
			cOpenConfig.BackgroundColor = new Color(0.7f, 0.7f, 0.7f, 0.7f);
			cOpenConfig.Text = "Config";
			cOpenConfig.Visible = true;
			cOpenConfig.Click += ConfigClickHandler;

			cOLConfigFrame = new OverlordDecksFrame(cGraphDevMgr.GraphicsDevice, cGraphDevMgr.GraphicsDevice.Viewport.Height, cGraphDevMgr.GraphicsDevice.Viewport.Width);
			cOLConfigFrame.Visible = false;
			cOLConfigFrame.OpenEffect = DisplayEffect.SlideUp;
			cOLConfigFrame.CloseEffect = DisplayEffect.SlideDown;
			cOLConfigFrame.Font = Font;

			//Load config files
			cDevConsole.AddText(LoadGameDecks(Content, INTERFACECONTENTDIR + Path.DirectorySeparatorChar + "AOCardsList.xml"));

			cAOFrame.ShuffleCompleteDeck(true, false);
			cAOFrame.SelectRandomCardBack();
			cOLFrame.ShuffleCompleteDeck(true, false);
			cOLFrame.SelectRandomCardBack();

			cOLConfigFrame.SetIconImageSet(cIconImages);
		}
 /// <summary>
 /// Initialize a new instance of the class by using a previously prepared texture font
 /// </summary>
 /// <param name="GraphicsDev">Connection to the Graphics device</param>
 /// <param name="ImageFont">Texture font object to use when drawing the text</param>
 /// <param name="Width">Width of the console on screen</param>
 /// <param name="Height">Height of the console on screen</param>
 public GameConsole(GraphicsDevice GraphicsDev, TextureFont ImageFont, int Width, int Height) : this(GraphicsDev, ImageFont, new Rectangle(0, 0, Width, Height))
 {
 }
Esempio n. 9
0
		public void RenderFullCard(Rectangle DrawRegion, Color ImageTint, Color FontColor, SpriteBatch Draw, TextureFont Font) {
			Vector2 TitleOrigin, DescOrigin, ComStatOrigin;
			int TitleHeight, DescHeight, ComStatHeight;
			Rectangle ImageRegion, IconRegion;

			//Calculate dimensions of the parts of the card
			TitleOrigin.X = (DrawRegion.Width * FULLMARGINLEFTRIGHTPERCENT) + DrawRegion.X;
			TitleOrigin.Y = (DrawRegion.Height * FULLTITLETOPPERCENT) + DrawRegion.Y;
			TitleHeight = (int)(DrawRegion.Height * FULLTITLEHEIGHTPERCENT);

			DescOrigin.X = TitleOrigin.X;
			DescOrigin.Y = (DrawRegion.Height * FULLDESCTOPPERCENT) + DrawRegion.Y;
			DescHeight = (int)(DrawRegion.Height * FULLDESCTEXTHEIGHTPERCENT);

			ComStatOrigin.X = (DrawRegion.Width * FULLCOMBATSTATSLEFTPERCENT) + DrawRegion.X;
			ComStatOrigin.Y = DrawRegion.Height - (DrawRegion.Height * FULLCOMBATSTATSHEIGHT) - (DrawRegion.Height * FULLMARGINTOPBOTTOMPERCENT) + DrawRegion.Y;
			ComStatHeight = (int)(DrawRegion.Height * FULLCOMBATSTATSHEIGHT);

			ImageRegion.X = (int)TitleOrigin.X;
			ImageRegion.Y = (int)(DrawRegion.Height * FULLMARGINTOPBOTTOMPERCENT) + DrawRegion.Y;
			ImageRegion.Width = DrawRegion.Width - (int)(DrawRegion.Width * FULLMARGINLEFTRIGHTPERCENT * 2);
			ImageRegion.Height = (int)(DrawRegion.Height * FULLIMAGEHEIGHTPERCENT);

			IconRegion.X = (int)ComStatOrigin.X;
			IconRegion.Y = (int)ComStatOrigin.Y;
			IconRegion.Width = ComStatHeight;
			IconRegion.Height = ComStatHeight;

			//Draw the card
			Draw.Draw(cBackground, DrawRegion, cBackground.Bounds, ImageTint);
			Draw.Draw(cImage, ImageRegion, cImage.Bounds, ImageTint);
			Draw.Draw(cHeartIcon, IconRegion, cHeartIcon.Bounds, ImageTint);
			IconRegion.X += ComStatHeight * 5;
			Draw.Draw(cSwordIcon, IconRegion, cSwordIcon.Bounds, ImageTint);

			Font.WriteText(Draw, cTitle, TitleHeight, (int)TitleOrigin.Y, (int)TitleOrigin.X, FontColor);
			Font.WriteText(Draw, cDesc, DescHeight, (int)DescOrigin.Y, (int)DescOrigin.X, FontColor);
			Font.WriteText(Draw, " " + cCurrHealth + "/" + cMaxHealth + "  " + cAttack, ComStatHeight, (int)ComStatOrigin.Y, (int)ComStatOrigin.X, FontColor);
		}