示例#1
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);
		}
示例#2
0
        /// <summary>
        /// Called once at start to load content
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            background = Content.Load <Texture2D>("DiceTexture.png");
            CardImage  = Content.Load <Texture2D>("Fighter.png");
            CardBack   = Content.Load <Texture2D>("CardBack.png");
            Assassin   = Content.Load <Texture2D>("Assassin.png");
            Archer     = Content.Load <Texture2D>("Archer.png");
            cShip      = Content.Load <Texture2D>("Ship.png");

            cShipDir     = ShipDirection.Straight;
            cShipUseKeys = true;
            cShipShow    = false;

            ConsoleRect = new Texture2D(graphics.GraphicsDevice, 1, 1);
            ConsoleRect.SetData(new[] { Color.DarkGray });

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

            TestCont                = new Container(GraphicsDevice, background, 20, 250, 100, 200);
            TestCont.OpenEffect     = DisplayEffect.SlideRight;
            TestCont.CloseEffect    = DisplayEffect.SlideLeft;
            TestCont.EffectDuration = 500;

            TestCard                 = new CardDisplay(GraphicsDevice, 350, 250, cFont);
            TestCard.Top             = 105;
            TestCard.Left            = 325;
            TestCard.SendMouseEvents = true;
            TestCard.MouseDown      += new ContainerMouseButtonEventHandler(MouseLeftDown);

            cCard            = new CardInfo(CardType.Monster);
            cCard.Background = Content.Load <Texture2D>("CardBase.png");
            cCard.Image      = CardImage;
            cCard.Title      = "Shield Maiden";

            List <string> Lines = new List <string>();

            Lines.Add("Health: 5");
            Lines.Add("Attack: 3");
            Lines.Add("");
            Lines.Add("Women of Rohan");
            cCard.Description = Lines;
            cCard.Changed     = true;

            TestCard.Card = cCard;

            NestedCont = new Container(GraphicsDevice, null, 350, 600, 100, 100);
            NestedCont.BackgroundColor = Color.BurlyWood;
            NestedCont.Visible         = true;

            cTextTest = new TextBox(GraphicsDevice, null, GraphicsDevice.Viewport.Height - 150, GraphicsDevice.Viewport.Width - 200, 125, 175);
            cTextTest.BackgroundColor = Color.CornflowerBlue;
            cTextTest.FontColor       = Color.Bisque;
            cTextTest.Font            = cFont;
            cTextTest.Visible         = true;

            DevConsole.AddText("Viewport Bounds: X=" + GraphicsDevice.Viewport.Bounds.X + " Y=" + GraphicsDevice.Viewport.Bounds.Y + " Width=" + GraphicsDevice.Viewport.Bounds.Width + " Height=" + GraphicsDevice.Viewport.Bounds.Height);
        }
示例#3
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);
		}
