public void Update(GameTime gametime)
{
if (!_blockUpdates)
{
Backend.Direction tmp = _actor.direction;
if ((tmp != Backend.Direction.None) && ((int)tmp > -1) && (tmp != _prevDir)) _prevDir = tmp;
if (_effect != null)
{
if (_effect.finished)
{
_effect = null;
}
else
{
_effect.Update(gametime);
}
}
_elapsed += gametime.ElapsedGameTime.Milliseconds;
if (_target != _position)
{
if (_elapsed > _animationTime / _moveAccel)
{
if (!_nomove)
{
_nomove = true;
Animate(true);
}
else
{
_nomove = false;
}
// System.Diagnostics.Debug.WriteLine("ENDED AT " + _textures[(int)_activity * 8 + (int)Math.Log((double)_direction,2)].animationID);
// System.Diagnostics.Debug.WriteLine(_textures[(int)_activity * 8 + (int)Math.Log((double)_direction,2)].animationID);
_elapsed -= _animationTime / _moveAccel;
if (_target.x > _position.x)
{
// if (_id == 0) System.Diagnostics.Debug.Write(_xpertick.ToString());
_position.x += _xpertick;
}
else
{
if (_target.x < _position.x)
{
// if (_id == 0) System.Diagnostics.Debug.Write(-_xpertick);
_position.x -= Math.Min(_xpertick, Math.Abs(_target.x - _position.x));
}
//else
// if (_id == 0) System.Diagnostics.Debug.Write("0");
}
if (_target.y > _position.y)
{
// if (_id == 0) System.Diagnostics.Debug.WriteLine("/" + _ypertick.ToString());
_position.y += _ypertick;
}
else
if (_target.y < _position.y)
{
// if (_id == 0) System.Diagnostics.Debug.WriteLine("/-" + _ypertick.ToString());
_position.y -= _ypertick;
}
else
{
// if (_id == 0) System.Diagnostics.Debug.WriteLine("/0");
}
if (_focussed)
_camera.position = new Vector2(-38 - position.x, -30 - position.y);
if (_target == _position)
{
// _position = _target;
// _target = _cacheTarget;
_parent.HandleEvent(false, Backend.Events.TileEntered, _id, direction);
}
}
}
else
{
if (_elapsed > _animationTime)
{
_elapsed -= _animationTime;
if (_playAfterMove != Backend.Activity.Walk)
{
this.activity = _playAfterMove;
_playAfterMove = Backend.Activity.Walk;
}
Animate(false);
}
}
}
}