private void MakeSpaceObject(string texName, Image tex, DrawPoint mp)
{
texName = texName.Replace(".png", "");
int numberOfFrames = SpaceObject.GetNumberOfFrames(texName);
//Much repeated code to account for each possible object
if (rb_WallStatic.Checked)
{
mp.X -= (texture.Width / (numberOfFrames * 2));
mp.Y -= (texture.Height / 2);
WallStatic wall = new WallStatic(
Conversion.DrawPointToVector2(mp),
currdir + "\\" + texName + ".tri");
wall.TextureName = texName;
currentlySelectedRoom.AddObject(wall);
}
else if (rb_WallDynamic.Checked)
{
mp.X -= (texture.Width / (numberOfFrames * 2));
mp.Y -= (texture.Height / 2);
WallDynamic wall = new WallDynamic(
Conversion.DrawPointToVector2(mp),
new Vector2(0, 0),
currdir + "\\" + texName + ".tri");
wall.TextureName = texName;
currentlySelectedRoom.AddObject(wall);
}
else if (rb_HazardStatic.Checked)
{
mp.X -= (texture.Width / (numberOfFrames * 2));
mp.Y -= (texture.Height / 2);
HazardStatic hazard = new HazardStatic(
Conversion.DrawPointToVector2(mp),
currdir + "\\" + texName + ".tri");
hazard.TextureName = texName;
currentlySelectedRoom.AddObject(hazard);
}
else if (rb_HazardDynamic.Checked)
{
mp.X -= (texture.Width / (numberOfFrames * 2));
mp.Y -= (texture.Height / 2);
HazardDynamic hazard = new HazardDynamic(
Conversion.DrawPointToVector2(mp),
new Vector2(0, 0),
currdir + "\\" + texName + ".tri");
hazard.TextureName = texName;
currentlySelectedRoom.AddObject(hazard);
}
else if (rb_Parts.Checked)
{
mp.X -= (texture.Width / (numberOfFrames * 2));
mp.Y -= (texture.Height / 2);
Part part = new Part(
Conversion.DrawPointToVector2(mp),
currdir + "\\" + texName + ".tri");
part.TextureName = texName;
currentlySelectedRoom.AddObject(part);
}
else if (rb_Survivors.Checked)
{
mp.X -= (texture.Width / (numberOfFrames * 2));
mp.Y -= (texture.Height / 2);
Survivor survivor = new Survivor(
Conversion.DrawPointToVector2(mp),
currdir + "\\" + texName + ".tri");
survivor.TextureName = texName;
//sets up the survivor color as appropriate
switch (survivor.TextureName)
{
case "Art\\Survivors\\SurvivorBlue":
survivor.SColor = Survivor.survivorColor.BLUE;
break;
case "Art\\Survivors\\SurvivorRed":
survivor.SColor = Survivor.survivorColor.RED;
break;
case "Art\\Survivors\\SurvivorYellow":
survivor.SColor = Survivor.survivorColor.YELLOW;
break;
case "Art\\Survivors\\SurvivorPurple":
survivor.SColor = Survivor.survivorColor.PURPLE;
break;
case "Art\\Survivors\\SurvivorOrange":
survivor.SColor = Survivor.survivorColor.ORANGE;
break;
case "Art\\Survivors\\Survivor":
survivor.SColor = Survivor.survivorColor.GREEN;
break;
default:
break;
}
currentlySelectedRoom.AddObject(survivor);
}
else if (rb_Vanish_Walls.Checked)
{
mp.X -= (texture.Width / (numberOfFrames * 2));
mp.Y -= (texture.Height / 2);
VanishWall vanish = new VanishWall(
Conversion.DrawPointToVector2(mp),
currdir + "\\" + texName + ".tri");
vanish.TextureName = texName;
currentlySelectedRoom.AddObject(vanish);
}
else if (rb_Handlebars.Checked)
{
mp.X -= (texture.Width / 2);
mp.Y -= (texture.Height / 2);
Handlebar hdlbar = new Handlebar(
Conversion.DrawPointToVector2(mp),
new Vector2(0, 0),
currdir + "\\" + texName + ".tri");
hdlbar.TextureName = texName;
currentlySelectedRoom.AddObject(hdlbar);
}
else if (rb_VictoryTest.Checked)
{
mp.X -= (texture.Width / 2);
mp.Y -= (texture.Height / 2);
VictoryTest victest = new VictoryTest(
Conversion.DrawPointToVector2(mp),
currdir + "\\" + texName + ".tri");
victest.TextureName = texName;
currentlySelectedRoom.AddObject(victest);
}
else if (rb_SavePoint.Checked)
{
mp.X -= (texture.Width / (numberOfFrames * 2));
mp.Y -= (texture.Height / 2);
SavePoint savePoint = new SavePoint(
Conversion.DrawPointToVector2(mp),
currdir + "\\" + texName + ".tri");
savePoint.TextureName = texName;
currentlySelectedRoom.AddObject(savePoint);
}
else if (rb_Player.Checked)
{
mp.X -= (int)((texture.Width * Constants.PLAYER_SCALE) / 2);
mp.Y -= (int)((texture.Height * Constants.PLAYER_SCALE) / 2);
world.player = new Player(
Conversion.DrawPointToVector2(mp),
currdir + "\\" + texName + ".tri"
);
world.CurrentRoom = currentlySelectedRoom;
world.player.TextureName = texName;
}
}