private void SpawnAmobea(GameTime gameTime, List <SpriteBase> sprites) { if (gameTime == null || gameTime.TotalGameTime.TotalSeconds - _timer < _interval) { //Don't spawn return; } //spawn new sprite Debug.Print("Spawning..."); _timer = gameTime.TotalGameTime.TotalSeconds; //33% chance of spawning a new amobea int res = _random.Next(0, 101); if (res > 66) { Debug.Print("=> Amobea"); var clone = this.Clone() as Amobea; clone.Mover = new RandomMover(1f, 2000); sprites.Add(clone); } else { Debug.Print("=>SpriteBase"); var child = new SpriteBase(this._spriteTexture, new Vector2(this._spritePosition.X + 50, this._spritePosition.Y + 50), new RandomMover(2f, 1), 10f, Color.White, 0.3f); child.TextureScale = 0.5f; sprites.Add(child); } Debug.Print(string.Format("Sprites in list : {0}", sprites.Count)); }
public void Follow(SpriteBase target) { var position = Matrix.CreateTranslation( -target.Position.X - 16, -target.Position.Y - 16, 0); var offset = Matrix.CreateTranslation( Constants.ScreenWidth / 2, Constants.ScreenHeight / 2, 0); Transform = position * offset; }