public void SpawnEgg() { const float SPAWN_DISTANCE = 10f; _eggSpawned = true; Vector2 direction = -1f * DirectionHelper.GetFacingFromDirection(_animDirection); if (_animDirection == AnimationDirection.Left || _animDirection == AnimationDirection.Right) { direction.Y += (float)GameScreen.RandomNum.NextDouble() - 0.5f; } else if (_animDirection == AnimationDirection.Up || _animDirection == AnimationDirection.Down) { direction.X += (float)GameScreen.RandomNum.NextDouble() - 0.5f; } direction.Normalize(); Vector2 spawn = Position + (SPAWN_DISTANCE * direction) + PHYSICS_OFFSET; EggEntity egg = GameScreen.AddEgg(spawn); egg.DynamicBody.ApplyLinearImpulse(direction); }
private void CleanupDeletedEntities() { if (QueuedForDisposal.Count > 0) { foreach (CharacterEntity entity in QueuedForDisposal) { entity.DynamicBody.Enabled = false; entity.DynamicBody.Dispose(); ActiveEntities.Remove(entity); EnemyEntity enemy = entity as EnemyEntity; if (enemy != null) { Enemies.Remove(enemy); } else { EggEntity egg = entity as EggEntity; if (egg != null) { Eggs.Remove(egg); } } } QueuedForDisposal.Clear(); } }
public EggEntity AddEgg(Vector2 pos) { _eggCounterCurrent++; EggEntity egg = new EggEntity(this, Clips["egg"], pos); egg.DynamicBody.LinearDamping = 5f; Eggs.Add(egg); QueuedForCreation.Add(egg); return(egg); }
private bool CollisionWithEgg(Fixture f1, Fixture f2, Contact contact, EggEntity egg) { if (CurrentState == State.BeingSuckedIn) { return(false); } HitEgg = true; egg.SwitchToDeathState(); return(true); }
private bool CollisionHandler(Fixture f1, Fixture f2, Contact contact) { PlayerEntity player = f2.Body.UserData as PlayerEntity; EggEntity egg = f2.Body.UserData as EggEntity; if (player != null) { return(CollisionWithPlayer(f1, f2, contact, player)); } else if (egg != null) { return(CollisionWithEgg(f1, f2, contact, egg)); } return(true); }
public void DestroyEgg(EggEntity egg) { egg.IsValid = false; QueuedForDisposal.Add(egg); }
public EggEntity AddEgg(Vector2 pos) { _eggCounterCurrent++; EggEntity egg = new EggEntity(this, Clips["egg"], pos); egg.DynamicBody.LinearDamping = 5f; Eggs.Add(egg); QueuedForCreation.Add(egg); return egg; }
private bool CollisionWithEgg(Fixture f1, Fixture f2, Contact contact, EggEntity egg) { if (CurrentState == State.BeingSuckedIn) return false; HitEgg = true; egg.SwitchToDeathState(); return true; }