Esempio n. 1
0
        public void LoadNextLevel(Action <Action> AlmostDone)
        {
            CurrentLevel++;

            this.EgoView.Image.FadeOut(
                delegate
            {
                RemoveAllEntities();

                // each level starts counting from zero
                GoldTotalCollected = 0;

                //MazeSize = (MazeSizeMin + CurrentLevel / 2).Min(MazeSizeMax);
                MazeSize = (MazeSizeMin + CurrentLevel / MazeDelayResize).Min(MazeSizeMax);

                this.WriteLine("mazesize: " + MazeSize);

                CreateMapFromMaze();

                AddIngameEntities(
                    delegate
                {
                    TheGoldStack.IsTaken = false;
                    TheGoldStack.Position.To(maze.Width - 1.3, maze.Height - 1.3);
                    GoldSprites.Add(TheGoldStack);

                    //this.WriteLine("goal is at " + new { TheGoldStack.Position.x, TheGoldStack.Position.y });


                    WaitForCollectingHalfTheTreasureToRevealEndGoal();

                    ResetPortals();

                    music = Assets.Default.Music.music.play(0, 9999);

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

                    EndLevelMode             = false;
                    MovementEnabled_IsInGame = true;

                    ResetEgoPosition();

                    AlmostDone(
                        delegate
                    {
                        this.EgoView.Image.FadeIn();
                        this.HudContainer.FadeIn();
                    }
                        );
                }
                    );
            }
                );
        }
Esempio n. 2
0
        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
        }