public Bullet Update(int id, List <int> bulletsToDelete) { if (_dieing) { UpdateAnimation(); if (_animations[_currentAnimation].FinishedPlaying) { SetInactive(_id); bulletsToDelete.Add(id); } return(this); } --KillTime; if (KillTime == 0) { Clear(); return(this); } if (SpawnDelay > 0) { --SpawnDelay; } if (SpawnDelay != 0) { return(this); } UpdateAnimation(); Behavior.Update(ref this); if (AutomaticCollision) { if (!_tileMap.CellIsPassableByPixel(CircleCollisionCenter) || !Camera.WorldRectangle.Contains((int)Position.X, (int)Position.Y)) { Clear(); return(this); } } if (CollisionCircle.Intersects(((Player)VariableProvider.CurrentPlayer).PlayerBulletCollisionCircle)) { Clear(); return(this); //VariableProvider.CurrentPlayer.Send<string>("KILL", null); } _directionVector.Normalize(); _lastDirection = Direction; _lastPosition = Position; return(this); }
public void Update(GameTime a_GameTime) { if (Follow != null) { if (CollisionCircle.Intersects(Follow.CollisionCircle) == false) { Velocity = Follow.Position - Position; Position += (Vector2.Normalize(Velocity)) * 5; if (Velocity != Vector2.Zero) { ConstantVelocity = Velocity; } } } }