/// <summary> /// Initializes a new instance of the <see cref="LevelManager"/> class. /// </summary> /// <param name="gameDisplayResolution">The resolution the game is set to render at.</param> /// <param name="frameTime">The frame time set for the game.</param> public LevelManager(Vector2 gameDisplayResolution, float frameTime) { this.startText = new RenderableText(); this.Complete = false; this.physicsWorld = null; this.gameDisplayResolution = gameDisplayResolution; this.frameTime = frameTime; this.physicsWorld = null; this.spriteBatch = null; this.floorSprite = new Sprite(); this.contentManager = null; this.levelLoader = null; this.floorEdges = new List <Body>(); this.visualFloorEdges = new List <VisualEdge>(); this.platforms = new List <Platform>(); this.interactiveEntities = new List <InteractiveEntity>(); this.stickman = null; this.exit = null; this.scrollingDeath = null; this.mineCart = null; this.cartSwitch = null; this.scrollStartTimer = 0.0f; this.background = new Background(this.gameDisplayResolution, 0.8f); this.maxScore = 0.0f; }
/// <summary> /// Creates the bonuses, obstacles and power ups contained in a level. /// </summary> /// <param name="interactiveEntityDescriptions">A list of interactive entity descriptions.</param> /// <param name="physicsWorld">The physics world to create the entities in.</param> /// <param name="interactiveEntities">An empty list to store the interactive entities in.</param> /// <param name="mineCart">The mine cart entity.</param> /// <param name="cartSwitch">The switch entity.</param> /// <param name="spriteBatch">The sprite batch to use for rendering.</param> /// <param name="contentManager">The game's content manager.</param> public static void CreateInteractiveEntities(List<InteractiveEntityDescription> interactiveEntityDescriptions, ref World physicsWorld, ref List<InteractiveEntity> interactiveEntities, ref MineCart mineCart, ref Switch cartSwitch, SpriteBatch spriteBatch, ContentManager contentManager) { if (interactiveEntities.Count == 0) { foreach (InteractiveEntityDescription description in interactiveEntityDescriptions) { if (EntityConstants.PowerUpNames.Contains(description.Name)) { interactiveEntities.Add(new PowerUp(ref physicsWorld, spriteBatch, contentManager, description, EntitySettingsLoader.GetPowerUpSettings(description.Name))); } else if (EntityConstants.BonusNames.Contains(description.Name) || EntityConstants.ObstacleNames.Contains(description.Name)) { interactiveEntities.Add(new BonusOrObstacle(ref physicsWorld, spriteBatch, contentManager, description, EntitySettingsLoader.GetObstacleOrBonusSetting(description.Name))); } else if (description.Name == EntityConstants.CartBody) { mineCart = new MineCart(spriteBatch, contentManager, ref physicsWorld, description.Position, 100.0f, 240.0f, 350.0f, 80.0f, -80.0f); } else if (description.Name == EntityConstants.Switch) { cartSwitch = new Switch(spriteBatch, contentManager, ref physicsWorld, description.Position, mineCart); } } } }
/// <summary> /// Creates the bonuses, obstacles and power ups contained in a level. /// </summary> /// <param name="interactiveEntityDescriptions">A list of interactive entity descriptions.</param> /// <param name="physicsWorld">The physics world to create the entities in.</param> /// <param name="interactiveEntities">An empty list to store the interactive entities in.</param> /// <param name="mineCart">The mine cart entity.</param> /// <param name="cartSwitch">The switch entity.</param> /// <param name="spriteBatch">The sprite batch to use for rendering.</param> /// <param name="contentManager">The game's content manager.</param> public static void CreateInteractiveEntities(List <InteractiveEntityDescription> interactiveEntityDescriptions, ref World physicsWorld, ref List <InteractiveEntity> interactiveEntities, ref MineCart mineCart, ref Switch cartSwitch, SpriteBatch spriteBatch, ContentManager contentManager) { if (interactiveEntities.Count == 0) { foreach (InteractiveEntityDescription description in interactiveEntityDescriptions) { if (EntityConstants.PowerUpNames.Contains(description.Name)) { interactiveEntities.Add(new PowerUp(ref physicsWorld, spriteBatch, contentManager, description, EntitySettingsLoader.GetPowerUpSettings(description.Name))); } else if (EntityConstants.BonusNames.Contains(description.Name) || EntityConstants.ObstacleNames.Contains(description.Name)) { interactiveEntities.Add(new BonusOrObstacle(ref physicsWorld, spriteBatch, contentManager, description, EntitySettingsLoader.GetObstacleOrBonusSetting(description.Name))); } else if (description.Name == EntityConstants.CartBody) { mineCart = new MineCart(spriteBatch, contentManager, ref physicsWorld, description.Position, 100.0f, 240.0f, 350.0f, 80.0f, -80.0f); } else if (description.Name == EntityConstants.Switch) { cartSwitch = new Switch(spriteBatch, contentManager, ref physicsWorld, description.Position, mineCart); } } } }
/// <summary> /// Initializes a new instance of the <see cref="Switch"/> class. /// </summary> /// <param name="spriteBatch">The sprite batch to render sprites with.</param> /// <param name="contentManager">The content manager to load assets with.</param> /// <param name="physicsWorld">The game's physics world.</param> /// <param name="position">The position of the switch.</param> /// <param name="mineCart">The mine cart to activate.</param> public Switch(SpriteBatch spriteBatch, ContentManager contentManager, ref World physicsWorld, Vector2 position, MineCart mineCart) { this.sprite = new AnimatedSprite(); this.activated = false; this.mineCart = mineCart; this.InitializeAndLoadSprites(spriteBatch, contentManager); this.SetUpPhysics(ref physicsWorld, position); }
public MineTracks(string[] input) { var parsedInput = input.Select(l => l.ToCharArray()).ToArray(); _width = parsedInput[0].Length; _height = parsedInput.Length; _tracks = new char[_width, _height]; for (var y = 0; y < _height; y++) { for (var x = 0; x < _width; x++) { var entity = parsedInput[y][x]; if (_cartTypes.Contains(entity)) { var cart = new MineCart(entity, x, y); entity = cart.ToTrack(); _carts.Add(cart); } _tracks[x, y] = entity; } } }
/// <summary> /// Disposes of the interactive entities and clears the list. /// </summary> /// <param name="physicsWorld">The physics world containing the entities' bodies.</param> /// <param name="interactiveEntities">the list of interactive entities.</param> /// <param name="mineCart">The mine cart.</param> /// <param name="cartSwitch">The switch entity.</param> public static void DisposeOfInteractiveEntities(ref World physicsWorld, ref List<InteractiveEntity> interactiveEntities, ref MineCart mineCart, ref Switch cartSwitch) { if (mineCart != null) { mineCart.Dispose(ref physicsWorld); mineCart = null; cartSwitch.Dispose(ref physicsWorld); cartSwitch = null; } foreach (InteractiveEntity entity in interactiveEntities) { entity.Dispose(ref physicsWorld); } interactiveEntities.Clear(); }
/// <summary> /// Initializes a new instance of the <see cref="LevelManager"/> class. /// </summary> /// <param name="gameDisplayResolution">The resolution the game is set to render at.</param> /// <param name="frameTime">The frame time set for the game.</param> public LevelManager(Vector2 gameDisplayResolution, float frameTime) { this.startText = new RenderableText(); this.Complete = false; this.physicsWorld = null; this.gameDisplayResolution = gameDisplayResolution; this.frameTime = frameTime; this.physicsWorld = null; this.spriteBatch = null; this.floorSprite = new Sprite(); this.contentManager = null; this.levelLoader = null; this.floorEdges = new List<Body>(); this.visualFloorEdges = new List<VisualEdge>(); this.platforms = new List<Platform>(); this.interactiveEntities = new List<InteractiveEntity>(); this.stickman = null; this.exit = null; this.scrollingDeath = null; this.mineCart = null; this.cartSwitch = null; this.scrollStartTimer = 0.0f; this.background = new Background(this.gameDisplayResolution, 0.8f); this.maxScore = 0.0f; }
public void randomizeCart(MineCart mineCart, Boolean usedTNT) { mineCart.fontColor = Color.White; mineCart.contents = randomLetter().ToUpper(); if ((alphabet[mineCart.contents.ToLower()] >= 0f / 3f) && (alphabet[mineCart.contents.ToLower()] < 1f / 3f)) { mineCart.mineCartType = MineCartType.Gold1; } else if ((alphabet[mineCart.contents.ToLower()] >= 1f / 3f) && (alphabet[mineCart.contents.ToLower()] < 2f / 3f)) { mineCart.mineCartType = MineCartType.Gold2; } else if (alphabet[mineCart.contents.ToLower()] >= 2f / 3f) { mineCart.mineCartType = MineCartType.Gold3; } if (!usedTNT) { if ((numberOfTNT < maxNumberOfTNT) && (rand.NextDouble() < tntChance)) { if (mineCart.y >= 3) { numberOfTNT++; mineCart.mineCartType = MineCartType.TNT; mineCartsTNT.Add(mineCart); } } } }
public override void LoadContent(ContentManager content) { if (this.options != null) { this.options.TryGetValue("language", out this.language); } try { this.alphabet = content.Load<Dictionary<String, Double>>("data/alphabet_" + this.language); this.dictionary = content.Load<List<String>>("data/dictionary_" + this.language); if (this.language == "english") { bonusEnglish.Add(new bonusword( "adjective" , "able" , "capable" , "capable" )); bonusEnglish.Add(new bonusword( "adjective" , "agile" , "active" , "nimble, spry, quick" )); bonusEnglish.Add(new bonusword( "adjective" , "aloof" , "reserved" , "distant" )); bonusEnglish.Add(new bonusword( "adjective" , "amber" , "chromatic" , "yellowish" )); bonusEnglish.Add(new bonusword( "adjective" , "ample" , "large" , "sizable, capacious" )); bonusEnglish.Add(new bonusword( "adjective" , "arrogant" , "proud" , "self-important" )); bonusEnglish.Add(new bonusword( "adjective" , "astonishing" , "impressive" , "astounding, staggering" )); bonusEnglish.Add(new bonusword( "adjective" , "bad" , "evil" , "immoral, evil" )); bonusEnglish.Add(new bonusword( "adjective" , "bad" , "inferior" , "below average in quality" )); bonusEnglish.Add(new bonusword( "adjective" , "bad" , "stale" , "spoiled, spoilt, capable of harming" )); bonusEnglish.Add(new bonusword( "adjective" , "bald" , "hairless" , "lacking hair" )); bonusEnglish.Add(new bonusword( "adjective" , "bitter" , "resentful" , "acrimonious, resentful" )); bonusEnglish.Add(new bonusword( "adjective" , "bitter" , "tasty" , "bitter-tasting" )); bonusEnglish.Add(new bonusword( "adjective" , "black" , "undiluted" , "without cream or sugar" )); bonusEnglish.Add(new bonusword( "adjective" , "bland" , "tasteless" , "tasteless, insipid, flavorless" )); bonusEnglish.Add(new bonusword( "adjective" , "blank" , "empty" , "empty, not filled in" )); bonusEnglish.Add(new bonusword( "adjective" , "brown" , "chromatic" , "having a brown color" )); bonusEnglish.Add(new bonusword( "adjective" , "charismatic" , "attractive" , "possessing a magnetic personality" )); bonusEnglish.Add(new bonusword( "adjective" , "childish" , "immature" , "infantile" )); bonusEnglish.Add(new bonusword( "adjective" , "common" , "shared" , "mutual" )); bonusEnglish.Add(new bonusword( "adjective" , "constant" , "continuous" , "unending, incessant" )); bonusEnglish.Add(new bonusword( "adjective" , "critical" , "indispensable" , "vital urgently needed" )); bonusEnglish.Add(new bonusword( "adjective" , "crude" , "early" , "primitive" )); bonusEnglish.Add(new bonusword( "adjective" , "cruel" , "inhumane" , "brutal, barbarous" )); bonusEnglish.Add(new bonusword( "adjective" , "cute" , "attractive" , "attractive" )); bonusEnglish.Add(new bonusword( "adjective" , "deadly" , "fatal" , "lethal" )); bonusEnglish.Add(new bonusword( "adjective" , "decorative" , "nonfunctional" , "cosmetic, ornamental" )); bonusEnglish.Add(new bonusword( "adjective" , "delicate" , "breakable" , "fragile, frail, easily broken, sensitive" )); bonusEnglish.Add(new bonusword( "adjective" , "articulate" , "articulate" , "eloquent, well-spoken" )); bonusEnglish.Add(new bonusword( "adjective" , "eternal" , "permanent" , "everlasting, perpetual, unending" )); bonusEnglish.Add(new bonusword( "adjective" , "ethnic" , "social" , "cultural" )); bonusEnglish.Add(new bonusword( "adjective" , "exotic" , "foreign" , "foreign, alien" )); bonusEnglish.Add(new bonusword( "adjective" , "exotic" , "strange" , "unusual, strikingly strange" )); bonusEnglish.Add(new bonusword( "adjective" , "express" , "fast" , "without unnecessary stops" )); bonusEnglish.Add(new bonusword( "adjective" , "finished" , "destroyed" , "ruined" )); bonusEnglish.Add(new bonusword( "adjective" , "flat" , "horizontal" , "horizontally level" )); bonusEnglish.Add(new bonusword( "adjective" , "flawed" , "imperfect" , "imperfect, blemished, faulty" )); bonusEnglish.Add(new bonusword( "adjective" , "frank" , "direct" , "candid, blunt, forthright" )); bonusEnglish.Add(new bonusword( "adjective" , "free" , "unpaid" , "complimentary, costless, gratis" )); bonusEnglish.Add(new bonusword( "adjective" , "free" , "unoccupied" , "not occupied" )); bonusEnglish.Add(new bonusword( "adjective" , "fresh" , "forward" , "insolent, impertinent, impudent, sassy" )); bonusEnglish.Add(new bonusword( "adjective" , "frozen" , "unmelted" , "unthawed" )); bonusEnglish.Add(new bonusword( "adjective" , "full" , "nourished" , "replete, filled to satisfaction with food" )); bonusEnglish.Add(new bonusword( "adjective" , "funny" , "humorous" , "amusing, laughable" )); bonusEnglish.Add(new bonusword( "adjective" , "good" , "healthful" , "beneficial, salutary" )); bonusEnglish.Add(new bonusword( "adjective" , "good" , "righteous" , "just, upright, virtuous" )); bonusEnglish.Add(new bonusword( "adjective" , "grand" , "rich" , "luxurious, opulent, sumptuous" )); bonusEnglish.Add(new bonusword( "adjective" , "graphic" , "explicit" , "explicit, descriptive" )); bonusEnglish.Add(new bonusword( "adjective" , "graphic" , "realistic" , "pictorial, lifelike, vivid" )); bonusEnglish.Add(new bonusword( "adjective" , "great" , "important" , "outstanding, very valuable" )); bonusEnglish.Add(new bonusword( "adjective" , "great" , "large" , "large in size, number or extent" )); bonusEnglish.Add(new bonusword( "adjective" , "handy" , "convenient" , "easy to use" )); bonusEnglish.Add(new bonusword( "adjective" , "helpless" , "powerless" , "incapacitated" )); bonusEnglish.Add(new bonusword( "adjective" , "hilarious" , "humorous" , "uproarious" )); bonusEnglish.Add(new bonusword( "adjective" , "huge" , "large" , "immense, vast" )); bonusEnglish.Add(new bonusword( "adjective" , "ignorant" , "uneducated" , "lacking basic knowledge, naive, unsophisticated" )); bonusEnglish.Add(new bonusword( "adjective" , "immune" , "unsusceptible" , "resistant" )); bonusEnglish.Add(new bonusword( "adjective" , "incapable" , "inadequate" , "incompetent" )); bonusEnglish.Add(new bonusword( "adjective" , "jealous" , "desirous" , "covetous, envious" )); bonusEnglish.Add(new bonusword( "adjective" , "last" , "closing" , "concluding, final, terminal" )); bonusEnglish.Add(new bonusword( "adjective" , "late" , "unpunctual" , "belated, tardy" )); bonusEnglish.Add(new bonusword( "adjective" , "latest" , "fashionable" , "newest, up-to-date" )); bonusEnglish.Add(new bonusword( "adjective" , "lazy" , "idle" , "indolent, otiose, slothful, work-shy" )); bonusEnglish.Add(new bonusword( "adjective" , "lonely" , "unaccompanied" , "alone, lone, solitary" )); bonusEnglish.Add(new bonusword( "adjective" , "depressed" , "dejected" , "blue" )); bonusEnglish.Add(new bonusword( "adjective" , "main" , "important" , "chief, primary, principal" )); bonusEnglish.Add(new bonusword( "adjective" , "miserable" , "contemptible" , "abject, scummy, contemptible" )); bonusEnglish.Add(new bonusword( "adjective" , "monstrous" , "evil" , "atrocious, heinous" )); bonusEnglish.Add(new bonusword( "adjective" , "monstrous" , "ugly" , "grotesque" )); bonusEnglish.Add(new bonusword( "adjective" , "nervous" , "excitable" , "skittish" )); bonusEnglish.Add(new bonusword( "adjective" , "new" , "unaccustomed" , "unfamiliar" )); bonusEnglish.Add(new bonusword( "adjective" , "notorious" , "disreputable" , "ill-famed, infamous" )); bonusEnglish.Add(new bonusword( "adjective" , "obese" , "fat" , "overweight" )); bonusEnglish.Add(new bonusword( "adjective" , "obscure" , "inglorious" , "unknown" )); bonusEnglish.Add(new bonusword( "adjective" , "paralyzed" , "ill" , "paralytic, unable to move" )); bonusEnglish.Add(new bonusword( "adjective" , "particular" , "fastidious" , "finicky, fussy" )); bonusEnglish.Add(new bonusword( "adjective" , "particular" , "specific" , "peculiar, special" )); bonusEnglish.Add(new bonusword( "adjective" , "premature" , "early" , "untimely" )); bonusEnglish.Add(new bonusword( "adjective" , "private" , "personal" , "concerning things personal" )); bonusEnglish.Add(new bonusword( "adjective" , "rare" , "infrequent" , "infrequent, uncommon" )); bonusEnglish.Add(new bonusword( "adjective" , "real" , "true" , "actual, genuine" )); bonusEnglish.Add(new bonusword( "adjective" , "reckless" , "bold" , "foolhardy" )); bonusEnglish.Add(new bonusword( "adjective" , "restless" , "unquiet" , "antsy, itchy, fidgety" )); bonusEnglish.Add(new bonusword( "adjective" , "retired" , "inactive" , "no longer active in your work" )); bonusEnglish.Add(new bonusword( "adjective" , "romantic" , "loving" , "amatory, amorous" )); bonusEnglish.Add(new bonusword( "adjective" , "rotten" , "unsound" , "decayed, rotted" )); bonusEnglish.Add(new bonusword( "adjective" , "rotten" , "bad" , "crappy, lousy, shitty, stinking, stinky" )); bonusEnglish.Add(new bonusword( "adjective" , "satisfied" , "mitigated" , "quenched, slaked" )); bonusEnglish.Add(new bonusword( "adjective" , "secular" , "profane" , "laic, lay" )); bonusEnglish.Add(new bonusword( "adjective" , "shallow" , "superficial" , "lacking depth of intellect or knowledge or feeling" )); bonusEnglish.Add(new bonusword( "adjective" , "shy" , "unconfident" , "timid, diffident" )); bonusEnglish.Add(new bonusword( "adjective" , "single" , "unshared" , "individual, separate" )); bonusEnglish.Add(new bonusword( "adjective" , "sticky" , "adhesive" , "gluey, glutinous, gummy" )); bonusEnglish.Add(new bonusword( "adjective" , "muggy" , "wet" , "sticky, steamy" )); bonusEnglish.Add(new bonusword( "adjective" , "still" , "nonmoving" , "inactive, motionless, static" )); bonusEnglish.Add(new bonusword( "adjective" , "strong" , "alcoholic" , "hard, having a high alcoholic content" )); bonusEnglish.Add(new bonusword( "adjective" , "strong" , "forceful" , "firm" )); bonusEnglish.Add(new bonusword( "adjective" , "strong" , "invulnerable" , "secure, unattackable" )); bonusEnglish.Add(new bonusword( "adjective" , "stunning" , "beautiful" , "strikingly beautiful or attractive" )); bonusEnglish.Add(new bonusword( "adjective" , "supplementary" , "secondary" , "auxiliary, subsidiary" )); bonusEnglish.Add(new bonusword( "adjective" , "talkative" , "voluble" , "chatty, gabby, garrulous" )); bonusEnglish.Add(new bonusword( "adjective" , "terminal" , "last" , "endmost" )); bonusEnglish.Add(new bonusword( "adjective" , "thoughtful" , "considerate" , "considerate, showing concern" )); bonusEnglish.Add(new bonusword( "adjective" , "transparent" , "thin" , "see-through, sheer" )); bonusEnglish.Add(new bonusword( "adjective" , "trivial" , "ordinary" , "banal, commonplace" )); bonusEnglish.Add(new bonusword( "adjective" , "unanimous" , "accordant" , "in complete agreement" )); bonusEnglish.Add(new bonusword( "adjective" , "unique" , "incomparable" , "unequaled, unparalleled" )); bonusEnglish.Add(new bonusword( "adjective" , "global" , "comprehensive" , "universal, worldwide" )); bonusEnglish.Add(new bonusword( "adjective" , "unlawful" , "illegal" , "illegitimate, illicit" )); bonusEnglish.Add(new bonusword( "adjective" , "vain" , "proud" , "self-conceited, swollen-headed" )); bonusEnglish.Add(new bonusword( "adjective" , "viable" , "possible" , "feasible, practicable, workable" )); bonusEnglish.Add(new bonusword( "adjective" , "vigorous" , "robust" , "strong physically or mentally" )); bonusEnglish.Add(new bonusword( "adjective" , "young" , "young" , "youthful" )); } else this.bonus = content.Load<List<String>>("data/bonus_" + this.language); } catch (ContentLoadException e) { Console.Out.WriteLine("Error: " + e.Message + "\nDefaulting to english"); this.alphabet = content.Load<Dictionary<String, Double>>("data/alphabet_english"); this.dictionary = content.Load<List<String>>("data/dictionary_english"); this.bonusEnglish = content.Load<List<bonusword>>("data/bonus_english"); } newBonusWord(); this.popupScoreScene.LoadContent(content); this.popupMenuScene.LoadContent(content); this.popupLoseScene.LoadContent(content); this.popupBonusScene.LoadContent(content); this.popupQuizScene.LoadContent(content); for (int i = 0; i < CART_COLUMNS; i++) { for (int j = 0; j < CART_MAX_ROWS; j++) { if (((i % 2) == 0) && (j >= CART_MIN_ROWS)) { mineCarts[i, j] = null; } else { mineCarts[i, j] = new MineCart(); } if (mineCarts[i, j] != null) { mineCarts[i, j].x = i; mineCarts[i, j].y = j; mineCarts[i, j].position.X = CART_OFFSET_X + (i * CART_SPACING_X); mineCarts[i, j].position.Y = -CART_OFFSET_Y; mineCarts[i, j].contents = randomLetter().ToUpper(); if ((alphabet[mineCarts[i, j].contents.ToLower()] >= 0f / 3f) && (alphabet[mineCarts[i, j].contents.ToLower()] < 1f / 3f)) { mineCarts[i, j].mineCartType = MineCartType.Gold1; } else if ((alphabet[mineCarts[i, j].contents.ToLower()] >= 1f / 3f) && (alphabet[mineCarts[i, j].contents.ToLower()] < 2f / 3f)) { mineCarts[i, j].mineCartType = MineCartType.Gold2; } else if (alphabet[mineCarts[i, j].contents.ToLower()] >= 2f / 3f) { mineCarts[i, j].mineCartType = MineCartType.Gold3; } mineCarts[i, j].zindex = 0.3f; gameObjects.Add(mineCarts[i, j]); } } } base.LoadContent(content); }
private Boolean isMineCartAdjacent(MineCart lastMineCart, MineCart currentMineCart) { Boolean flag = false; if (currentMineCart.x == lastMineCart.x) { if ((currentMineCart.y == lastMineCart.y - 1) || (currentMineCart.y == lastMineCart.y + 1)) { flag = true; } } else if (currentMineCart.x == lastMineCart.x - 1) { if ((currentMineCart.x % 2) == 0) { if ((currentMineCart.y == lastMineCart.y) || (currentMineCart.y == lastMineCart.y - 1)) { flag = true; } } else { if ((currentMineCart.y == lastMineCart.y) || (currentMineCart.y == lastMineCart.y + 1)) { flag = true; } } } else if (currentMineCart.x == lastMineCart.x + 1) { if ((currentMineCart.x % 2) == 0) { if ((currentMineCart.y == lastMineCart.y) || (currentMineCart.y == lastMineCart.y - 1)) { flag = true; } } else { if ((currentMineCart.y == lastMineCart.y) || (currentMineCart.y == lastMineCart.y + 1)) { flag = true; } } } return flag; }
private List<MineCart> getAdjacentMineCarts(MineCart currentMineCart) { List<MineCart> adjacentMineCarts = new List<MineCart>(); if (currentMineCart.y > 0) { if (mineCarts[currentMineCart.x, currentMineCart.y - 1] != null) { adjacentMineCarts.Add(mineCarts[currentMineCart.x, currentMineCart.y - 1]); } } if ((currentMineCart.x) % 2 == 0) { if (currentMineCart.y < CART_MIN_ROWS - 1) { if (mineCarts[currentMineCart.x, currentMineCart.y + 1] != null) { adjacentMineCarts.Add(mineCarts[currentMineCart.x, currentMineCart.y + 1]); } } if (currentMineCart.x > 0) { if (mineCarts[currentMineCart.x - 1, currentMineCart.y] != null) { adjacentMineCarts.Add(mineCarts[currentMineCart.x - 1, currentMineCart.y]); } if (currentMineCart.y < CART_MAX_ROWS - 1) { if (mineCarts[currentMineCart.x - 1, currentMineCart.y + 1] != null) { adjacentMineCarts.Add(mineCarts[currentMineCart.x - 1, currentMineCart.y + 1]); } } } if (currentMineCart.x < CART_COLUMNS - 1) { if (mineCarts[currentMineCart.x + 1, currentMineCart.y] != null) { adjacentMineCarts.Add(mineCarts[currentMineCart.x + 1, currentMineCart.y]); } if (currentMineCart.y < CART_MAX_ROWS - 1) { if (mineCarts[currentMineCart.x + 1, currentMineCart.y + 1] != null) { adjacentMineCarts.Add(mineCarts[currentMineCart.x + 1, currentMineCart.y + 1]); } } } } else { if (currentMineCart.y < CART_MAX_ROWS - 1) { if (mineCarts[currentMineCart.x, currentMineCart.y + 1] != null) { adjacentMineCarts.Add(mineCarts[currentMineCart.x, currentMineCart.y + 1]); } } if (currentMineCart.x > 0) { if (mineCarts[currentMineCart.x - 1, currentMineCart.y] != null) { adjacentMineCarts.Add(mineCarts[currentMineCart.x - 1, currentMineCart.y]); } if (currentMineCart.y > 0) { if (mineCarts[currentMineCart.x - 1, currentMineCart.y - 1] != null) { adjacentMineCarts.Add(mineCarts[currentMineCart.x - 1, currentMineCart.y - 1]); } } } if (currentMineCart.x < CART_COLUMNS - 1) { if (mineCarts[currentMineCart.x + 1, currentMineCart.y] != null) { adjacentMineCarts.Add(mineCarts[currentMineCart.x + 1, currentMineCart.y]); } if (currentMineCart.y > 0) { if (mineCarts[currentMineCart.x + 1, currentMineCart.y - 1] != null) { adjacentMineCarts.Add(mineCarts[currentMineCart.x + 1, currentMineCart.y - 1]); } } } } return adjacentMineCarts; }
public void removeMineCart(MineCart temp, Boolean usedTNT) { mineCarts[temp.x, temp.y] = null; for (int k = temp.y + 1; k < CART_MAX_ROWS; k++) { if (mineCarts[temp.x, k] != null) { mineCarts[temp.x, k - 1] = mineCarts[temp.x, k]; mineCarts[temp.x, k - 1].fontColor = Color.White; mineCarts[temp.x, k - 1].x = temp.x; mineCarts[temp.x, k - 1].y = k - 1; mineCarts[temp.x, k] = null; } } temp.position.X = CART_OFFSET_X + (temp.x * CART_SPACING_X); temp.position.Y = -CART_OFFSET_Y - ((CART_MAX_ROWS - temp.y) * CART_SPACING_Y); if ((temp.x % 2) == 0) { temp.y = CART_MAX_ROWS - 2; } else { temp.y = CART_MAX_ROWS - 1; } randomizeCart(temp, usedTNT); mineCarts[temp.x, temp.y] = temp; }
/// <summary> /// Disposes of the interactive entities and clears the list. /// </summary> /// <param name="physicsWorld">The physics world containing the entities' bodies.</param> /// <param name="interactiveEntities">the list of interactive entities.</param> /// <param name="mineCart">The mine cart.</param> /// <param name="cartSwitch">The switch entity.</param> public static void DisposeOfInteractiveEntities(ref World physicsWorld, ref List <InteractiveEntity> interactiveEntities, ref MineCart mineCart, ref Switch cartSwitch) { if (mineCart != null) { mineCart.Dispose(ref physicsWorld); mineCart = null; cartSwitch.Dispose(ref physicsWorld); cartSwitch = null; } foreach (InteractiveEntity entity in interactiveEntities) { entity.Dispose(ref physicsWorld); } interactiveEntities.Clear(); }