public void isGround()
{
if (IsAlive == false)
{
return;
}
m_isOnGround = false;
RoomNew room = null;
Rectangle playerBounds = _position.Bounding;
Vector2 v2 = SpriteRoom.getCenterTile(playerBounds);
Rectangle tileBounds = SpriteRoom.GetBounds(Convert.ToInt32(Math.Truncate(v2.X)), Convert.ToInt32(Math.Truncate(v2.Y)));
//Check if kid outside Room
if (v2.X < 0)
{
room = Maze.LeftRoom(SpriteRoom);
}
else
{
room = SpriteRoom;
}
if (v2.Y > 2)
{
m_isOnGround = false;
}
else if (v2.Y < 0)
{
m_isOnGround = false;
}
else
{
if (room.GetCollision(Convert.ToInt32(Math.Truncate(v2.X)), Convert.ToInt32(Math.Truncate(v2.Y))) != Enumeration.TileCollision.Passable)
{
if (playerBounds.Bottom >= tileBounds.Bottom)
{
m_isOnGround = true;
}
}
}
if (m_isOnGround == false)
{
if (sprite.sequence.raised == false)
{
if (spriteState.Value().state == Enumeration.State.runjump)
{
spriteState.Add(Enumeration.State.rjumpfall, Enumeration.PriorityState.Force);
sprite.PlayAnimation(spriteSequence, spriteState.Value());
}
else
{
if (spriteState.Previous().state == Enumeration.State.runjump)
{
spriteState.Add(Enumeration.State.stepfall, Enumeration.PriorityState.Force, new Vector2(20, 15));
}
else if (spriteState.Value().state != Enumeration.State.freefall)
{
spriteState.Add(Enumeration.State.stepfall, Enumeration.PriorityState.Force);
}
}
//SpriteRoom.LooseShake();
//and for upper room...
SpriteRoom.maze.UpRoom(SpriteRoom).LooseShake();
}
return;
}
//IS ON GROUND!
if (spriteState.Value().state == Enumeration.State.freefall)
{
//Align to tile x
_position.Y = tileBounds.Bottom - _position._spriteRealSize.Y;
//CHECK IF LOOSE ENERGY...
int Rem = 0;
Rem = Convert.ToInt32(Math.Truncate(Math.Abs(Position.Y - PositionFall.Y))) / Tile.REALHEIGHT;
if (Rem == 0)
{
((SoundEffect)Maze.dContentRes["Sounds/dos/falling echo".ToUpper()]).Play();
}
else if (Rem >= 1 & Rem < 3)
{
((SoundEffect)Maze.dContentRes["Sounds/dos/loosing a life falling".ToUpper()]).Play();
}
else
{
((SoundEffect)Maze.dContentRes["Sounds/dos/falling".ToUpper()]).Play();
//you should dead!!!
DeadFall();
}
Energy = Energy - Rem;
spriteState.Add(Enumeration.State.crouch, Enumeration.PriorityState.Force, false);
SpriteRoom.LooseShake();
}
}