private void MoveBack(Sprite sprite) { var ownerSprite = Owner.GetComponent <Sprite>(); if (ownerSprite == null) { _currentState = BoomerangState.Stop; Active = false; } if (ManagerFunction.Distance(sprite.Position, ownerSprite.Position) < 2) { _currentState = BoomerangState.Stop; Active = false; return; } if (ownerSprite.Position.X < sprite.Position.X) { sprite.Move(-1 * _speed, 0); } if (ownerSprite.Position.X > sprite.Position.X) { sprite.Move(_speed, 0); } if (ownerSprite.Position.Y < sprite.Position.Y) { sprite.Move(0, -1 * _speed); } if (ownerSprite.Position.Y > sprite.Position.Y) { sprite.Move(0, _speed); } }
public override void Update(double gameTime) { if (ManagerEvents.Active) { return; } _counter += gameTime; if (_counter < _cooldown) { return; } var ownerSprite = GetComponent <Sprite>(ComponentType.Sprite); if (ownerSprite == null) { return; } foreach (var baseObject in _targetList) { var sprite = baseObject.GetComponent <Sprite>(ComponentType.Sprite); if (sprite != null) { if (ManagerFunction.Distance(ownerSprite.Position, sprite.Position) < _distance) { ManagerEvents.AddEvents(_gameEvent); _counter = 0; } } } }