private void CreateGuards(IEnumerator<TextureBase.Entry> FreeSpaceForStuff)
		{
			for (int i = 0; i < 3; i++)
			{
				var g = CreateGuard();
				g.Position = FreeSpaceForStuff.Take().Do(kk => new Point(kk.XIndex + 0.5, kk.YIndex + 0.5));
				g.Direction = 0;

				// state machine for AI guard

				// each 3 secs turn 90 while not walking
				3000.AtInterval(
					delegate
					{
						if (g.WalkingAnimationRunning)
							return;
						
						var PossibleDestination = g.Position.MoveToArc(g.Direction, 1);

						var AsMapLocation = new PointInt32
						{
							X = PossibleDestination.x.Floor(),
							Y = PossibleDestination.y.Floor()
						};

						if (EgoView.Map.WallMap[AsMapLocation.X, AsMapLocation.Y] == 0)
						{
							// whee we can walk at this direction
							g.StartWalkingAnimation();

							const int StepsToBeTaken  = 100;

							(1000 / 15).AtInterval(
								t =>
								{
									g.Position = g.Position.MoveToArc(g.Direction, 1.0 / (double)StepsToBeTaken);

									if (t.currentCount == StepsToBeTaken)
									{
										t.stop();
										g.StopWalkingAnimation();
									}
								}
							);
							return;
						}

						// can we walk at that direction?
						g.Direction += 90.DegreesToRadians();

					}
				);
			}
		}
		public double GetGoodDirection(Point p)
		{
			var u = new PointInt32 { X = p.x.Floor(), Y = p.y.Floor() };

			if (EgoView.Map.WallMap[u.X + 1, u.Y] == 0)
				return 0.DegreesToRadians();
			else if (EgoView.Map.WallMap[u.X - 1, u.Y] == 0)
				return 180.DegreesToRadians();
			else if (EgoView.Map.WallMap[u.X, u.Y + 1] == 0)
				return 90.DegreesToRadians();
			else if (EgoView.Map.WallMap[u.X, u.Y - 1] == 0)
				return 270.DegreesToRadians();

			return 0;
		}
		private void EnterEndLevelMode()
		{
			var ScoreContainer = new Sprite().AttachTo(this);

			ScoreContainer.alpha = 0.8;

			var scroll = Assets.Default.scroll.AttachTo(ScoreContainer);
			var scroll_scale =  DefaultControlHeight / scroll.height;

			scroll.scaleX = scroll_scale;
			scroll.scaleY = scroll_scale;

			scroll.MoveTo(DefaultControlWidth - scroll.width, 0 );
			scroll.filters = new BitmapFilter[] { new DropShadowFilter() };

			new Bitmap(EgoView.Buffer.clone())
			{
				scaleX = DefaultScale,
				scaleY = DefaultScale
			}.AttachTo(this).FadeOutAndOrphanize(1000 / 24, 0.1);

			music.stop();

			EndLevelMode = true;
			MovementEnabled = false;

			var music_endlevel = Assets.Default.music_endlevel.play(1);


			this.EgoView.Image.filters = new BitmapFilter[] {
				Filters.GrayScaleFilter,
			};

			this.EgoView.ViewPositionLock = TheGoldStack.Position;
			this.EgoView.ViewPosition = TheGoldStack.Position;

			var FrozenLook = (45 + 180);

			var p = new PointInt32
			{
				X = (int)Math.Floor(TheGoldStack.Position.x),
				Y = (int)Math.Floor(TheGoldStack.Position.y),
			};

			// where should we look actually?
			if (EgoView.Map.WallMap[p.X - 1, p.Y] != 0)
				FrozenLook = (90 + 180);

			if (EgoView.Map.WallMap[p.X, p.Y - 1] != 0)
				FrozenLook = (0 + 180);

			this.EgoView.ViewDirection = FrozenLook.DegreesToRadians();

		

			1500.AtDelayDo(
				delegate
				{
					HudContainer.FadeOut(1000 / 15, 0.2,
						delegate
						{

						}
					);


					new TextField
					{
						defaultTextFormat = new TextFormat
						{
							size = 36,
						},
						text = "Level 7 Complete",

						textColor = 0xFFC526,
						autoSize = TextFieldAutoSize.LEFT,
						filters = new[] { new GlowFilter(0xC1931D) }
					}.AttachTo(ScoreContainer).MoveTo(scroll.x + 40, scroll.y + 64);

					// level ends for all

					// list current scores

					new TextField
					{
						defaultTextFormat = new TextFormat
						{
							size = 33,
						},
						text = "Player 1 - 1000$",

						textColor = 0xFFC526,
						autoSize = TextFieldAutoSize.LEFT,
						filters = new[] { new GlowFilter(0xC1931D) }
					}.AttachTo(ScoreContainer).MoveTo(scroll.x + 48, scroll.y + 96 + 33 * 1);

					new TextField
					{
						defaultTextFormat = new TextFormat
						{
							size = 30,
						},
						text = "Player 2 - 1200$",

						textColor = 0xbebebe,
						autoSize = TextFieldAutoSize.LEFT,
						filters = new[] { new GlowFilter(0x909090) }
					}.AttachTo(ScoreContainer).MoveTo(scroll.x + 48, scroll.y + 96 + 33 * 2);

					new TextField
					{
						defaultTextFormat = new TextFormat
						{
							size = 30,
						},
						text = "Player 3 - 1800$",

						textColor = 0xbebebe,
						autoSize = TextFieldAutoSize.LEFT,
						filters = new[] { new GlowFilter(0x909090) }
					}.AttachTo(ScoreContainer).MoveTo(scroll.x + 48, scroll.y + 96 + 33 * 3);


					music_endlevel.soundComplete +=
						delegate
						{
							// we are ready to continue...
							// are other players?

							ScoreContainer.FadeOut(1000 / 15, 0.1,
								delegate
								{
									ScoreContainer.Orphanize();

									//this.EgoView.Image.filters = null;
									//this.EgoView.ViewPositionLock = null;

									//EndLevelMode = false;
									//MovementEnabled = true;

									//HudContainer.alpha = 1;

									if (ReadyForNextLevel != null)
										ReadyForNextLevel();
								}
							);
						};
				}
			);

		}
