public override void InitializeAgent() { base.InitializeAgent(); character = GetComponent <Character>(); startingPosition = transform.position; flagPole = FindObjectOfType <FlagPole>(); }
public void FlagPoleCreationTest() { var game = new GameObject("Mario"); ResourceManager.Instance.LoadSpriteSheetFromFile("sm-mario-sprites", @"resources\sm-mario-sprites.png", 10); ResourceManager.Instance.LoadFontFromFile("arial", @"resources\arial.ttf"); var s = new MainScene(game) { Name = "play" }; game.SceneManager.AddScene(s); var flagPole = new FlagPole(game); Assert.IsFalse(flagPole.HasUpwardVelocity, "Flag pole is moving upwards!"); Assert.IsFalse(flagPole.IgnoreAllCollisions, "Flag pole is uncollidable!"); Assert.IsFalse(flagPole.IgnorePlayerCollisions, "Flag pole is uncollidable by player!"); Assert.IsFalse(flagPole.IsJumping, "Flag pole is jumping!"); Assert.IsFalse(flagPole.IsMoving, "Flag pole is moving!"); Assert.IsFalse(flagPole.IsPlayer, "Flag pole is player!"); Assert.IsTrue(flagPole.IsStatic, "Flag pole is not static!"); Assert.IsTrue(flagPole.Visible, "Flag pole is invisible!"); Assert.IsTrue(flagPole.Acceleration == 0, "Flag pole is accelerating!"); Assert.IsTrue(flagPole.Velocity == 0, "Flag pole has non-zero velocity!"); Assert.IsFalse(flagPole.IsAffectedByGravity, "Flag pole shouldn't be affected by gravity until Mario touches it!"); }
protected override void OnSetContext() { GI.ShadeModel(ShadingModel.Smooth); GI.Hint(HintTarget.PolygonSmoothHint, HintMode.DontCare); GI.Buffers.ColorBuffer.Color = new ColorRGBA(0, 0, 0, 1); GI.PolygonMode(GLFace.FrontAndBack, PolygonMode.Line); GI.Features.Lighting.Enable(); GI.Features.Lighting.Light0.SetAmbientDiffuse(ambientLight, diffuseLight); GI.Features.Lighting.Light0.Location = positionLight; //GLC.Features.Lighting.Light0.Location = positionLight; GI.Features.Lighting.Light0.Enable(); GI.Features.ColorMaterial.Enable(); GI.ColorMaterial(GLFace.FrontAndBack, ColorMaterialParameter.AmbientAndDiffuse); GI.Features.DepthTest.Enable(); bandera.nWidth = nWidth; bandera.nHeight = nHeight; bandera.size = size; bandera.uTile = 1; bandera.vTile = 1; bandera.ini(timeStep); flagpole = new FlagPole(bandera.x0, bandera.y0, bandera.z0, bandera.nHeight, size); SetupTexture(); }
private static void LoadLevel(XmlReader reader) { Random random = new Random(); string objectType = ""; string objectName = ""; string location = ""; bool typeFlag = false; bool nameFlag = false; bool locationFlag = false; IList <IBlock> blockList = new List <IBlock>(); IList <IEnemy> enemyList = new List <IEnemy>(); IList <IItem> itemList = new List <IItem>(); while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name.ToString()) { case "ObjectType": objectType = reader.ReadString(); typeFlag = true; break; case "ObjectName": objectName = reader.ReadString(); nameFlag = true; break; case "Location": location = reader.ReadString(); locationFlag = true; break; } if (typeFlag && nameFlag && locationFlag) { switch (objectType) { case "Player": string[] coordinates = location.Split(' '); Mario.Instance.ConditionState = new SmallMarioState(Mario.Instance); Mario.Instance.Location = new Vector2(Int32.Parse(coordinates[0]), Int32.Parse(coordinates[1])); break; case "Block": switch (objectName) { case "HiddenBlock": string[] blockCoordinates = location.Split(' '); IBlock block = new HiddenBlock(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; case "HiddenBlockEmpty": blockCoordinates = location.Split(' '); block = new HiddenBlockEmpty(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; case "HiddenBlockCoin": blockCoordinates = location.Split(' '); block = new HiddenBlockCoin(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; case "HiddenBlockStar": blockCoordinates = location.Split(' '); block = new HiddenBlockStar(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; case "BrickBlock": blockCoordinates = location.Split(' '); block = new BrickBlock(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; case "BrickBlockEmpty": blockCoordinates = location.Split(' '); block = new BrickBlockEmpty(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; case "ItemBrick": blockCoordinates = location.Split(' '); block = new BrickBlockWithItem(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; case "ItemBrickCoin": blockCoordinates = location.Split(' '); block = new BrickBlockWithCoin(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; case "ItemBrickStar": blockCoordinates = location.Split(' '); block = new BrickBlockWithStar(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; case "QuestionBlock": blockCoordinates = location.Split(' '); block = new QuestionBlock(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; case "QuestionBlockEmpty": blockCoordinates = location.Split(' '); block = new QuestionBlockEmpty(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; case "QuestionBlockStar": blockCoordinates = location.Split(' '); block = new QuestionBlockStar(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; case "QuestionBlockCoin": blockCoordinates = location.Split(' '); block = new QuestionBlockCoin(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; case "UnbreakableBlock": blockCoordinates = location.Split(' '); block = new UnbreakableBlock(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; case "UsedBlock": blockCoordinates = location.Split(' '); block = new UsedBlock(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; case "GroundBlock": blockCoordinates = location.Split(' '); block = new GroundBlock(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; case "Pipe": blockCoordinates = location.Split(' '); block = new Pipe(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; case "PipeBottom": blockCoordinates = location.Split(' '); block = new PipeBottom(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; case "WarpPipe": blockCoordinates = location.Split(' '); WarpPipe pipe = new WarpPipe(); pipe.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); switch (pipe.Location.X) { case 1760: pipe.WarpDestination = new Vector2(8000, 384); break; case 8736: pipe.WarpDestination = new Vector2(2080, 352); break; } blockList.Add((IBlock)pipe); break; case "FlagPole": blockCoordinates = location.Split(' '); block = new FlagPole(); block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1])); blockList.Add(block); break; } break; case "Enemy": switch (objectName) { case "Goomba": string[] enemyCoordinates = location.Split(' '); IEnemy enemy = new Goomba(); enemy.RowId = random.Next(0, 160); enemy.Location = new Vector2(Int32.Parse(enemyCoordinates[0]), Int32.Parse(enemyCoordinates[1])); enemyList.Add(enemy); break; case "Koopa": enemyCoordinates = location.Split(' '); enemy = new Koopa(); enemy.RowId = random.Next(0, 160); enemy.Location = new Vector2(Int32.Parse(enemyCoordinates[0]), Int32.Parse(enemyCoordinates[1])); enemyList.Add(enemy); break; } break; case "Item": switch (objectName) { case "Coin": string[] itemCoordinates = location.Split(' '); IItem item = new Coin(); item.Location = new Vector2(Int32.Parse(itemCoordinates[0]), Int32.Parse(itemCoordinates[1])); itemList.Add(item); break; case "FireFlower": itemCoordinates = location.Split(' '); item = new FireFlower(); item.Location = new Vector2(Int32.Parse(itemCoordinates[0]), Int32.Parse(itemCoordinates[1])); itemList.Add(item); break; case "OneUpMush": itemCoordinates = location.Split(' '); item = new OneUpMushroom(); item.Location = new Vector2(Int32.Parse(itemCoordinates[0]), Int32.Parse(itemCoordinates[1])); itemList.Add(item); break; case "SuperMush": itemCoordinates = location.Split(' '); item = new SuperMushroom(); item.Location = new Vector2(Int32.Parse(itemCoordinates[0]), Int32.Parse(itemCoordinates[1])); itemList.Add(item); break; case "Star": itemCoordinates = location.Split(' '); item = new Star(); item.Location = new Vector2(Int32.Parse(itemCoordinates[0]), Int32.Parse(itemCoordinates[1])); itemList.Add(item); break; } break; } typeFlag = false; nameFlag = false; locationFlag = false; } } } PlayerLevel.Instance.BlockArray = blockList; PlayerLevel.Instance.EnemyArray = enemyList; PlayerLevel.Instance.ItemArray = itemList; }
static LevelLoader() { // Mario loader loaders.Add("mario", (game, x, y) => { game.Mario = new Entities.Mario.Mario(game, x, y); }); LevelLoader_Block1(); LevelLoader_Block2(); // Enemy loaders loaders.Add("goomba", (game, x, y) => { game.WorldLoader.Enemies.Add(new Goomba(game, x, y)); }); loaders.Add("koopa", (game, x, y) => { game.WorldLoader.Enemies.Add(new Koopa(game, x, y)); }); loaders.Add("boss", (game, x, y) => { game.WorldLoader.Enemies.Add(new Bowser(game, x - 1, y - 1)); }); loaders.Add("lakitu", (game, x, y) => { game.WorldLoader.Enemies.Add(new Lakitu(game, x, y)); }); // Pipe loader loaders.Add("pipeTop", (game, x, y) => { Pipe pipe = new Pipe("Top", game) { Position = new Vector2(x, y) }; game.WorldLoader.Pipes.Add(pipe); game.Map.SetBlock(x, y, pipe); game.Map.SetHiddenBlock(x, y + 1, pipe); game.Map.SetHiddenBlock(x + 1, y, pipe); game.Map.SetHiddenBlock(x + 1, y + 1, pipe); }); loaders.Add("UGpipeTop", (game, x, y) => { Pipe pipe = new Pipe("UGTop", game); pipe.Position = new Vector2(x, y); game.WorldLoader.Pipes.Add(pipe); game.Map.SetBlock(x, y, pipe); game.Map.SetHiddenBlock(x, y + 1, pipe); game.Map.SetHiddenBlock(x + 1, y, pipe); game.Map.SetHiddenBlock(x + 1, y + 1, pipe); }); loaders.Add("pipeBody", (game, x, y) => { Pipe pipeBody = new Pipe("Body", game); pipeBody.Position = new Vector2(x, y); game.WorldLoader.Pipes.Add(pipeBody); game.Map.SetBlock(x, y, pipeBody); game.Map.SetHiddenBlock(x + 1, y, pipeBody); }); loaders.Add("SWPipeEntrance", (game, x, y) => { Pipe pipeBody = new Pipe("SWEntrance", game); pipeBody.Position = new Vector2(x, y); game.WorldLoader.Pipes.Add(pipeBody); game.Map.SetBlock(x, y, pipeBody); game.Map.SetHiddenBlock(x + 1, y, pipeBody); game.Map.SetHiddenBlock(x, y + 1, pipeBody); game.Map.SetHiddenBlock(x + 1, y + 1, pipeBody); }); loaders.Add("SWPipeBody", (game, x, y) => { Pipe pipeBody = new Pipe("SWBody", game); pipeBody.Position = new Vector2(x, y); game.WorldLoader.Pipes.Add(pipeBody); game.Map.SetBlock(x, y, pipeBody); game.Map.SetBlock(x, y + 1, pipeBody); }); //Item loaders loaders.Add("coin", (game, x, y) => { IItem coin = new Coin(game, new Vector2(x, y - 1)); coin.Position = new Vector2(x, y); game.WorldLoader.Items.Add(coin); }); loaders.Add("flagPole", (game, x, y) => { IItem flagPole = new FlagPole(game); flagPole.Position = new Vector2(x, y); flagPole.Bounds = new Rectangle(x, y, 1, 12 - y); game.WorldLoader.Items.Add(flagPole); }); // Background loaders loaders.Add("bush", (game, x, y) => { IBackground bush = new Bush(); bush.Position = new Vector2(x, y); game.WorldLoader.Background.Add(bush); }); loaders.Add("bushMid", (game, x, y) => { IBackground bushmid = new BushMid(); bushmid.Position = new Vector2(x, y); game.WorldLoader.Background.Add(bushmid); }); loaders.Add("bushLong", (game, x, y) => { IBackground bushlong = new BushLong(); bushlong.Position = new Vector2(x, y); game.WorldLoader.Background.Add(bushlong); }); loaders.Add("hill", (game, x, y) => { IBackground hill = new Hill(); hill.Position = new Vector2(x, y); game.WorldLoader.Background.Add(hill); }); loaders.Add("cloud", (game, x, y) => { IBackground cloud = new Cloud(); cloud.Position = new Vector2(x, y); game.WorldLoader.Background.Add(cloud); }); loaders.Add("cloudMid", (game, x, y) => { IBackground cloudMid = new CloudMid(); cloudMid.Position = new Vector2(x, y); game.WorldLoader.Background.Add(cloudMid); }); loaders.Add("cloudLong", (game, x, y) => { IBackground cloudlong = new CloudLong(); cloudlong.Position = new Vector2(x, y); game.WorldLoader.Background.Add(cloudlong); }); loaders.Add("castle", (game, x, y) => { IBackground castle = new ToadCastle(); castle.Position = new Vector2(x, y); game.WorldLoader.Background.Add(castle); }); loaders.Add("flag", (game, x, y) => { Flag flag = new Flag(new Vector2(x, y)); game.WorldLoader.Background.Add(flag); }); loaders.Add("lavaTop", (game, x, y) => { IBackground lavatop = new LavaTop { Position = new Vector2(x, y) }; game.WorldLoader.Background.Add(lavatop); }); loaders.Add("LavaBot", (game, x, y) => { IBackground lavatop = new LavaBot { Position = new Vector2(x, y) }; game.WorldLoader.Background.Add(lavatop); }); loaders.Add("BridgeChain", (game, x, y) => { IBackground bc = new BridgeChain { Position = new Vector2(x, y) }; game.WorldLoader.Background.Add(bc); }); loaders.Add("Hammer", (game, x, y) => { game.WorldLoader.Items.Add(new Hammer(game, new Vector2(x, y))); }); }
private void OnLevelWon(FlagPole m, EventArgs e) { model.TransistGameWon(); }
public FlagSprite(FlagPole flagPole) { FlagPole = flagPole; destination = new Rectangle((int)FlagPole.Position.X + 32, (int)FlagPole.Position.Y, 32, 32); }
public void VictoryState(IMario mario, FlagPole flagPole) { game.VictoryState(mario, flagPole); }
public MarioWithFlagCollisionResponse(ICollision collision) { this.firstEntity = (IMario)collision.FirstEntity; this.secondEntity = (FlagPole)collision.SecondEntity; }
protected override void OnSetContext() { GI.Features.DepthTest.Enable(); GI.ShadeModel(ShadingModel.Smooth); GI.Hint(HintTarget.PolygonSmoothHint, HintMode.Nicest); GI.Buffers.ColorBuffer.Color = new ColorRGBA(0, 0, 0, 1); GI.PolygonMode(GLFace.FrontAndBack, PolygonMode.Line); GI.Features.Lighting.Enable(); GI.Features.Lighting.Light0.SetAmbientDiffuse(ambientLight, diffuseLight); GI.Features.Lighting.Light0.Location = positionLight; GI.Features.Lighting.Light0.Enable(); GI.Features.ColorMaterial.Enable(); GI.ColorMaterial(GLFace.FrontAndBack, ColorMaterialParameter.AmbientAndDiffuse); flagpole = new FlagPole(fBanner.x0, fBanner.y0, fBanner.z0, fBanner.nHeight, size); SetupTexture(); }