public override void OnHit(GameObject hitObject) { if (hitObject is Player) { if (RandomGenerator.GetRandom(0, 100) < PROB_LIFE) { ExtraLife extraLife = (ExtraLife)ItemPickableManager.GetItem(PickableType.ExtraLife); extraLife.IsActive = true; extraLife.Position = Position; extraLife.OnPlayerPick(); } else { int randomApples = RandomGenerator.GetRandom(MIN_APPLE, MAX_APPLE + 1); List <Pickable> apples = ItemPickableManager.GetItems(PickableType.Apple, randomApples); Vector2 offsetBetweenApples = Vector2.Zero; for (int i = 0; i < apples.Count; i++) { Apple apple = (Apple)apples[i]; apple.IsActive = true; apple.Position = Position + offsetBetweenApples; offsetBetweenApples += new Vector2(apple.Width / 3, apple.Height / 2); apple.OnPlayerPick(); } } } base.OnHit(hitObject); }
public override void OnHit(GameObject hitObject) { if (hitObject is Player) { Apple apple = (Apple)ItemPickableManager.GetItem(PickableType.Apple); apple.IsActive = true; apple.Position = Position; apple.OnPlayerPick(); } base.OnHit(hitObject); }
public override void OnHit(GameObject hitObject) { if (hitObject is Player && !isHitted) { ExtraLife extraLife = (ExtraLife)ItemPickableManager.GetItem(PickableType.ExtraLife); extraLife.IsActive = true; extraLife.Position = Position; extraLife.OnPlayerPick(); } base.OnHit(hitObject); }