protected override async Task OnActivatedAsync(ActorActivationDetails details) { endText = details.Params[1]; canHurtPlayer = false; isInvulnerable = true; canBeFrozen = false; health = int.MaxValue; maxHealth = int.MaxValue; scoreValue = 0; lastHealth = health; CollisionFlags |= CollisionFlags.IsSolidObject | CollisionFlags.SkipPerPixelCollisions; stepSize = 0.3f; switch (levelHandler.Difficulty) { case GameDifficulty.Easy: stepSize *= 1.3f; break; case GameDifficulty.Hard: stepSize *= 0.7f; break; } await RequestMetadataAsync("Boss/Queen"); SetAnimation(AnimState.Idle); // Invisible block above the queen block = new InvisibleBlock(); block.OnActivated(new ActorActivationDetails { LevelHandler = levelHandler }); levelHandler.AddActor(block); }
public void Handle(ICollidable player, ICollidable invisibleBlock, CollisionDirection.DirectionTag direction) { if (typeof(IMario).IsInstanceOfType(player) && typeof(InvisibleBlock).IsInstanceOfType(invisibleBlock)) { this.player = (IMario)player; this.invisibleBlock = (InvisibleBlock)invisibleBlock; Console.WriteLine(invisibleBlock.GetHitBox().X + " " + invisibleBlock.GetHitBox().Y); switch (direction) { case CollisionDirection.DirectionTag.Top: break; case CollisionDirection.DirectionTag.Bottom: this.player.SetYPosition(this.invisibleBlock.GetBottomSide() + 1); this.invisibleBlock.Bump(); this.invisibleBlock.EndBump(); break; case CollisionDirection.DirectionTag.Left: break; case CollisionDirection.DirectionTag.Right: break; default: Console.WriteLine("Unexpected Direction Received in Collision.PlayerWithInvisibleBlock"); break; } } }
public override void OnAttach(ActorInstantiationDetails details) { base.OnAttach(details); endText = details.Params[1]; canHurtPlayer = false; isInvulnerable = true; canBeFrozen = false; maxHealth = health = int.MaxValue; scoreValue = 0; lastHealth = health; collisionFlags |= CollisionFlags.IsSolidObject; stepSize = 0.3f; switch (api.Difficulty) { case GameDifficulty.Easy: stepSize *= 1.3f; break; case GameDifficulty.Hard: stepSize *= 0.7f; break; } RequestMetadata("Boss/Queen"); SetAnimation(AnimState.Idle); // Invisible block above the queen block = new InvisibleBlock(); block.OnAttach(new ActorInstantiationDetails { Api = api }); api.AddActor(block); }
public override void OnDestroyed() { if (block != null) { levelHandler.RemoveActor(block); block = null; } }
protected override void OnDeactivated(Component.ShutdownContext context) { if (block != null) { api.RemoveActor(block); block = null; } base.OnDeactivated(context); }
private Entity LoadBlock(Vector2 pos, string collisionType, string blocktype) { Block block; Block doorHalf; switch (blocktype) { case "walls": block = new Wall(LevelMapSpriteFactory.Instance.CreateExterior(), pos); Constants.SetLayerDepth(block, Constants.LayerDepth.Room); break; case "entrance": block = new Block(LevelMapSpriteFactory.Instance.CreateRoomEntrance(), pos); Constants.SetLayerDepth(block, Constants.LayerDepth.Room); break; case "empty": block = new Block(LevelMapSpriteFactory.Instance.CreateRoomEmpty(), pos); Constants.SetLayerDepth(block, Constants.LayerDepth.Room); break; case "black": block = new Block(LevelMapSpriteFactory.Instance.CreateRoomBlack(), pos); Constants.SetLayerDepth(block, Constants.LayerDepth.Room); break; case "itemroom": block = new Block(LevelMapSpriteFactory.Instance.CreateRoomItem(), pos); Constants.SetLayerDepth(block, Constants.LayerDepth.Room); break; case "downdoor": block = new Door(LevelMapSpriteFactory.Instance.CreateDownOpen(), pos); doorHalf = new Block(LevelMapSpriteFactory.Instance.CreateDownOpenHalf(), new Vector2(0, 64)); Constants.SetLayerDepth(doorHalf, Constants.LayerDepth.Door_Top); Scene.Add(doorHalf); block.GetComponent <Transform>().AddChild(doorHalf); break; case "leftdoor": block = new Door(LevelMapSpriteFactory.Instance.CreateLeftOpen(), pos); doorHalf = new Block(LevelMapSpriteFactory.Instance.CreateLeftOpenHalf(), new Vector2(0, 0)); Constants.SetLayerDepth(doorHalf, Constants.LayerDepth.Door_Top); Scene.Add(doorHalf); block.GetComponent <Transform>().AddChild(doorHalf); break; case "rightdoor": block = new Door(LevelMapSpriteFactory.Instance.CreateRightOpen(), pos); doorHalf = new Block(LevelMapSpriteFactory.Instance.CreateRightOpenHalf(), new Vector2(64, 0)); Constants.SetLayerDepth(doorHalf, Constants.LayerDepth.Door_Top); Scene.Add(doorHalf); block.GetComponent <Transform>().AddChild(doorHalf); break; case "updoor": block = new Door(LevelMapSpriteFactory.Instance.CreateTopOpen(), pos); doorHalf = new Block(LevelMapSpriteFactory.Instance.CreateTopOpenHalf(), new Vector2(0, 0)); Constants.SetLayerDepth(doorHalf, Constants.LayerDepth.Door_Top); Scene.Add(doorHalf); block.GetComponent <Transform>().AddChild(doorHalf); break; case "downwall": block = new Door(LevelMapSpriteFactory.Instance.CreateDownWall(), pos, Door.Type.Wall); break; case "leftwall": block = new Door(LevelMapSpriteFactory.Instance.CreateLeftWall(), pos, Door.Type.Wall); break; case "rightwall": block = new Door(LevelMapSpriteFactory.Instance.CreateRightWall(), pos, Door.Type.Wall); break; case "upwall": block = new Door(LevelMapSpriteFactory.Instance.CreateTopWall(), pos, Door.Type.Wall); break; case "downlock": block = new Door(LevelMapSpriteFactory.Instance.CreateDownLock(), pos, Door.Type.Locked); doorHalf = new Block(LevelMapSpriteFactory.Instance.CreateDownOpenHalf(), new Vector2(0, 64)); Constants.SetLayerDepth(doorHalf, Constants.LayerDepth.Door_Top); Scene.Add(doorHalf); block.GetComponent <Transform>().AddChild(doorHalf); break; case "leftlock": block = new Door(LevelMapSpriteFactory.Instance.CreateLeftLock(), pos, Door.Type.Locked); doorHalf = new Block(LevelMapSpriteFactory.Instance.CreateLeftOpenHalf(), new Vector2(0, 0)); Constants.SetLayerDepth(doorHalf, Constants.LayerDepth.Door_Top); Scene.Add(doorHalf); block.GetComponent <Transform>().AddChild(doorHalf); break; case "rightlock": block = new Door(LevelMapSpriteFactory.Instance.CreateRightLock(), pos, Door.Type.Locked); doorHalf = new Block(LevelMapSpriteFactory.Instance.CreateRightOpenHalf(), new Vector2(64, 0)); Constants.SetLayerDepth(doorHalf, Constants.LayerDepth.Door_Top); Scene.Add(doorHalf); block.GetComponent <Transform>().AddChild(doorHalf); break; case "uplock": block = new Door(LevelMapSpriteFactory.Instance.CreateTopLock(), pos, Door.Type.Locked); doorHalf = new Block(LevelMapSpriteFactory.Instance.CreateTopOpenHalf(), new Vector2(0, 0)); Constants.SetLayerDepth(doorHalf, Constants.LayerDepth.Door_Top); Scene.Add(doorHalf); block.GetComponent <Transform>().AddChild(doorHalf); break; case "downbomb": block = new Door(LevelMapSpriteFactory.Instance.CreateDownWall(), pos, Door.Type.BombWall); break; case "leftbomb": block = new Door(LevelMapSpriteFactory.Instance.CreateLeftWall(), pos, Door.Type.BombWall); break; case "rightbomb": block = new Door(LevelMapSpriteFactory.Instance.CreateRightWall(), pos, Door.Type.BombWall); break; case "upbomb": block = new Door(LevelMapSpriteFactory.Instance.CreateTopWall(), pos, Door.Type.BombWall); break; case "downboss": block = new Door(LevelMapSpriteFactory.Instance.CreateDownBoss(), pos, Door.Type.Locked); break; case "leftboss": block = new Door(LevelMapSpriteFactory.Instance.CreateLeftBoss(), pos, Door.Type.Locked); block.name = "boss_door"; break; case "rightboss": block = new Door(LevelMapSpriteFactory.Instance.CreateRightBoss(), pos, Door.Type.Locked); break; case "upboss": block = new Door(LevelMapSpriteFactory.Instance.CreateTopBoss(), pos, Door.Type.Locked); break; case "statuedragon": block = new Block(LevelMapSpriteFactory.Instance.CreateStatueDragon(), pos); break; case "statueface": block = new Block(LevelMapSpriteFactory.Instance.CreateStatueFace(), pos); break; case "bluestatuedragon": block = new Block(LevelMapSpriteFactory.Instance.CreateBlueStatueDragon(), pos); break; case "bluestatueface": block = new Block(LevelMapSpriteFactory.Instance.CreateBlueStatueFace(), pos); break; case "raisedtile": block = new Block(LevelMapSpriteFactory.Instance.CreateTileRaised(), pos); break; case "stairs": block = new Block(LevelMapSpriteFactory.Instance.CreateTileStairs(), pos); break; case "navytile": block = new Block(LevelMapSpriteFactory.Instance.CreateTileNavy(), pos); break; case "water": block = new Block(LevelMapSpriteFactory.Instance.CreateTileBlue(), pos); break; case "invis": block = new InvisibleBlock(LevelMapSpriteFactory.Instance.CreateTileInvis(), pos); break; default: Console.WriteLine("Level @ LoadBlock(): Unrecognized blocktype \"" + blocktype + "\"!"); return(null); } // TODO: Slowly but surely we should create classes for each general type // of block (Door, Wall, MovableBlock, etc.) to avoid this collision logic. var coll = new Collider(); switch (collisionType) { case "movableU": coll.response = new MovableCollisionResponse(block, Constants.Direction.UP); break; case "movableD": coll.response = new MovableCollisionResponse(block, Constants.Direction.DOWN); break; case "movableL": coll.response = new MovableCollisionResponse(block, Constants.Direction.LEFT); break; case "movableR": coll.response = new MovableCollisionResponse(block, Constants.Direction.RIGHT); break; case "movableRK": coll.response = new MovableKeyCollisionResponse(block, Constants.Direction.RIGHT, Root.name); break; case "rigid": coll.response = new RigidCollisionResponse(block); break; //case "door": // coll.response = new DoorCollisionResponse(block); // break; case "invis": // already handled break; case "stairs00": coll.response = new StairsCollisionResponse(block, "0_0"); break; case "stairs10": coll.response = new StairsCollisionResponse(block, "1_0"); break; case "wall": // Already handled break; case "none": // no collision necessary break; default: //coll.response = new BaseCollisionResponse(block); break; } block.AddComponent(coll); Scene.Add(block); return(block); }
/// <summary> /// Maakt de blok aan /// </summary> /// <param name="id">Afhankelijk van de id zullen we een bepaalde blok aanmaken</param> /// <param name="content">ContentManager object dat we gebruiken om textures te laden</param> /// <returns>De aangemaakt blok</returns> protected override GameObject CreateBlock(int id, ContentManager content) { GameObject b = null; if (id == 1) { b = new DirtBlock(content, "01"); } else if (id == 2) { b = new GrassTopBlock(content, "04"); } else if (id == 3) { b = new GrassRightBLock(content, "08"); } else if (id == 4) { b = new LeftTopCornerBlock(content, "03"); } else if (id == 5) { b = new RightTopCornerBlock(content, "02"); } else if (id == 6) { b = new AcidMudLeftAndBottomBlock(content, "19"); } else if (id == 7) { b = new AcidMudBottomBlock(content, "15"); } else if (id == 8) { b = new AcidMudRightAndBottomBlock(content, "22"); } else if (id == 9) { b = new GrassLeftBlock(content, "07"); } else if (id == 10) { b = new LeftBottomCornerBlock(content, "10"); } else if (id == 11) { b = new RightBottomCornerBlock(content, "09"); } else if (id == 12) { b = new PlatformBlock(content, "plate1"); } else if (id == 13) { b = new BoxFirstVariant(content, "box1"); } else if (id == 14) { b = new BoxSecondVariant(content, "box2"); } else if (id == 15) { b = new Scarecrow(content, "scarecrow"); } else if (id == 16) { b = new Pointer(content, "pointer"); } else if (id == 17) { b = new OrangeTree(content, "tree1"); } else if (id == 18) { b = new YellowTree(content, "tree2"); } else if (id == 19) { b = new MovingBlock(content, "plate1"); } else if (id == 20) { b = new MovingBlock(content, "plate1") { Invert = true } } ; else if (id == 21) { b = new StarCollectable(content, "star"); } else if (id == 22) { b = new BouncingAcidBall(content, "LavaFireballSprite"); } else if (id == 23) { b = new UpUnderBlock(content, "bovenonder"); } else if (id == 24) { b = new LeftOverRoofBlock(content, "linksoverkaping"); } else if (id == 25) { b = new RightOverRoofBlock(content, "rechtsoverkaping"); } else if (id == 26) { b = new UnderBlock(content, "13"); } else if (id == 27) { b = new FullBlock(content, "11"); } else if (id == 30) { b = new GreenGoblin(content, "GreenGoblinSprite"); } else if (id == 31) { b = new Giant(content, "GiantSprite"); } else if (id == 32) { b = new Orc(content, "BlackGoblin"); } else if (id == 33) { b = new BlueGoblin(content, "BlueMonster"); } else if (id == 40) { b = new InvisibleBlock(content, "legeBlok"); } else if (id == 50) { b = new ButtonNextLevel(content, "button"); } return(b); }