I am now bussy with picking up the sword.
the player picks up the sword and the picture will be shown in the inventory and the picture of the sword u picked up will be invisible. and u see the pictuce of the player with the sword in the dungeon.
I have this method:
[code]
public Point Move(Direction direction)
{
string weapon;
base.location = Move(direction, game.Boundaries,location);
if (!game.weaponInRoom.PickedUp)
{
//rest of the logic.
if (equippedweapon.Nearby(location,1))
{
equippedweapon.PickedUP();
//if (equippedweapon.PickedUP() == game.CheckPlayerInventory(equippedweapon.Name) )
//{
//}
//else
inventory.Add(equippedweapon);
if (weapons.Contains(1))
{
}
}
}
return location;
}//end method
[code]
Loading
albert albertPosted Feb 12, 2012, 6:08 PM
FroglegPosted Feb 12, 2012, 4:40 PM
FroglegPosted Feb 12, 2012, 2:57 PM
You have a mover abstact class which may be ok for enemies, but not in my opinion for the player.
When you create a project (after you have outlined what your program will do), do one thing at a time ie create player and movement.
When you add enemies or weapons further down the track- keep testing to ensure your later code has not interfered with your player
albert albertPosted Feb 12, 2012, 8:54 AM
FroglegPosted Feb 12, 2012, 4:36 AM
Pressing F11, I did a count of code lines - I stopped at 300 and it still had not finished the method
You move from class to class like a bouncing bullet - and all the methods do is transfer to another class - virtually popping to say hello and doing nothing constructive
My advice- Restart the project and make it simple
Form1 handles imputs and graphics
Game class is the game engine
weapon class holds only info on weapons
enemy class holds only info on enemies
albert albertPosted Feb 12, 2012, 3:04 AM
[code]
class Weapon
public bool PickedUP(bool pickedUp)
{
if (pickedUp == true)
return true; //I putted here an breakpoint and it gives true when the player intersects with the sword. So that is good
else
return false;
//pickedUp = true;
return pickedUp;
}
[/code]
but if I put here an breakpoint:
[code]
class Form
weaponControl.Visible = true;
weaponControl.Location = game.weaponInRoom.Location;
if (pickUpWeapon = game.weaponInRoom.PickedUp)
//if(( pickUpWeapon = game.checkForWeapon(pcPlayer.Bounds, pcSword.Bounds)) == true)
//if( game.weaponInRoom.PickedUP(pickUpWeapon) == true)
{
//game.MovePlayer(direction, boundaries, location);
// pickUpWeapon = game.checkForWeapon(pcPlayer.Bounds, pcSword.Bounds);
lb_pickedupSword.Text = game.weaponInRoom.PickedUP(pickUpWeapon).ToString();
---> weaponControl.Visible = false;// here I putted an breakpoint , but nothing happens
//so u have to guess where the sword is and the the sword will be shown in the
//inventory
}
else
{
weaponControl.Visible = true;
}
[/code]
albert albertPosted Feb 11, 2012, 8:30 AM
[code]
public bool checkForWeapon(Rectangle playRect, Rectangle weaponRect)
{
bool isPickup = false;
if (playRect.IntersectsWith(weaponRect))
{
isPickup = true;
}
return isPickup;
}
[/code]
I putted an breakpoint on this line: isPickup = true;
but when the player intersects with the sword the variable isPickup says: false. strange
albert albertPosted Feb 11, 2012, 4:40 AM
And still the form doesnt communicate with the player method
And when I put a breakpoint on this lines:
Form class:
[code]
weaponControl.Location = game.weaponInRoom.Location;
if (game.weaponInRoom.PickedUp)
weaponControl.Visible = false;
[/code]
the code is executed before the player picked up the sword.
this function:
[code]
weaponControl.Location = game.weaponInRoom.Location;
if (game.weaponInRoom.PickedUp)
weaponControl.Visible = false;
else
weaponControl.Visible = true;
[/code]
is necessary because this doesnt working ofcourse:
[code]
case "Sword":
weaponControl = pcSword;
locationWeapon.Text = weaponControl.Location.ToString();
if (intersects() == true)
{
//weaponControl.Visible = false;
pcSword.Visible = false;
inventorySword.Visible = true;
inventorySword.BorderStyle = BorderStyle.FixedSingle;
pcPlayerSword.Location = weaponControl.Location;//That the new image is show on the place where the player pickedup his weapon!!
pcPlayerSword.Visible = true;
pcPlayer.Visible = false;
//if (inventorySword.Visible = true)
// weaponControl.Visible = false;
}
break;
[/code]
because then only the sword is !visible when the player intersects with the sword. but after the interseciton the sword is still visible.
albert albertPosted Feb 11, 2012, 2:55 AM
u changed this method:
And the Form class.
[code]
public Point Move(Direction direction)
{
//Rectangle r1 = new Rectangle(new Point(this.Location.X, this.location.Y),this.width,this,heigt);
//Point target = equippedweapon.Location;
string weapon;
base.location = Move(direction, game.Boundaries,location);
return location;
}//end method
[/code]
But If u put a breakpoint on this line in the form Class:
weaponControl.Location = game.weaponInRoom.Location;
if (game.weaponInRoom.PickedUp) --- u can put a breakpoint on this line, then it will be executed befor the player actually hit with the sword.
weaponControl.Visible = false;
That I dont understand. Because only when the player hits with the the sword then the weapon in the dungeon will be removed and the sword in the inventory will be showed. That is how it has to be.
FroglegPosted Feb 10, 2012, 9:19 PM
albert albertPosted Feb 10, 2012, 8:11 PM
FroglegPosted Feb 10, 2012, 3:48 PM
albert albertPosted Feb 10, 2012, 7:53 AM
And I dont understand why the pcSword not dissapear from the Dungeon, because I set the property vissible to false.
albert albertPosted Feb 9, 2012, 4:06 PM
[code]
public void intersects()
{
Rectangle p1 = this.pcPlayer.ClientRectangle;
p1.Offset(this.pcPlayer.Location);
Rectangle p2 = this.pcSword.ClientRectangle;
p2.Offset(this.pcSword.Location);
bool overlapped = p1.IntersectsWith(p2);
[/code]
albert albertPosted Feb 9, 2012, 3:36 PM
I think in the form class it is already done, isnt?
FroglegPosted Feb 9, 2012, 3:04 PM
albert albertPosted Feb 9, 2012, 2:52 PM
[code]
public Point Move(Direction direction)
{
string weapon;
base.location = Move(direction, game.Boundaries,location);
if (!game.weaponInRoom.PickedUp)
{
//rest of the logic.
if (game.weaponInRoom.Nearby(this.Location, this.distance) == true)
{
equippedweapon.PickedUP();
inventory.Add(equippedweapon);
}
}
return location;
}//end method
[/code]
in the Player class.
The player moves to the weapon(sword) and the the sword will dissapear in the dungeon, where the player moves and appears in the inventory and also the player with the sword will appear. But now the situation is if u press on a move button the action is already done before the player pickedup the weapon.
FroglegPosted Feb 9, 2012, 2:40 PM
albert albertPosted Feb 9, 2012, 2:16 PM
FroglegPosted Feb 9, 2012, 1:26 PM
Check your code and upload project again
albert albertPosted Feb 9, 2012, 12:01 PM
[code]
public Point Move(Direction direction)
{
string weapon;
base.location = Move(direction, game.Boundaries,location);
if (!game.weaponInRoom.PickedUp)
{
//rest of the logic.
if (game.weaponInRoom.Nearby(this.Location, this.distance) == true)
{
equippedweapon.PickedUP();
inventory.Add(equippedweapon);
}
//if (this.game.weaponInRoom.Nearby(location,distance) == true)
// {
// }
}
return location;
}//end method
[/code]