Esempio n. 4
0
        private void AttachGuardLogic(SpriteInfoExtended g)
        {
            var TurnAndWalk = default(Action);
            var WalkToQueue = new Queue <Point>();

            TurnAndWalk =
                delegate
            {
                if (g.Health <= 0)
                {
                    return;
                }

                if (!this.EgoView.Sprites.Contains(g))
                {
                    return;
                }

                if (WalkToQueue.Count > 0)
                {
                    var p = WalkToQueue.Dequeue();

                    g.WalkTo(p.x, p.y);

                    if (Sync_GuardWalkTo != null)
                    {
                        Sync_GuardWalkTo(g.ConstructorIndexForSync, p);
                    }

                    return;
                }

                var PossibleDestination = g.Position.MoveToArc(g.Direction, 1);

                var AsMapLocation = new PointInt32
                {
                    X = PossibleDestination.x.Floor(),
                    Y = PossibleDestination.y.Floor()
                };

                if (EgoView.Map.WallMap[AsMapLocation.X, AsMapLocation.Y] == 0)
                {
                    WalkToQueue.Enqueue(g.Position.MoveToArc(g.Direction, 0.2));
                    WalkToQueue.Enqueue(g.Position.MoveToArc(g.Direction, 0.4));
                    WalkToQueue.Enqueue(g.Position.MoveToArc(g.Direction, 0.6));
                    WalkToQueue.Enqueue(g.Position.MoveToArc(g.Direction, 0.8));
                    WalkToQueue.Enqueue(g.Position.MoveToArc(g.Direction, 1.0));
                }
                else
                {
                    g.Direction += 90.DegreesToRadians();

                    if (Sync_GuardLookAt != null)
                    {
                        Sync_GuardLookAt(g.ConstructorIndexForSync, g.Direction);
                    }
                }

                3000.AtDelayDo(TurnAndWalk);
            };

            g.WalkToDone +=
                delegate
            {
                TurnAndWalk();
            };

            g.WalkToTeleported +=
                delegate
            {
                TurnAndWalk();
            };

            TurnAndWalk();
        }
		private void EnterEndLevelMode()
		{
			var ScoreContainer = new Sprite().AttachTo(this);

			ScoreContainer.alpha = 0.8;

			var scroll = Assets.Default.scroll.AttachTo(ScoreContainer);
			var scroll_scale = DefaultControlHeight / scroll.height;

			scroll.scaleX = scroll_scale;
			scroll.scaleY = scroll_scale;

			scroll.MoveTo(DefaultControlWidth - scroll.width, 0);
			scroll.filters = new BitmapFilter[] { new DropShadowFilter() };

			new Bitmap(EgoView.Buffer.clone())
			{
				scaleX = DefaultScale,
				scaleY = DefaultScale
			}.AttachTo(this).FadeOutAndOrphanize(1000 / 24, 0.1);

			music.stop();

			EndLevelMode = true;
			MovementEnabled_IsInGame = false;

			var music_endlevel = Assets.Default.Sounds.music_endlevel.play(1);


			this.EgoView.Image.filters = new BitmapFilter[] {
				Filters.GrayScaleFilter,
			};

			this.EgoView.ViewPositionLock = TheGoldStack.Position;
			this.EgoView.ViewPosition = TheGoldStack.Position;

			var FrozenLook = (45 + 180);

			var p = new PointInt32
			{
				X = (int)Math.Floor(TheGoldStack.Position.x),
				Y = (int)Math.Floor(TheGoldStack.Position.y),
			};

			// where should we look actually?
			if (EgoView.Map.WallMap[p.X - 1, p.Y] != 0)
				FrozenLook = (90 + 180);

			if (EgoView.Map.WallMap[p.X, p.Y - 1] != 0)
				FrozenLook = (0 + 180);

			this.EgoView.ViewDirection = FrozenLook.DegreesToRadians();



			1500.AtDelayDo(
				delegate
				{
					HudContainer.FadeOut(1000 / 15, 0.2,
						delegate
						{
							CompassContainer.alpha = 0;
						}
					);


			
					// level ends for all

					// list current scores


					1000.Chain(
						delegate
						{
							Assets.Default.Sounds.gunshot.play();

							new TextField
							{
								defaultTextFormat = new TextFormat
								{
									size = 36,
								},
								text = "Level " + CurrentLevel + " Complete",

								textColor = 0xFFC526,
								autoSize = TextFieldAutoSize.LEFT,
								filters = new[] { new GlowFilter(0xC1931D) }
							}.AttachTo(ScoreContainer).MoveTo(scroll.x + 40, scroll.y + 64);

						}
					).Chain(
						delegate
						{
							Assets.Default.Sounds.gunshot.play();

							new TextField
							{
								defaultTextFormat = new TextFormat
								{
									size = 33,
								},
								text = "Blazkowicz - " + CurrentLevelScore + "$",

								textColor = 0xFFC526,
								autoSize = TextFieldAutoSize.LEFT,
								filters = new[] { new GlowFilter(0xC1931D) }
							}.AttachTo(ScoreContainer).MoveTo(scroll.x + 48, scroll.y + 96 + 33 * 1);

						}
					).Chain(
						delegate
						{
							Assets.Default.Sounds.gunshot.play();
							new TextField
							{
								defaultTextFormat = new TextFormat
								{
									size = 30,
								},
								text = "Player 2 - 1200$",

								textColor = 0xbebebe,
								autoSize = TextFieldAutoSize.LEFT,
								filters = new[] { new GlowFilter(0x909090) }
							}.AttachTo(ScoreContainer).MoveTo(scroll.x + 48, scroll.y + 96 + 33 * 2);

						}
					).Chain(
						delegate
						{
							Assets.Default.Sounds.gunshot.play();
							new TextField
							{
								defaultTextFormat = new TextFormat
								{
									size = 30,
								},
								text = "Player 3 - 1800$",

								textColor = 0xbebebe,
								autoSize = TextFieldAutoSize.LEFT,
								filters = new[] { new GlowFilter(0x909090) }
							}.AttachTo(ScoreContainer).MoveTo(scroll.x + 48, scroll.y + 96 + 33 * 3);
						}
					).Do();

					var ReadyToContinue = default(Action);
					var onClick = default(Action<MouseEvent>);
					var onKeyUp = default(Action<KeyboardEvent>);


					ReadyToContinue =
						delegate
						{
							ReadyToContinue = delegate { };

							ScoreContainer.FadeOut(
								delegate
								{
									ScoreContainer.Orphanize();

									EgoView.Image.FadeOut(ReadyForNextLevel);
								}
							);

							stage.keyUp -= onKeyUp;
							stage.click -= onClick;

						};

					music_endlevel.soundComplete +=
						delegate
						{
							// we are ready to continue...
							// are other players?

							ReadyToContinue();

						};


					onClick =
						delegate
						{
							if (!MovementEnabled_IsFocused)
								return;

							music_endlevel.stop();
							ReadyToContinue();

						};

					stage.click += onClick;



					onKeyUp =
						delegate
						{
							if (!MovementEnabled_IsFocused)
								return;

							music_endlevel.stop();
							ReadyToContinue();

						};

					stage.click += onClick;

					stage.keyUp += onKeyUp;

					// should add click / any key to dismiss this menu
				}
			);

		}
		private void AttachGuardLogic(SpriteInfoExtended g)
		{
			var TurnAndWalk = default(Action);
			var WalkToQueue = new Queue<Point>();

			TurnAndWalk =
				delegate
				{
					if (g.Health <= 0)
						return;

					if (!this.EgoView.Sprites.Contains(g))
						return;

					if (WalkToQueue.Count > 0)
					{
						var p = WalkToQueue.Dequeue();

						g.WalkTo(p.x, p.y);

						if (Sync_GuardWalkTo != null)
							Sync_GuardWalkTo(g.ConstructorIndexForSync, p);

						return;
					}

					var PossibleDestination = g.Position.MoveToArc(g.Direction, 1);

					var AsMapLocation = new PointInt32
					{
						X = PossibleDestination.x.Floor(),
						Y = PossibleDestination.y.Floor()
					};

					if (EgoView.Map.WallMap[AsMapLocation.X, AsMapLocation.Y] == 0)
					{
						WalkToQueue.Enqueue(g.Position.MoveToArc(g.Direction, 0.2));
						WalkToQueue.Enqueue(g.Position.MoveToArc(g.Direction, 0.4));
						WalkToQueue.Enqueue(g.Position.MoveToArc(g.Direction, 0.6));
						WalkToQueue.Enqueue(g.Position.MoveToArc(g.Direction, 0.8));
						WalkToQueue.Enqueue(g.Position.MoveToArc(g.Direction, 1.0));
					}
					else
					{
						g.Direction += 90.DegreesToRadians();

						if (Sync_GuardLookAt != null)
							Sync_GuardLookAt(g.ConstructorIndexForSync, g.Direction);

					}

					3000.AtDelayDo(TurnAndWalk);
				};

			g.WalkToDone +=
				delegate
				{
					TurnAndWalk();
				};

			g.WalkToTeleported +=
				delegate
				{
					TurnAndWalk();
				};

			TurnAndWalk();
		}
		public void EnterEndLevelMode()
		{
			if (EndLevelMode)
				return;

			this.WriteLine("init: EnterEndLevelMode");

			if (Sync_EnterEndLevelMode != null)
				Sync_EnterEndLevelMode();

			var ScoreContainer = new Sprite().AttachTo(this);

			ScoreContainer.alpha = 0.8;

			Bitmap scroll = Assets.Default.scroll.AttachTo(ScoreContainer);
			var scroll_scale = DefaultControlHeight / scroll.height;

			scroll.scaleX = scroll_scale;
			scroll.scaleY = scroll_scale;

			scroll.MoveTo(DefaultControlWidth - scroll.width, 0);
			scroll.filters = new BitmapFilter[] { new DropShadowFilter() };

			new Bitmap(EgoView.Buffer.clone())
			{
				scaleX = DefaultScale,
				scaleY = DefaultScale
			}.AttachTo(this).FadeOutAndOrphanize(1000 / 24, 0.1);

			if (music != null)
				music.stop();

			EndLevelMode = true;
			MovementEnabled_IsInGame = false;

			var music_endlevel = Assets.Default.Music.music_endlevel.play(1);

			this.WriteLine("init: music_endlevel");

			this.EgoView.Image.filters = new BitmapFilter[] {
				Filters.GrayScaleFilter,
			};

			this.EgoView.ViewPositionLock = TheGoldStack.Position;
			this.EgoView.ViewPosition = TheGoldStack.Position;

			var FrozenLook = (45 + 180);

			var p = new PointInt32
			{
				X = (int)Math.Floor(TheGoldStack.Position.x),
				Y = (int)Math.Floor(TheGoldStack.Position.y),
			};

			// where should we look actually?
			if (EgoView.Map.WallMap[p.X - 1, p.Y] != 0)
				FrozenLook = (90 + 180);

			if (EgoView.Map.WallMap[p.X, p.Y - 1] != 0)
				FrozenLook = (0 + 180);

			this.EgoView.ViewDirection = FrozenLook.DegreesToRadians();

			HudContainer.FadeOut(1000 / 15, 0.2,
						delegate
						{
							CompassContainer.alpha = 0;
						}
					);


			var onClick = default(Action<MouseEvent>);
			var onKeyUp = default(Action<KeyboardEvent>);


			#region EnterEndLevelMode_ReadyToContinue
			EnterEndLevelMode_ReadyToContinue =
				delegate
				{
					if (EnterEndLevelMode_ReadyToContinue == null)
					{
						this.WriteLine("EnterEndLevelMode_ReadyToContinue already disabled?");

						return;
					}

					this.WriteLine("EnterEndLevelMode_ReadyToContinue is now disabled!");
					if (Sync_ExitEndLevelMode != null)
						Sync_ExitEndLevelMode();

					EnterEndLevelMode_ReadyToContinue = null;

					music_endlevel.stop();


					ScoreContainer.FadeOut(
						delegate
						{
							ScoreContainer.Orphanize();

							PrepareToCallReadyForNextLevel();
						}
					);

					stage.keyUp -= onKeyUp;
					stage.click -= onClick;

				};
			#endregion



			1500.AtDelayDo(
				delegate
				{




					// level ends for all

					// list current scores

					ShowScoreTable(ScoreContainer, scroll);




					#region exit this menu
					music_endlevel.soundComplete +=
						delegate
						{
							// we are ready to continue...
							// are other players?

							if (EnterEndLevelMode_ReadyToContinue != null)
								EnterEndLevelMode_ReadyToContinue();

						};


					onClick =
						delegate
						{
							if (!MovementEnabled_IsFocused)
								return;

							if (EnterEndLevelMode_ReadyToContinue != null)
								EnterEndLevelMode_ReadyToContinue();
						};

					onKeyUp =
						delegate
						{
							if (!MovementEnabled_IsFocused)
								return;

							if (EnterEndLevelMode_ReadyToContinue != null)
								EnterEndLevelMode_ReadyToContinue();
						};
					#endregion

					stage.click += onClick;
					stage.keyUp += onKeyUp;

					// should add click / any key to dismiss this menu
				}
			);

		}
