Пример #1
0
        protected override void Update(Game game, float elapsedSeconds)
        {
            elapsedSeconds *= TimeDilation;
            if (Treasure.Instance.TimeDilationFast)
            {
                elapsedSeconds *= 4;
            }

            if (Root.WasKeyPressed(Keys.Escape))
            {
                Retreat();
            }

            if (Root.WasKeyPressed(Keys.F, ModifierKey.Ctrl))
            {
                Treasure.Instance.ShowFireMode = !Treasure.Instance.ShowFireMode;
                Treasure.Instance.Save();
            }
            if (Root.WasKeyPressed(Keys.T, ModifierKey.Ctrl))
            {
                Treasure.Instance.TimeDilationFast = !Treasure.Instance.TimeDilationFast;
                Treasure.Instance.Save();
            }
            if (Root.WasKeyPressed(Keys.R, ModifierKey.Ctrl))
            {
                Session.AllTiles.Where(tl => tl.Trap != TrapId.NotTrapped).ForEach(tr => tr.TrapGoesOff());
            }

            CameraMovement(elapsedSeconds);
            Session.Update(elapsedSeconds);
            base.Update(game, elapsedSeconds);

            if (Session.Victory.HasValue)
            {
                SFX.StopAll();
                if (Session.Victory.Value)
                {
                    Root.PushPhase(new MissionCompletedPhase(new EmergencyRecords()
                    {
                        Reason = EndReason.Victory,
                        Text   = Session.VictoryText
                    }));
                }
                else
                {
                    Root.PushPhase(new MissionCompletedPhase(new EmergencyRecords()
                    {
                        Reason = Session.VictoryEndReason
                    }));
                }
            }

            if (contextMenu?.ScheduledForElimination ?? false)
            {
                contextMenu = null;
            }

            if (Root.WasMouseLeftClick)
            {
                if (contextMenu != null)
                {
                    contextMenu.HandleLeftClick();
                }
                else if (mouseOverCharacter != null)
                {
                    SelectedCharacter = mouseOverCharacter;
                }
                else
                {
                    SelectedCharacter = null;
                }
            }

            if (Root.WasMouseRightClick && SelectedCharacter != null && SelectedCharacter.IsLivingPaladin)
            {
                List <Interaction> interactions = new List <Interaction>();
                if (mouseOverCharacter != null)
                {
                    interactions = mouseOverCharacter.GetInteractionsBy(SelectedCharacter).ToList();
                }
                if (mouseOverTile != null && interactions.Count == 0)
                {
                    interactions = mouseOverTile.GetInteractionsBy(SelectedCharacter).ToList();
                }

                if (interactions.Count == 1 && interactions[0].IsDirectlyExecutable)
                {
                    interactions[0].FullExecute();
                }
                else if (interactions.Count > 0)
                {
                    this.contextMenu = ContextMenu.Generate(Root.Mouse_NewState.X, Root.Mouse_NewState.Y, interactions);
                }
            }
        }