示例#4
0
        private void CommandSentEventHandler(object Sender, string Command)
        {
            if (Tools.RegEx.QuickTest(Command, "^(quit|exit)$") == true)
            {
                Exit();
            }
            else if (Tools.RegEx.QuickTest(Command, "^ship *stop$") == true)
            {
                cPlayerShip.cSpeedX = 0;
                cPlayerShip.cSpeedY = 0;
                cDevConsole.AddText("Ship speed set to 0");
            }
            else if (Tools.RegEx.QuickTest(Command, "^ship *center$") == true)
            {
                cPlayerShip.Top  = (cGraphDevMgr.GraphicsDevice.Viewport.Bounds.Height) / 2 - (cPlayerShip.Height / 2);
                cPlayerShip.Left = (cGraphDevMgr.GraphicsDevice.Viewport.Bounds.Width) / 2 - (cPlayerShip.Width / 2);
                cDevConsole.AddText("Ship position set to [X=" + cPlayerShip.Left + ", Y=" + cPlayerShip.Width + "]");
            }
            else if (Tools.RegEx.QuickTest(Command, "^ship *state$") == true)
            {
                cDevConsole.AddText("Ship Position [X=" + cPlayerShip.Top + ", Y=" + cPlayerShip.Left + "]");
                cDevConsole.AddText("     Speed X=" + cPlayerShip.cSpeedX + " Y=" + cPlayerShip.cSpeedY);
                cDevConsole.AddText("     Size Width=" + cPlayerShip.Width + " Height=" + cPlayerShip.Height);
            }
            else if (Tools.RegEx.QuickTest(Command, "^fire *spread$") == true)
            {
                cDevConsole.AddText("Firing Spread");
                cPlayerBullets.AddParticle(cTextureDict[Textures.Bullet], cPlayerShip.Top + (cPlayerShip.Height / 2) - 10, cPlayerShip.Left + (cPlayerShip.Height / 2) - 10, 20, 20, cPlayerShip.cRotation - 0.628f, 10, Color.White);
                cPlayerBullets.AddParticle(cTextureDict[Textures.Bullet], cPlayerShip.Top + (cPlayerShip.Height / 2) - 10, cPlayerShip.Left + (cPlayerShip.Height / 2) - 10, 20, 20, cPlayerShip.cRotation - 0.314f, 10, Color.White);
                cPlayerBullets.AddParticle(cTextureDict[Textures.Bullet], cPlayerShip.Top + (cPlayerShip.Height / 2) - 10, cPlayerShip.Left + (cPlayerShip.Height / 2) - 10, 20, 20, cPlayerShip.cRotation, 10, Color.White);
                cPlayerBullets.AddParticle(cTextureDict[Textures.Bullet], cPlayerShip.Top + (cPlayerShip.Height / 2) - 10, cPlayerShip.Left + (cPlayerShip.Height / 2) - 10, 20, 20, cPlayerShip.cRotation + 0.314f, 10, Color.White);
                cPlayerBullets.AddParticle(cTextureDict[Textures.Bullet], cPlayerShip.Top + (cPlayerShip.Height / 2) - 10, cPlayerShip.Left + (cPlayerShip.Height / 2) - 10, 20, 20, cPlayerShip.cRotation + 0.628f, 10, Color.White);
            }
            else if (Tools.RegEx.QuickTest(Command, "^fire *multi-?(ple|shot)$") == true)
            {
                cDevConsole.AddText("Firing Multi-Shot");
                Vector2 BulletOrigin, BulletOffset;
                BulletOrigin = MGMath.CalculateXYMagnitude(-1 * cPlayerShip.cRotation, cPlayerShip.Width / 4);
                BulletOffset = MGMath.CalculateXYMagnitude(-1 * cPlayerShip.cRotation + 1.570796f, cPlayerShip.Width / 5);

                //Adjust it so that it's relative to the top left screen corner
                BulletOrigin.Y += cPlayerShip.Top + (cPlayerShip.Height / 2);
                BulletOrigin.X += cPlayerShip.Left + (cPlayerShip.Height / 2);

                cPlayerBullets.AddParticle(cTextureDict[Textures.Bullet], BulletOrigin.Y + (BulletOffset.Y * 2) - 10, BulletOrigin.X + (BulletOffset.X * 2) - 10, 20, 20, cPlayerShip.cRotation, 15, Color.White);
                cPlayerBullets.AddParticle(cTextureDict[Textures.Bullet], BulletOrigin.Y + BulletOffset.Y - 10, BulletOrigin.X + BulletOffset.X - 10, 20, 20, cPlayerShip.cRotation, 15, Color.White);
                cPlayerBullets.AddParticle(cTextureDict[Textures.Bullet], BulletOrigin.Y - 10, BulletOrigin.X - 10, 20, 20, cPlayerShip.cRotation, 15, Color.White);
                cPlayerBullets.AddParticle(cTextureDict[Textures.Bullet], BulletOrigin.Y - BulletOffset.Y - 10, BulletOrigin.X - BulletOffset.X - 10, 20, 20, cPlayerShip.cRotation, 15, Color.White);
                cPlayerBullets.AddParticle(cTextureDict[Textures.Bullet], BulletOrigin.Y - (BulletOffset.Y * 2) - 10, BulletOrigin.X - (BulletOffset.X * 2) - 10, 20, 20, cPlayerShip.cRotation, 15, Color.White);
            }
            else if (Tools.RegEx.QuickTest(Command, "^new *asteroid$") == true)
            {
                cDevConsole.AddText("Spawning Asteroid");
                cAsteroids.AddParticle(cTextureDict[Textures.Asteroid], cPlayerShip.Top + (cPlayerShip.Height / 2) - 50, cPlayerShip.Left + (cPlayerShip.Height / 2) - 50, 100, 100, cPlayerShip.cRotation - 0.628f, 2, Color.White);
            }
            else if (Tools.RegEx.QuickTest(Command, @"^\s*ast(eroid)?\s*count\s*?$") == true)
            {
                cDevConsole.AddText("Current Asteroid Count: " + cAsteroids.ParticleList.Count);
            }
            else if (Tools.RegEx.QuickTest(Command, @"^\s*ast(eroid)?\s*clear$") == true)
            {
                cDevConsole.AddText("Destroying all asteroids");
                cAsteroids.ParticleList.Clear();
            }
            else if (Tools.RegEx.QuickTest(Command, @"^\s*mouse\s*turn\s*=\s*(on|true|enable|1)\s*$") == true)
            {
                cDevConsole.AddText("Using mouse position to rotate ship");
                cPlayerShip.MouseRotate = true;
            }
            else if (Tools.RegEx.QuickTest(Command, @"^\s*mouse\s*turn\s*=\s*(off|false|disable|0)\s*$") == true)
            {
                cDevConsole.AddText("Using arrow keys to rotate ship");
                cPlayerShip.MouseRotate = false;
            }
            else if (Tools.RegEx.QuickTest(Command, @"^\s*(spawn|new)\s*hunter\s*$") == true)
            {
                cDevConsole.AddText("Spawning new hunter UFO");
                Vector2 StartPos = new Vector2(-50, -50);
                CreateNewHunter(100, StartPos);
            }
            else if (Tools.RegEx.QuickTest(Command, @"^\s*(sparkles|particles)\s*$") == true)
            {
                Particle2D NewSparkle;
                Vector2    Speed;

                cDevConsole.AddText("Particle burst on player ship");

                for (int Ctr = 0; Ctr < 25; Ctr++)
                {
                    NewSparkle = new Particle2D(cGraphDevMgr.GraphicsDevice);

                    NewSparkle.AlphaFade  = true;
                    NewSparkle.TimeToLive = 100 + (cRandom.NextDouble() * 1000);
                    NewSparkle.Height     = 10;
                    NewSparkle.Width      = 10;
                    NewSparkle.TopLeft.X  = cPlayerShip.Left + (cPlayerShip.Width / 2);
                    NewSparkle.TopLeft.Y  = cPlayerShip.Top + (cPlayerShip.Height / 2);
                    NewSparkle.Image      = cTextureDict[Textures.Bullet];

                    NewSparkle.Rotation = (float)(cRandom.NextDouble() * 6.2f);
                    Speed             = MGMath.CalculateXYMagnitude(NewSparkle.Rotation, (float)(cRandom.NextDouble() * 5));
                    NewSparkle.SpeedX = Speed.X;
                    NewSparkle.SpeedY = Speed.Y;

                    NewSparkle.Tint = Color.White;

                    cSparkles.AddParticle(NewSparkle);
                }
            }
            else if (Tools.RegEx.QuickTest(Command, @"^\s*(headlight|flashlight|dark)\s*=\s*(1|true|enable)\s*$") == true)
            {
                cDevConsole.AddText("Headlight mode enabled.");
                cHeadlightMode = true;
            }
            else if (Tools.RegEx.QuickTest(Command, @"^\s*(headlight|flashlight|dark)\s*=\s*(0|false|disable)\s*$") == true)
            {
                cDevConsole.AddText("Headlight mode disabled.");
                cHeadlightMode = false;
            }
            else if (Tools.RegEx.QuickTest(Command, @"^\s*stats\s*=\s*(1|true|enable|on)\s*$") == true)
            {
                cDevConsole.AddText("Stats enabled.");
                cShowStats = true;
            }
            else if (Tools.RegEx.QuickTest(Command, @"^\s*stats\s*=\s*(0|false|disable|off)\s*$") == true)
            {
                cDevConsole.AddText("Stats disabled.");
                cShowStats = false;
            }
            else
            {
                cDevConsole.AddText("Unrecognized command: " + Command);
            }
        }