コード例 #1
0
        private void WaitForCollectingHalfTheTreasureToRevealEndGoal()
        {
            HalfOfTheTreasureCollected =
                delegate
            {
                // ding ding ding - end of level revealed

                HalfOfTheTreasureCollected = null;

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

                EgoView.Image.FadeOut(
                    delegate
                {
                    TheGoldStack.AddTo(EgoView.Sprites);

                    // cuz we removed and then added, we have to manually update
                    // pov info, otherwise we need to wait
                    // until we collect another treasure
                    // for the endlevel to show up

                    EgoView.UpdatePOV(true);

                    CompassContainer.FadeIn(
                        delegate
                    {
                        EgoView.Image.FadeIn();
                    }
                        );
                }
                    );

                //this.WriteLine("game goal is now there");
            };
        }
コード例 #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
        }