Quote:
Originally Posted by InsomniacPro
So, I would like some opinions on how I should handle luckytime.
For example, I can either enumerate through players within a screen, and check for distance and check for llucky time. If a player is within range for luckytime, they start luckabsorb.
Now option B tht I have. When a player starts luckytime, its in a 7x7 grid. Now the tiles within that 7x7 grid, get an attribute declaring them luckytime tiles, a blessed tile if you will. When player is standing still on a blessed tile, they start gaining luckytime.
Which of these would be the smarter more efficient route. Or if you have another, better way, I would love to hear.
|
Code:
int base_X = 10, base_Y = 10;
int lowerX= base_X - 3, lowerY= base_Y - 3;// Lowest possible coordinate value.
for (int x = lowerX; i < lowerX + 6; x++)//Enumerate through all possible X values.
{
for (int y = lowerY; j < lowerY + 6; y++)//Enumerating through all possible Y values.
{
map.SetBlessedTile(x, y);
}
}
So if i am casting luckytime and a player decides to walk right up to me to pray, You are gonna loop 36 times and call map.IsBlessed(x,y) each block that player walks just to check if i am casting luckytime? I think its a stupid idea and i don't blame you.. I blame the first responders...
That ^ is a waste of time and resources.
You are over complicating things here...
Quote:
class Hero
{
public bool CastingLuckytime;// = false
public Dictionary<int, Hero> or List<Hero> LuckyTimeLeechers;
}
|
Assume that Hero A is standing at 10X 10Y.
Hero A casts the Luckytime spell and goes afk... His mother she's been yelling at him to go to bed for hours or something....
Hero B jumps into Hero A screen.
Here you are gonna have to spawn Hero A to B and B to A so they can see each other.
if (A.CastingLuckytime && B.CastingLuckytime)
do nothing
if(A.CastingLuckytime && !B.CastingLuckytime)
A.LuckyTimeLeechers.Add(B);
if(!A.CastingLuckytime && B.CastingLuckytime)
B.LuckyTimeLeechers.Add(A);
LuckyTimeLeechers will be your reference later on because you are gonna have to Add/Remove status flags from not only the Hero that is casting Luckytime but from the Luckytime Leechers as will since they cant keep the Praying flag once they/the caster move(s).
Good luck.. I only had like 4 min to spare so please excuse my sloppy reply.
@Everyone else
I am sorry but i couldn't leave the house before i say... Why the fuck would you need to LOOP through lists or whatever the heck you guys are talking about for such a simple feature... You are spawning players to each other with or without checking for luckytime casters so why not take advantage of that...