Skip to content

Commit

Permalink
Loadout menu beginnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdooner committed May 2, 2011
1 parent 71c71a8 commit 0eb3328
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 99 deletions.
11 changes: 10 additions & 1 deletion Project290/Project290/Games/SuperPowerRobots/Battle.cs
Expand Up @@ -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;
Expand All @@ -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.

Expand Down
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down
96 changes: 65 additions & 31 deletions Project290/Project290/Games/SuperPowerRobots/LoadOutScreen.cs
Expand Up @@ -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
{
/// <summary>
/// This is a Screen specific for a game (as opposed to title or pause screen).
/// </summary>
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<string, string> a = new Dictionary<string, string>();
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 = "<Allies>\n <Bot>\n <AI>HumanAI</AI>\n <Health>500</Health>\n <Texture>4SideFriendlyRobot</Texture>\n <PositionX>400</PositionX>\n <PositionY>400</PositionY>\n <Weapon>\n <Type>" + a[xWeapons] + "</Type>\n<Texture>" + xWeapons + "</Texture>\n <Health>300</Health>\n <Power>10</Power>\n </Weapon>\n <Weapon>\n <Type>" + a[yWeapons] + "</Type>\n <Texture>" + yWeapons + "</Texture>\n <Health>300</Health>\n <Power>10</Power>\n </Weapon>\n <Weapon>\n <Type>" + a[aWeapons] + "</Type>\n<Texture>" + aWeapons + "</Texture>\n <Health>300</Health>\n <Power>10</Power>\n </Weapon>\n <Weapon>\n <Type>" + a[bWeapons] + "</Type>\n<Texture>" + bWeapons + "</Texture>\n <Health>300</Health>\n <Power>10</Power>\n </Weapon>\n </Bot>\n <Level>0</Level>\n <HasWatchedIntro>0</HasWatchedIntro>\n</Allies>\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);*/
}

}
}
27 changes: 18 additions & 9 deletions Project290/Project290/Games/SuperPowerRobots/Menus/LoadOutMenu.cs
Expand Up @@ -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)
Expand Up @@ -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));*/
}
}
}
32 changes: 18 additions & 14 deletions Project290/Project290/Games/SuperPowerRobots/SPRGameScreen.cs
Expand Up @@ -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;
Expand All @@ -65,8 +67,8 @@ class SPRGameScreen : GameScreen
/// <param name="scoreboardIndex">The game-specific index into the scoreboard.</param>
public SPRGameScreen(int scoreboardIndex)
: base(scoreboardIndex)
{
// Tom's messing around with the physics engine!
{
this.m_scoreboardIndex = scoreboardIndex;

currentLevel = 0;
scoreKeeper = new ScoreKeeper(true);
Expand Down Expand Up @@ -97,29 +99,31 @@ internal override void Reset()
/// </summary>
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;

}

/// <summary>
/// Draws this instance.
/// </summary>
public override void Draw()
{
base.Draw();

base.Draw();
this.sprWorld.Draw();
}
}
Expand Down
Expand Up @@ -20,10 +20,10 @@
<Power>0</Power>
</Weapon>
<Weapon>
<Type>shield</Type>
<Texture>Shield</Texture>
<Type>gun</Type>
<Texture>Gun</Texture>
<Health>300</Health>
<Power>0</Power>
<Power>10</Power>
</Weapon>
<Weapon>
<Type>shield</Type>
Expand Down

0 comments on commit 0eb3328

Please sign in to comment.