Skip to content

Commit

Permalink
LoadOutMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
seankruer committed May 2, 2011
1 parent f14319b commit 71c71a8
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 108 deletions.
126 changes: 18 additions & 108 deletions Project290/Project290/Games/SuperPowerRobots/LoadOutScreen.cs
Expand Up @@ -14,6 +14,9 @@
using Project290.Physics.Dynamics;
using Project290.Games.SuperPowerRobots.Controls;
using Project290.Inputs;
using Project290.Games.SuperPowerRobots.Menus;
using Project290.Menus;
using Project290.Games.SuperPowerRobots.Menus.MenuDelegates;

namespace Project290.Screens
{
Expand All @@ -22,123 +25,30 @@ namespace Project290.Screens
/// </summary>
public class LoadOutScreen : Screen
{
private int scoreBoardIndex;
private string[] pictures;
private bool isOver;
private float time;
private float[] thresh;
private int count;
private int[] weapons;
private LoadOutMenu menu;
private Vector2 textDrawPosition;
private Vector2 textDrawOrigin;

private int yWeapons;
private int xWeapons;
private int bWeapons;
private int aWeapons;
private Bot bot;

public LoadOutScreen(int scoreBoardIndex)
public LoadOutScreen(int count, int[] weapons)
: base()
{
this.scoreBoardIndex = scoreBoardIndex;
World world = new World(Vector2.Zero);
SPRWorld loadOutWorld = new SPRWorld(world, 0);

yWeapons = 0;
xWeapons = 0;
bWeapons = 0;
aWeapons = 0;

this.bot = new Bot(loadOutWorld, new Body(world), Bot.Player.Computer, Bot.Type.FourSided, new BrickAI(loadOutWorld), TextureStatic.Get("4SideFriendlyRobot"), 62, 62, 100);

bot.AddWeapon(0, "gun", WeaponType.gun, 100f, 10f);
bot.AddWeapon(1, "gun", WeaponType.gun, 100f, 10f);
bot.AddWeapon(2, "gun", WeaponType.gun, 100f, 10f);
bot.AddWeapon(3, "gun", WeaponType.gun, 100f, 10f);


this.menu = new LoadOutMenu(
new Vector2(0, -60),
new MenuAction[]
{
new MenuAction(ActionType.Select, new LoadOutDelegate(count, 0, weapons)),
},
60f,
count,
weapons);
}


public override void Update()
{
base.Update();

if (GameWorld.controller.ContainsBool(ActionType.BButton) && bWeapons == 0)
{
bWeapons = 1;
bot.RemoveWeapon(bot.GetWeapons()[0]);
bot.AddWeapon(0, "shield", WeaponType.melee, 100f, 40f);
}
else if (GameWorld.controller.ContainsBool(ActionType.BButton) && bWeapons == 1)
{
bWeapons = 2;
bot.RemoveWeapon(bot.GetWeapons()[0]);
bot.AddWeapon(0, "shield", WeaponType.shield, 100f, 0f);
}
else if (GameWorld.controller.ContainsBool(ActionType.BButton))
{
bWeapons = 0;
bot.RemoveWeapon(bot.GetWeapons()[0]);
bot.AddWeapon(0, "gun", WeaponType.gun, 100f, 10f);
}


if (GameWorld.controller.ContainsBool(ActionType.AButton) && aWeapons == 0)
{
aWeapons = 1;
bot.RemoveWeapon(bot.GetWeapons()[1]);
bot.AddWeapon(0, "shield", WeaponType.melee, 100f, 40f);
}
else if (GameWorld.controller.ContainsBool(ActionType.AButton) && aWeapons == 1)
{
aWeapons = 2;
bot.RemoveWeapon(bot.GetWeapons()[1]);
bot.AddWeapon(0, "shield", WeaponType.shield, 100f, 0f);
}
else if (GameWorld.controller.ContainsBool(ActionType.AButton))
{
aWeapons = 0;
bot.RemoveWeapon(bot.GetWeapons()[1]);
bot.AddWeapon(0, "gun", WeaponType.gun, 100f, 10f);
}


if (GameWorld.controller.ContainsBool(ActionType.XButton) && xWeapons == 0)
{
xWeapons = 1;
bot.RemoveWeapon(bot.GetWeapons()[2]);
bot.AddWeapon(0, "shield", WeaponType.melee, 100f, 40f);
}
else if (GameWorld.controller.ContainsBool(ActionType.XButton) && xWeapons == 1)
{
xWeapons = 2;
bot.RemoveWeapon(bot.GetWeapons()[2]);
bot.AddWeapon(0, "shield", WeaponType.shield, 100f, 0f);
}
else if (GameWorld.controller.ContainsBool(ActionType.XButton))
{
xWeapons = 0;
bot.RemoveWeapon(bot.GetWeapons()[2]);
bot.AddWeapon(0, "gun", WeaponType.gun, 100f, 10f);
}


if (GameWorld.controller.ContainsBool(ActionType.YButton) && yWeapons == 0)
{
yWeapons = 1;
bot.RemoveWeapon(bot.GetWeapons()[3]);
bot.AddWeapon(0, "shield", WeaponType.melee, 100f, 40f);
}
else if (GameWorld.controller.ContainsBool(ActionType.YButton) && yWeapons == 1)
{
yWeapons = 2;
bot.RemoveWeapon(bot.GetWeapons()[3]);
bot.AddWeapon(0, "shield", WeaponType.shield, 100f, 0f);
}
else if (GameWorld.controller.ContainsBool(ActionType.YButton))
{
yWeapons = 0;
bot.RemoveWeapon(bot.GetWeapons()[3]);
bot.AddWeapon(0, "gun", WeaponType.gun, 100f, 10f);
}
}

public override void Draw()
Expand Down
44 changes: 44 additions & 0 deletions Project290/Project290/Games/SuperPowerRobots/Menus/LoadOutMenu.cs
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Project290.Menus;
using Microsoft.Xna.Framework;
using Project290.Inputs;
using Project290.Games.SuperPowerRobots.Menus.MenuDelegates;

namespace Project290.Games.SuperPowerRobots.Menus
{
class LoadOutMenu : Menu
{
public LoadOutMenu(Vector2 position, MenuAction[] actions, float spacing, int count, int[] weapons)
:base(position, actions)
{
MenuEntry gun = new MenuEntry(
"Gun",
new MenuAction[]
{
new MenuAction(ActionType.Select, new LoadOutDelegate(count, 0, weapons))
},
position);

MenuEntry axe = new MenuEntry(
"Shield",
new MenuAction[]
{
new MenuAction(ActionType.Select, new LoadOutDelegate(count, 1, weapons))
},
position);

MenuEntry shield = new MenuEntry(
"Shield",
new MenuAction[]
{
new MenuAction(ActionType.Select, new LoadOutDelegate(count, 0, weapons))
},
position);
}
}
}

ActionType.Select, new LoadOutDelegate(count, 0, weapons)
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Project290.Menus;
using Project290.Menus.MenuDelegates;
using Project290.GameElements;

namespace Project290.Games.SuperPowerRobots.Menus.MenuDelegates
{
class LoadOutDelegate : IMenuDelegate
{
int[] weapons;
int count;

public LoadOutDelegate(int count, int type, int[] weapons)
:base()
{
this.count = count;
this.weapons = weapons;
weapons[count] = type;
count++;
}

public void Run()
{
if (count == 3)
{
GameWorld.screens[GameWorld.screens.Count - 1].Disposed = true;
}
GameWorld.screens.Play(new LoadOutScreen(count, weapons));
}
}
}
2 changes: 2 additions & 0 deletions Project290/Project290/Project290.csproj
Expand Up @@ -129,7 +129,9 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Games\SuperPowerRobots\IntroScreen.cs" />
<Compile Include="Games\SuperPowerRobots\Menus\LoadOutMenu.cs" />
<Compile Include="Games\SuperPowerRobots\Menus\MainMenu.cs" />
<Compile Include="Games\SuperPowerRobots\Menus\MenuDelegates\LoadOutDelegate.cs" />
<Compile Include="Games\SuperPowerRobots\Menus\MenuDelegates\PlayGameDelegate.cs" />
<Compile Include="Games\SuperPowerRobots\ScoreKeeper.cs" />
<Compile Include="Games\SuperPowerRobots\Settings.cs" />
Expand Down

0 comments on commit 71c71a8

Please sign in to comment.