public override void MapLoaded(TeeEngine engine, TiledMap map, MapEventArgs mapEventArgs) { LightShader lightShader = (LightShader)engine.GetPostGameShader("LightShader"); lightShader.Enabled = true; base.MapLoaded(engine, map, mapEventArgs); }
public override void MapLoaded(TeeEngine engine, TiledMap map, MapEventArgs mapEventArgs) { LightShader lightShader = (LightShader)engine.GetPostGameShader("LightShader"); lightShader.Enabled = false; Random random = new Random(); for (int i = 0; i < 50; i++) { int px = (int)Math.Ceiling(random.NextDouble() * engine.Map.pxWidth); int py = (int)Math.Ceiling(random.NextDouble() * engine.Map.pxHeight); Bat bat = new Bat(px, py); Coin coin = new Coin(px, py, 100, (CoinType)random.Next(3)); // Switch between adding bats and coins to the map. if (i % 2 == 0) engine.AddEntity(bat); else engine.AddEntity(coin); } base.MapLoaded(engine, map, mapEventArgs); }
public void MapLoaded(TeeEngine engine, TiledMap map, MapEventArgs args) { engine.GetPostGameShader("LightShader").Enabled = false; _player = (Hero)engine.GetEntity("Player"); // The player should start with zero intensity _player.Intensity = 0; _spawners = new List<MobSpawner>(); List<Entity> entities = new List<Entity>(engine.GetEntities()); foreach (Entity e in entities) { if (e is MobSpawner) _spawners.Add((MobSpawner)e); } // Setup and load the UI Hud = new ArenaUI(engine.Game); List<Component> hudComponents = Component.LoadComponentsFromXml("HUD/Elements/Components.ui", engine.Game.Content); foreach (Component c in hudComponents) Hud.AddComponent(c.Name, c); // Bind data to components if (_player != null) { Label label = (Label)Hud.GetComponent("HeroLevel"); if (label != null) label.SetDataBinding("Level", _player); label = (Label)Hud.GetComponent("HeroStrength"); if (label != null) label.SetDataBinding("Strength", _player); label = (Label)Hud.GetComponent("HeroDexterity"); if (label != null) label.SetDataBinding("Dexterity", _player); label = (Label)Hud.GetComponent("HeroWisdom"); if (label != null) label.SetDataBinding("Wisdom", _player); Button cheat = (Button)Hud.GetComponent("CheatButton"); if(cheat != null) cheat.onMouseClick += new Component.MouseEventHandler(delegate(Component sender, MouseState mouse) { _player.LevelUp(); _player.HP = _player.MaxHP; }); _player.onItemEquipped += new NPC.OnItemEquippedEventHandler(NPC_onItemEquiped); _player.onItemUnEquipped += new NPC.OnItemUnEquippedEventHandler(NPC_onItemUnEquiped); _player.onDeath += new NPC.OnDeathEventHandler(NPC_onDeath); // Load the currently equipped items foreach (KeyValuePair<ItemType, Item> pair in _player.Equiped) { NPC_onItemEquiped(_player, pair.Value); } } _mapLoaded = true; }