Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?
You are not logged in.
Pages: 1
Edit: Tried a dig code, didn't work. Here's my current code:
case "m":
try
{
string mover = Players[m.GetInt(0)];
int leftOrRight = m.GetInt(7); //-1 left, 1 right
int upOrDown = m.GetInt(8);//-1 up, 1 down
int xPlayer = (int)m.GetDouble(1);
int yPlayer = (int)m.GetDouble(2);
BlockTracker bt;
if (checkBox1.Checked)
{
if (leftOrRight == -1 && RoomData[0, xPlayer - 1, yPlayer] == 16)
{
bt = new BlockTracker(xPlayer - 1, yPlayer);
bt.hp--;
if (bt.hp == 0)
{
conn.Send(bldatm, xPlayer - 1, yPlayer, 4);
points[mover]++;
}
}
if (leftOrRight == 1 && RoomData[0, xPlayer + 1, yPlayer] == 16)
{
bt = new BlockTracker(xPlayer + 1, yPlayer);
bt.hp--;
if (bt.hp == 0)
{
conn.Send(bldatm, xPlayer + 1, yPlayer, 4);
points[mover]++;
}
}
if (upOrDown == -1 && RoomData[0, xPlayer, yPlayer + 1] == 16)
{
bt = new BlockTracker(xPlayer, yPlayer + 1);
bt.hp--;
if (bt.hp == 0)
{
conn.Send(bldatm, xPlayer, yPlayer + 1, 0);
points[mover]++;
}
}
if (upOrDown == 1 && RoomData[0, xPlayer, yPlayer - 1] == 16)
{
bt = new BlockTracker(xPlayer, yPlayer - 1);
bt.hp--;
if(bt.hp == 0)
{
conn.Send(bldatm, xPlayer, yPlayer - 1, 0);
points[mover]++;
}
}
}
}
catch { }
break;
BlockTracker.cs (I know this is unnecessary, but I made a class)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Forms_Bot_Rebuild
{
class BlockTracker
{
private int _X;
private int _Y;
private int _Hp = 5;
public BlockTracker(int x, int y)
{
_X = x;
_Y = y;
}
public int x
{
get
{
return _X;
}
set
{
_Y = value;
}
}
public int y
{
get
{
return _Y;
}
set
{
_Y = value;
}
}
public int hp
{
get
{
return _Hp;
}
set
{
_Hp = value;
}
}
}
}
Doesn't work. Please help.
Offline
Just check when somebody moves, which direction it is and if the direction he's wishing to go is against a block. Do minHp() and make sure you handle some sort of event once hp has reached 0.
Offline
BTW did you heard about c# accessors?
Everybody edits, but some edit more than others
Offline
What's a C# accessor?
He's talking about properties and get/set accessors, which you could use to replace your class methods.
Here's more info about properties:
http://www.dotnetperls.com/property
Offline
I'm not sure if this is right, but I think the problem is that you keep creating a new BlockTracker so that every time you try digging, the block's health resets to 5. You should try storing your blocks into an array and then check if the spot you are digging in has already been added. If not, then create a new BlockTracker with those coordinates. Then if it reaches 0, remove that block.
Offline
Didn't quite get ya.
Everytime a person hits a block, you give that block a new blocktracker, starting it off at 5hp again.
What what I would personally do is include the hp into you Block object instead of making a new class which tracks the blocks POSITION seperatly.
I think you can also more easily add seperate hp values per block type if you'd do it this way.
Offline
Pages: 1
[ Started around 1732796627.4343 - Generated in 0.081 seconds, 11 queries executed - Memory usage: 1.44 MiB (Peak: 1.58 MiB) ]