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 override void Update(GameTime gameTime, TeeEngine engine) { Hero player = (Hero)engine.GetEntity("Player"); KeyboardState keyboardState = Keyboard.GetState(); if (KeyboardExtensions.GetKeyDownState(keyboardState, Keys.S, this, true) && Entity.IntersectsWith(this, null, player, "Shadow", gameTime)) { if (CurrentDrawableState != "Open") { Random random = new Random(); CurrentDrawableState = "Open"; Drawables.ResetState("Open", gameTime); for (int i = 0; i < 10; i++) { Coin coin = new Coin(this.Pos.X, this.Pos.Y, 100, (CoinType)random.Next(3)); coin.Pos.X += (float)((random.NextDouble() - 0.5) * 100); coin.Pos.Y += (float)((random.NextDouble() - 0.5) * 100); engine.AddEntity(coin); } } } }
public virtual void MapLoaded(TeeEngine engine, TiledMap map, MapEventArgs mapEventArgs) { if (mapEventArgs.HasProperty("Target")) { Hero player = new Hero(); MapEntrance targetEntrance = (MapEntrance)engine.GetEntity(mapEventArgs.GetProperty("Target")); player.Pos = targetEntrance.Pos + new Vector2(targetEntrance.Width, targetEntrance.Height) / 2; engine.AddEntity("Player", player); } }
public override bool PreInitialize(GameTime gameTime, TeeEngine engine) { int coinx = (Width / CoinPadding); int coiny = (Height / CoinPadding); for (int i = 0; i < coinx; i++) { for (int j = 0; j < coiny; j++) { Coin coin = new Coin(); coin.CoinType = CoinType; coin.CoinValue = CoinValue; coin.Pos = new Vector2(Pos.X + i * CoinPadding, Pos.Y + j * CoinPadding); engine.AddEntity(coin); } } return(false); // Destory self when ready. }
public override void PostInitialize(GameTime gameTime, TeeEngine engine) { engine.AddEntity(LightSource); }