Esempio n. 8
0
        public void EnterEndLevelMode()
        {
            if (EndLevelMode)
            {
                return;
            }

            this.WriteLine("init: EnterEndLevelMode");

            if (Sync_EnterEndLevelMode != null)
            {
                Sync_EnterEndLevelMode();
            }

            var ScoreContainer = new Sprite().AttachTo(this);

            ScoreContainer.alpha = 0.8;

            Bitmap scroll       = Assets.Default.scroll.AttachTo(ScoreContainer);
            var    scroll_scale = DefaultControlHeight / scroll.height;

            scroll.scaleX = scroll_scale;
            scroll.scaleY = scroll_scale;

            scroll.MoveTo(DefaultControlWidth - scroll.width, 0);
            scroll.filters = new BitmapFilter[] { new DropShadowFilter() };

            new Bitmap(EgoView.Buffer.clone())
            {
                scaleX = DefaultScale,
                scaleY = DefaultScale
            }.AttachTo(this).FadeOutAndOrphanize(1000 / 24, 0.1);

            if (music != null)
            {
                music.stop();
            }

            EndLevelMode             = true;
            MovementEnabled_IsInGame = false;

            var music_endlevel = Assets.Default.Music.music_endlevel.play(1);

            this.WriteLine("init: music_endlevel");

            this.EgoView.Image.filters = new BitmapFilter[] {
                Filters.GrayScaleFilter,
            };

            this.EgoView.ViewPositionLock = TheGoldStack.Position;
            this.EgoView.ViewPosition     = TheGoldStack.Position;

            var FrozenLook = (45 + 180);

            var p = new PointInt32
            {
                X = (int)Math.Floor(TheGoldStack.Position.x),
                Y = (int)Math.Floor(TheGoldStack.Position.y),
            };

            // where should we look actually?
            if (EgoView.Map.WallMap[p.X - 1, p.Y] != 0)
            {
                FrozenLook = (90 + 180);
            }

            if (EgoView.Map.WallMap[p.X, p.Y - 1] != 0)
            {
                FrozenLook = (0 + 180);
            }

            this.EgoView.ViewDirection = FrozenLook.DegreesToRadians();

            HudContainer.FadeOut(1000 / 15, 0.2,
                                 delegate
            {
                CompassContainer.alpha = 0;
            }
                                 );


            var onClick = default(Action <MouseEvent>);
            var onKeyUp = default(Action <KeyboardEvent>);


            #region EnterEndLevelMode_ReadyToContinue
            EnterEndLevelMode_ReadyToContinue =
                delegate
            {
                if (EnterEndLevelMode_ReadyToContinue == null)
                {
                    this.WriteLine("EnterEndLevelMode_ReadyToContinue already disabled?");

                    return;
                }

                this.WriteLine("EnterEndLevelMode_ReadyToContinue is now disabled!");
                if (Sync_ExitEndLevelMode != null)
                {
                    Sync_ExitEndLevelMode();
                }

                EnterEndLevelMode_ReadyToContinue = null;

                music_endlevel.stop();


                ScoreContainer.FadeOut(
                    delegate
                {
                    ScoreContainer.Orphanize();

                    PrepareToCallReadyForNextLevel();
                }
                    );

                stage.keyUp -= onKeyUp;
                stage.click -= onClick;
            };
            #endregion



            1500.AtDelayDo(
                delegate
            {
                // level ends for all

                // list current scores

                ShowScoreTable(ScoreContainer, scroll);



                #region exit this menu
                music_endlevel.soundComplete +=
                    delegate
                {
                    // we are ready to continue...
                    // are other players?

                    if (EnterEndLevelMode_ReadyToContinue != null)
                    {
                        EnterEndLevelMode_ReadyToContinue();
                    }
                };


                onClick =
                    delegate
                {
                    if (!MovementEnabled_IsFocused)
                    {
                        return;
                    }

                    if (EnterEndLevelMode_ReadyToContinue != null)
                    {
                        EnterEndLevelMode_ReadyToContinue();
                    }
                };

                onKeyUp =
                    delegate
                {
                    if (!MovementEnabled_IsFocused)
                    {
                        return;
                    }

                    if (EnterEndLevelMode_ReadyToContinue != null)
                    {
                        EnterEndLevelMode_ReadyToContinue();
                    }
                };
                #endregion

                stage.click += onClick;
                stage.keyUp += onKeyUp;

                // should add click / any key to dismiss this menu
            }
                );
        }
		private void InitializeMap()
		{
			#region fill map
			Assets.Default.stuff.ToBitmapDictionary(
				f =>
				{
					this.WriteLine("init: stuff");

					StuffDictionary = f;


					CreateMapFromMaze();




					Func<string, Texture64> t =
						texname => f[texname + ".png"];

					Func<string, string, Texture64> mix =
						(a, b) =>
						{
							var ia = f[a + ".png"];
							var ib = f[b + ".png"];

							var u = new Bitmap(ia.bitmapData.clone());



							u.bitmapData.draw(ib);
							return u;
						};



					#region game goal
					TheGoldStack = CreateDummy(f["life.png"]);

					TheGoldStack.RemoveFrom(EgoView.Sprites);

					WaitForCollectingHalfTheTreasureToRevealEndGoal();

					TheGoldStack.Position.To(maze.Width - 1.25, maze.Height - 1.25);
					TheGoldStack.Range = 0.6;
					TheGoldStack.ItemTaken +=
						delegate
						{
							if (EndLevelMode)
								return;

							if (HalfOfTheTreasureCollected != null)
							{
								throw new Exception("should not reach here");
							}

							Assets.Default.Sounds.yeah.play();


							// show stats
							this.WriteLine("TheGoldStack -> EnterEndLevelMode");
							EnterEndLevelMode();
						};
					GoldSprites.Add(TheGoldStack);


					#endregion


					EgoView.Map.Textures = new Dictionary<uint, Texture64>
                        {
                            {graywall_achtung, mix("graywall", "achtung")},
                            {graywall_verboten, mix("graywall", "verboten")},
                            {graywall, t("graywall")},


							{woodwall_achtung, mix("woodwall", "achtung")},
                            {woodwall_verboten, mix("woodwall", "verboten")},
                            {woodwall, t("woodwall")},
                            {woodwall_books, t("woodwall_books")},


                            {bluewall, t("bluewall")},
                            {greenwall, t("greenwall")},
                        };

					// EgoView.RenderScene();

					InitializeWeaponOverlay(f);

					#region heads

					Assets.Default.head.Items.OrderBy(k => k.FileName).Select(k => k.Data).ToImages(
						heads =>
						{
							var head = default(Bitmap);

							1000.AtInterval(
								tt =>
								{
									if (head != null)
										head.Orphanize();

									if (heads.Length > 0)
									{
										if (GoldTakenCounter > 0)
										{
											GoldTakenCounter--;
											head = heads.Last();
										}
										else
											head = heads.AtModulus(tt.currentCount % 3);

										head.filters = new[] { new DropShadowFilter() };
										head.scaleX = 2;
										head.scaleY = 2;
										head.MoveTo(4, DefaultControlHeight - head.height - 4).AttachTo(HudContainer);
									}
								}
							);
						}
					);


					#endregion

					InitializeCompass();
					InitializeKeyboard();



					AttachMovementInput(EgoView, true, false);

					#region focus logic
					this.focusIn +=
						e =>
						{
							this.MovementEnabled_IsFocused = true;
							//WriteLine("focusIn");

							//if (this.MovementEnabled_IsAlive)
							//    this.filters = null;

						};

					this.focusOut +=
						delegate
						{
							this.MovementEnabled_IsFocused = false;

							//if (this.MovementEnabled_IsAlive)
							//    this.filters = new[] { Filters.GrayScaleFilter };
							//WriteLine("focusOut");
						};


					this.focusRect = null;
					this.mouseChildren = false;
					this.tabEnabled = true;
					#endregion

					//this.stage.focus = this;

					ResetEgoPosition();

					AddPortals();



					AddIngameEntities(
						delegate
						{
							this.WriteLine("init: AddIngameEntities done");


							1000.AtInterval(
								delegate
								{
									var u = new PointInt32 { X = EgoView.ViewPosition.x.Floor(), Y = EgoView.ViewPosition.y.Floor() };

									if (this.EgoView.Map.WallMap[u.X, u.Y] != 0)
										ResetEgoPosition();
								}
							);

							stage.enterFrame +=
								e =>
								{
									ApplyNextViewVector();

									if (EgoView.Image.alpha > 0)
										EgoView.RenderScene();
								};

							this.WriteLine("init: AddIngameEntities + ReadyWithLoadingCurrentLevel");

							this.ReadyWithLoadingCurrentLevel();
						}
					);
				}
			);
			#endregion
		}