From 0eb33286fbe809ecaa018199cb7cb4a97946c866 Mon Sep 17 00:00:00 2001 From: Tom Dooner Date: Mon, 2 May 2011 09:17:59 -0400 Subject: [PATCH] Loadout menu beginnings. --- .../Games/SuperPowerRobots/Battle.cs | 11 ++- .../Games/SuperPowerRobots/Entities/Entity.cs | 3 +- .../SuperPowerRobots/Entities/Projectile.cs | 5 +- .../Games/SuperPowerRobots/LoadOutScreen.cs | 96 +++++++++++++------ .../SuperPowerRobots/Menus/LoadOutMenu.cs | 27 ++++-- .../Menus/MenuDelegates/LoadOutDelegate.cs | 23 +++-- .../Games/SuperPowerRobots/SPRGameScreen.cs | 32 ++++--- .../Games/SuperPowerRobots/Storage/Allies.xml | 6 +- .../SuperPowerRobots/Storage/Battles.xml | 53 +++++----- 9 files changed, 157 insertions(+), 99 deletions(-) diff --git a/Project290/Project290/Games/SuperPowerRobots/Battle.cs b/Project290/Project290/Games/SuperPowerRobots/Battle.cs index 3f7f632..55b684b 100644 --- a/Project290/Project290/Games/SuperPowerRobots/Battle.cs +++ b/Project290/Project290/Games/SuperPowerRobots/Battle.cs @@ -36,6 +36,8 @@ public class Battle public int winReward { get; private set; } + public static string nextAllies = ""; // This will be populated so the user can customize their bot. + public Battle(SPRWorld sprWorld, int botHalfWidth, World world, int currentLevel) { this.sprWorld = sprWorld; @@ -44,7 +46,14 @@ public Battle(SPRWorld sprWorld, int botHalfWidth, World world, int currentLevel xmlDoc = new XmlDocument(); - xmlDoc.Load("Games/SuperPowerRobots/Storage/Allies.xml"); + if (nextAllies == "") + { + xmlDoc.Load("Games/SuperPowerRobots/Storage/Allies.xml"); + } + else + { + xmlDoc.LoadXml(nextAllies); + } //xmlDoc. diff --git a/Project290/Project290/Games/SuperPowerRobots/Entities/Entity.cs b/Project290/Project290/Games/SuperPowerRobots/Entities/Entity.cs index b1221bb..bfe74df 100644 --- a/Project290/Project290/Games/SuperPowerRobots/Entities/Entity.cs +++ b/Project290/Project290/Games/SuperPowerRobots/Entities/Entity.cs @@ -106,7 +106,6 @@ public float GetWidth() public void TakeDamage(float damage) { this.m_health -= damage; - ScoreKeeper.AddScore((int)damage); } public void SetWidth(float width) @@ -142,7 +141,7 @@ public virtual void Update(float dTime) this.Body.Dispose(); } - this.m_SPRWorld.World.ProcessChanges(); // Let's not be ashamed to call this method to cover up our lack of understanding the physics library. + this.m_SPRWorld.World.ProcessChanges(); } public virtual void Draw() diff --git a/Project290/Project290/Games/SuperPowerRobots/Entities/Projectile.cs b/Project290/Project290/Games/SuperPowerRobots/Entities/Projectile.cs index 1d2d0a0..0b7c06c 100644 --- a/Project290/Project290/Games/SuperPowerRobots/Entities/Projectile.cs +++ b/Project290/Project290/Games/SuperPowerRobots/Entities/Projectile.cs @@ -64,7 +64,8 @@ public static bool OnBulletHit(Fixture a, Fixture b, Contact c) m_toRemove.Add(a.Body); return true; } - + if (b.Body.IsBullet) + return true; // If we've gotten this far, b.UserData is an Object Projectile p = (Projectile)a.UserData; @@ -92,6 +93,8 @@ public static bool OnBulletHit(Fixture a, Fixture b, Contact c) } public static bool OnMeleeHit(Fixture a, Fixture b, Contact c) { + if (b.Body.IsBullet) + return true; Projectile p = (Projectile)a.UserData; // If we hit a weapon. if (b.UserData is Weapon) diff --git a/Project290/Project290/Games/SuperPowerRobots/LoadOutScreen.cs b/Project290/Project290/Games/SuperPowerRobots/LoadOutScreen.cs index 621f6c1..7ef62bd 100644 --- a/Project290/Project290/Games/SuperPowerRobots/LoadOutScreen.cs +++ b/Project290/Project290/Games/SuperPowerRobots/LoadOutScreen.cs @@ -16,55 +16,89 @@ using Project290.Inputs; using Project290.Games.SuperPowerRobots.Menus; using Project290.Menus; -using Project290.Games.SuperPowerRobots.Menus.MenuDelegates; - -namespace Project290.Screens +using Project290.Games.SuperPowerRobots.Menus.MenuDelegates; +using Project290.Screens; + +namespace Project290.Games.SuperPowerRobots { /// /// This is a Screen specific for a game (as opposed to title or pause screen). /// - public class LoadOutScreen : Screen - { + public class LoadOutScreen : GameScreen + { private int count; - private int[] weapons; private LoadOutMenu menu; private Vector2 textDrawPosition; - private Vector2 textDrawOrigin; + private Vector2 textDrawOrigin; + + private static string[] weapons; + private string yWeapons; + private string xWeapons; + private string bWeapons; + private string aWeapons; + private Bot bot; - public LoadOutScreen(int count, int[] weapons) - : base() - { + public LoadOutScreen(int scoreboardIndex) + : base(scoreboardIndex) + { + weapons = new string[4]; this.menu = new LoadOutMenu( new Vector2(0, -60), new MenuAction[] { - new MenuAction(ActionType.Select, new LoadOutDelegate(count, 0, weapons)), + new MenuAction(ActionType.Select, new LoadOutDelegate(count, "Gun")), }, - 60f, - count, - weapons); + count); + this.menu.position = new Vector2(1920f / 2f, 1080f / 2f); + + Dictionary a = new Dictionary(); + a.Add("Gun", "gun"); + a.Add("Melee", "shield"); + a.Add("Shield", "shield"); + // let's assume certain things are selected... + xWeapons = "Gun"; + yWeapons = "Melee"; + aWeapons = "Gun"; + bWeapons = "Shield"; + + Battle.nextAllies = "\n \n HumanAI\n 500\n 4SideFriendlyRobot\n 400\n 400\n \n " + a[xWeapons] + "\n" + xWeapons + "\n 300\n 10\n \n \n " + a[yWeapons] + "\n " + yWeapons + "\n 300\n 10\n \n \n " + a[aWeapons] + "\n" + aWeapons + "\n 300\n 10\n \n \n " + a[bWeapons] + "\n" + bWeapons + "\n 300\n 10\n \n \n 0\n 0\n\n"; } public override void Update() { - base.Update(); + base.Update(); + this.menu.Update(); + } + public static void save(int count, string weapon) + { + weapons[count] = weapon; + count += 1; + if (count == 4) + { + // gtfo. + } + } + public override void Draw() + { + base.Draw(); + Drawer.DrawRectangle( + new Rectangle(0, 0, 1920, 1080), + 1920, + 0f, + Color.Black); + Drawer.DrawString( + FontStatic.Get("defaultFont"), + "Please Select Your Weapon For Slot #" + count, + new Vector2(300, 100), + Color.White, + 0f, + this.textDrawOrigin, + 0.35f, + SpriteEffects.None, + 1f); + this.menu.Draw(); + } - - public override void Draw() - { - base.Draw(); - /*Drawer.Draw( - TextureStatic.Get(), - new Vector2(1920f / 2f, 1080f / 2f), - null, - Color.White, - 0f, - TextureStatic.GetOrigin(), - 1f, - SpriteEffects.None, - 0.5f);*/ - } - } } diff --git a/Project290/Project290/Games/SuperPowerRobots/Menus/LoadOutMenu.cs b/Project290/Project290/Games/SuperPowerRobots/Menus/LoadOutMenu.cs index 0ef32e8..1bdf808 100644 --- a/Project290/Project290/Games/SuperPowerRobots/Menus/LoadOutMenu.cs +++ b/Project290/Project290/Games/SuperPowerRobots/Menus/LoadOutMenu.cs @@ -11,34 +11,43 @@ namespace Project290.Games.SuperPowerRobots.Menus { class LoadOutMenu : Menu { - public LoadOutMenu(Vector2 position, MenuAction[] actions, float spacing, int count, int[] weapons) + public LoadOutMenu(Vector2 position, MenuAction[] actions, int count) :base(position, actions) { MenuEntry gun = new MenuEntry( "Gun", new MenuAction[] { - new MenuAction(ActionType.Select, new LoadOutDelegate(count, 0, weapons)) + new MenuAction(ActionType.Select, new LoadOutDelegate(count, "Gun")) }, position); MenuEntry axe = new MenuEntry( - "Shield", + "Melee", new MenuAction[] { - new MenuAction(ActionType.Select, new LoadOutDelegate(count, 1, weapons)) + new MenuAction(ActionType.Select, new LoadOutDelegate(count, "Melee")) }, - position); + position + new Vector2(0, 80)); MenuEntry shield = new MenuEntry( "Shield", new MenuAction[] { - new MenuAction(ActionType.Select, new LoadOutDelegate(count, 0, weapons)) + new MenuAction(ActionType.Select, new LoadOutDelegate(count, "Shield")) }, - position); + position + new Vector2(0,160)); + + gun.UpperMenu = shield; + gun.LowerMenu = axe; + axe.UpperMenu = gun; + axe.LowerMenu = shield; + shield.UpperMenu = axe; + shield.LowerMenu = gun; + + this.Add(gun); + this.Add(axe); + this.Add(shield); } } } - -ActionType.Select, new LoadOutDelegate(count, 0, weapons) diff --git a/Project290/Project290/Games/SuperPowerRobots/Menus/MenuDelegates/LoadOutDelegate.cs b/Project290/Project290/Games/SuperPowerRobots/Menus/MenuDelegates/LoadOutDelegate.cs index 81072f4..40cab5f 100644 --- a/Project290/Project290/Games/SuperPowerRobots/Menus/MenuDelegates/LoadOutDelegate.cs +++ b/Project290/Project290/Games/SuperPowerRobots/Menus/MenuDelegates/LoadOutDelegate.cs @@ -9,26 +9,25 @@ namespace Project290.Games.SuperPowerRobots.Menus.MenuDelegates { class LoadOutDelegate : IMenuDelegate - { - int[] weapons; - int count; + { + int thecount; + string chosen; - public LoadOutDelegate(int count, int type, int[] weapons) + public LoadOutDelegate(int count, string name) :base() - { - this.count = count; - this.weapons = weapons; - weapons[count] = type; - count++; + { + thecount = count; + chosen = name; } public void Run() - { - if (count == 3) + { + LoadOutScreen.save(thecount, chosen); + /*if (count == 3) { GameWorld.screens[GameWorld.screens.Count - 1].Disposed = true; } - GameWorld.screens.Play(new LoadOutScreen(count, weapons)); + GameWorld.screens.Play(new LoadOutScreen(0));*/ } } } diff --git a/Project290/Project290/Games/SuperPowerRobots/SPRGameScreen.cs b/Project290/Project290/Games/SuperPowerRobots/SPRGameScreen.cs index 891b99e..cf09924 100644 --- a/Project290/Project290/Games/SuperPowerRobots/SPRGameScreen.cs +++ b/Project290/Project290/Games/SuperPowerRobots/SPRGameScreen.cs @@ -52,8 +52,10 @@ class SPRGameScreen : GameScreen private int currentLevel; - public ScoreKeeper scoreKeeper; - + public ScoreKeeper scoreKeeper; + + private int m_scoreboardIndex; + // DEBUG!! Body wall_e; World fantastica; @@ -65,8 +67,8 @@ class SPRGameScreen : GameScreen /// The game-specific index into the scoreboard. public SPRGameScreen(int scoreboardIndex) : base(scoreboardIndex) - { - // Tom's messing around with the physics engine! + { + this.m_scoreboardIndex = scoreboardIndex; currentLevel = 0; scoreKeeper = new ScoreKeeper(true); @@ -97,20 +99,23 @@ internal override void Reset() /// public override void Update() { - base.Update(); - - this.sprWorld.Update((GameClock.Now - previousGameTime) / 10000000f); - - fantastica.Step((GameClock.Now - previousGameTime) / 10000000f); - - previousGameTime = GameClock.Now; - + base.Update(); + if (this.sprWorld.m_isGameOver == true) { + GameWorld.screens.Play(new LoadOutScreen(m_scoreboardIndex)); ScoreKeeper.AddMoney(this.sprWorld.WinReward()); // Any type of stuff to be done after the bout is over shall go here. // Wooo! + return; } + + this.sprWorld.Update((GameClock.Now - previousGameTime) / 10000000f); + + fantastica.Step((GameClock.Now - previousGameTime) / 10000000f); + + previousGameTime = GameClock.Now; + } /// @@ -118,8 +123,7 @@ public override void Update() /// public override void Draw() { - base.Draw(); - + base.Draw(); this.sprWorld.Draw(); } } diff --git a/Project290/Project290/Games/SuperPowerRobots/Storage/Allies.xml b/Project290/Project290/Games/SuperPowerRobots/Storage/Allies.xml index 4721bf0..28f7b95 100644 --- a/Project290/Project290/Games/SuperPowerRobots/Storage/Allies.xml +++ b/Project290/Project290/Games/SuperPowerRobots/Storage/Allies.xml @@ -20,10 +20,10 @@ 0 - shield - Shield + gun + Gun 300 - 0 + 10 shield diff --git a/Project290/Project290/Games/SuperPowerRobots/Storage/Battles.xml b/Project290/Project290/Games/SuperPowerRobots/Storage/Battles.xml index 50fb8d1..98081ec 100644 --- a/Project290/Project290/Games/SuperPowerRobots/Storage/Battles.xml +++ b/Project290/Project290/Games/SuperPowerRobots/Storage/Battles.xml @@ -3,70 +3,71 @@ - BrickAI - 100 + ModeAI + 200 4SideEnemyRobot - 1000 + 600 600 - shield - Shield - 20 - 0 + gun + Gun + 100 + 10 shield Shield - 20 - 0 + 30 + 10 shield Shield - 20 - 0 + 30 + 50 shield Shield - 20 - 0 + 30 + 10 - 150 + 1000 - ModeAI - 200 + BrickAI + 100 4SideEnemyRobot - 600 + 1000 600 gun Gun - 100 - 10 + 20 + 0 shield Shield - 30 - 10 + 20 + 0 shield Shield - 30 - 50 + 20 + 0 shield Shield - 30 - 10 + 20 + 0 - 1000 + 150 + \ No newline at end of file