public override void ProcessKeyboard(IScreenObject consoleObject, SadConsole.Input.Keyboard info, out bool handled)
        {
            // Upcast this because we know we're only using it with a Console type.
            var console = (Console)consoleObject;

            if (info.IsKeyDown(Keys.Left))
            {
                console.ViewPosition = console.ViewPosition.Translate((-1, 0));
            }

            if (info.IsKeyDown(Keys.Right))
            {
                console.ViewPosition = console.ViewPosition.Translate((1, 0));
            }

            if (info.IsKeyDown(Keys.Up))
            {
                console.ViewPosition = console.ViewPosition.Translate((0, -1));
            }

            if (info.IsKeyDown(Keys.Down))
            {
                console.ViewPosition = console.ViewPosition.Translate((0, +1));
            }

            handled = true;
        }
Exemplo n.º 2
0
        public IList <IRole> QueryRoleInRange(IScreenObject pSender, int nRange)
        {
            List <IRole> pRoles = Players.Values.Where(x => x.GetDistance(pSender.MapX, pSender.MapY) <= nRange).Cast <IRole>().ToList();

            pRoles.AddRange(GameObjects.Values.Where(x => Calculations.GetDistance(x.MapX, x.MapY, pSender.MapX, pSender.MapY) <= nRange).Cast <IRole>());
            return(pRoles);
        }
Exemplo n.º 3
0
        public void MoveNextConsole()
        {
            currentConsoleIndex++;

            if (currentConsoleIndex >= consoles.Length)
            {
                currentConsoleIndex = 0;
            }

            selectedConsole = consoles[currentConsoleIndex].Console;

            Children.Clear();
            Children.Add(headerConsole);
            Children.Add(selectedConsoleContainer);

            selectedConsoleContainer.Children.Clear();
            selectedConsoleContainer.Children.Add(selectedConsole);

            selectedConsole.IsVisible = true;
            selectedConsole.IsFocused = true;
            //selectedConsole.Position = new Point(0, 2);

            GameHost.Instance.FocusedScreenObjects.Set(selectedConsole);
            headerConsole.SetConsole(consoles[currentConsoleIndex].Title, consoles[currentConsoleIndex].Summary);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Runs the instruction set. Once all instructions are finished, this set will set the <see cref="InstructionBase.IsFinished"/> property will be set to <see langword="true"/>.
        /// </summary>
        public override void Update(IScreenObject componentHost, TimeSpan delta)
        {
            if (!IsFinished && Instructions.Count != 0)
            {
                if (_currentInstructionNode == null)
                {
                    _currentInstructionNode = Instructions.First;
                }

                _currentInstructionNode.Value.Update(componentHost, delta);

                if (_currentInstructionNode.Value.IsFinished)
                {
                    _currentInstructionNode = _currentInstructionNode.Next;

                    if (_currentInstructionNode == null)
                    {
                        IsFinished = true;
                    }
                }
            }
            else
            {
                IsFinished = true;
            }

            base.Update(componentHost, delta);
        }
Exemplo n.º 5
0
 public ModalWindow(IVisualCollection visualCollection, string dialogName, string entityName = "")
 {
     _collection = visualCollection;
     _dialogName = dialogName;
     _entityName = ((entityName != "") ? entityName : _collection.Details.GetModel().ElementType.Name);
     _screen     = _collection.Screen;
 }
Exemplo n.º 6
0
 public virtual void update(GameTime gameTime, IScreenObject screenObject)
 {
     if (baseEffect != null)
     {
         baseEffect.update(gameTime, screenObject);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Dislays a <see cref="MessageBox"/> indication an exception.
        /// </summary>
        /// <param name="value">The screen to show the <see cref="MessageBox"/> on.</param>
        /// <param name="ex">The exception to display.</param>
        public static void ShowError(this IScreenObject value, Exception ex)
        {
#if DEBUG
            Debug.WriteLine(ex.ToString());
#endif
            value.ShowMessageBox(ex.ToString(), "Fehler", Microsoft.LightSwitch.Presentation.Extensions.MessageBoxOption.Ok);
        }
Exemplo n.º 8
0
 public virtual void reset(IScreenObject screenObject)
 {
     if (baseEffect != null)
     {
         baseEffect.reset(screenObject);
     }
 }
 /// <inheritdoc/>
 public override void OnAdded(IScreenObject host)
 {
     if (!(host is IScreenSurface))
     {
         throw new ArgumentException($"{nameof(SurfaceComponentFollowTarget)} can only be added to an {nameof(IScreenSurface)}.");
     }
 }
Exemplo n.º 10
0
 /// <inheritdoc />
 public void Update(IScreenObject host, TimeSpan delta)
 {
     foreach (var entity in _mapEntities.ToArray())
     {
         entity.Update(delta);
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// Updates the timer with the time since the last call.
 /// </summary>
 /// <param name="console">The parent object.</param>
 /// <param name="delta">The time since the last frame update.</param>
 public override void Update(IScreenObject console, TimeSpan delta)
 {
     if (!IsFinished)
     {
         base.Update(console, delta);
     }
 }
Exemplo n.º 12
0
        /// <inheritdoc/>
        public override void OnAdded(IScreenObject host)
        {
            if (_screen != null)
            {
                throw new Exception("Component has already been added to a host.");
            }
            if (!(host is IScreenSurface surface))
            {
                throw new ArgumentException($"Must add this component to a type that implements {nameof(IScreenSurface)}");
            }

            if (RenderStep != null)
            {
                surface.RenderSteps.Remove(RenderStep);
                RenderStep.Dispose();
            }

            RenderStep = GameHost.Instance.GetRendererStep(Renderers.Constants.RenderStepNames.EntityRenderer);
            RenderStep.SetData(this);
            surface.RenderSteps.Add(RenderStep);
            _screen     = surface;
            _isAttached = true;

            UpdateCachedVisibilityArea();
        }
        public void OnScreenClosed(Notification n)
        {
            ScreenClosedNotification screenClosedNotification =
                (ScreenClosedNotification)n;
            IScreenObject screenObject = screenClosedNotification.Screen;

            foreach (TabItem ti in this.ScreenArea.Items)
            {
                // Get the real IScreenObject from the instance of the ScreenWrapper
                IScreenObject realScreenObject =
                    ((ScreenWrapper)ti.DataContext).RealScreenObject;
                // Remove the screen from the tab control
                if (realScreenObject == screenObject)
                {
                    this.ScreenArea.Items.Remove(ti);
                    break;
                }
            }

            // Switch the current tab and current screen
            int count = this.ScreenArea.Items.Count;

            if (count > 0)
            {
                TabItem ti = (TabItem)this.ScreenArea.Items[count - 1];

                this.ScreenArea.SelectedItem = ti;
                this.ServiceProxy.ActiveScreensViewModel.Current =
                    ((ScreenWrapper)(ti.DataContext)).RealScreenObject;
            }
        }
        public void OnScreenOpened(Notification n)
        {
            ScreenOpenedNotification screenOpenedNotification =
                (ScreenOpenedNotification)n;
            IScreenObject screenObject = screenOpenedNotification.Screen;
            IScreenView   view         =
                this.ServiceProxy.ScreenViewService.GetScreenView(screenObject);

            // Create a tab item from the template
            TabItem      ti       = new TabItem();
            DataTemplate template =
                (DataTemplate)this.Resources["TabItemHeaderTemplate"];
            UIElement element = (UIElement)template.LoadContent();

            // Wrap the underlying screen object in a ScreenWrapper object
            ti.DataContext    = new ScreenWrapper(screenObject);
            ti.Header         = element;
            ti.HeaderTemplate = template;
            ti.Content        = view.RootUI;

            // Add the tab item to the tab control.
            this.ScreenArea.Items.Add(ti);
            this.ScreenArea.SelectedItem = ti;

            // Set the currently active screen in the active screens view model.
            this.ServiceProxy.ActiveScreensViewModel.Current = screenObject;
        }
Exemplo n.º 15
0
 public ModalWindow(IVisualCollection visualCollection, string dialogName, string entityName = "")
 {
     _collection = visualCollection;
     _dialogName = dialogName;
     _entityName = ((entityName != "") ? entityName : _collection.Details.GetModel().ElementType.Name);
     _screen = _collection.Screen;
 }
Exemplo n.º 16
0
        public int AdjustAttack(int nAtk, IScreenObject attacker)
        {
            int nAddAtk = 0;

            // TODO

            return(nAtk + nAddAtk);
        }
Exemplo n.º 17
0
 public void resetscreenObject(IScreenObject screenObject)
 {
     screenObject.Position = position;
     screenObject.Origin   = origin;
     screenObject.Color    = color;
     screenObject.Scale    = scale;
     screenObject.Rotation = rotation;
 }
Exemplo n.º 18
0
 /// <inheritdoc />
 public void ProcessKeyboard(IScreenObject host, Keyboard keyboard, out bool handled)
 {
     handled = false;
     foreach (var entity in _mapEntities.ToArray())
     {
         handled = entity.ProcessKeyboard(keyboard);
     }
 }
Exemplo n.º 19
0
 /// <inheritdoc />
 public void ProcessMouse(IScreenObject host, MouseScreenObjectState state, out bool handled)
 {
     handled = false;
     foreach (var entity in _mapEntities.ToArray())
     {
         handled = entity.ProcessMouse(state);
     }
 }
Exemplo n.º 20
0
        public override void Show(IScreenObject showInitializator = null)
        {
            Enabled = true;

            base.Show(showInitializator);

            SetDefaultStyle();
        }
Exemplo n.º 21
0
        protected void AddNestedObject(IScreenObject nestedObject, int drawOrder)
        {
            var pair = new KeyValuePair <int, IScreenObject>(drawOrder, nestedObject);

            _nestedObjects.Add(pair);
            _nestedObjects = _nestedObjects.OrderByDescending(p => p.Key).ToList();
            OnNestedObjectAdded?.Invoke(pair);
        }
Exemplo n.º 22
0
 public Label(IScreenObject parent, IInputDevice inputDevice, IOCRReader ocr, int top, int bottom, int left, int right)
     : base(parent, inputDevice, top, bottom, left, right)
 {
     CharacterHeight = 11;
     CharacterOffset = 0;
     Colors          = new[] { new byte[] { 0, 0, 0 } };
     OCR             = ocr;
 }
Exemplo n.º 23
0
 public void setDefaults(IScreenObject screenObject)
 {
     position = screenObject.Position;
     origin   = screenObject.Origin;
     color    = screenObject.Color;
     scale    = screenObject.Scale;
     rotation = screenObject.Rotation;
 }
Exemplo n.º 24
0
 private void AssertPixelsOnControlAreCorrect(IScreenObject control)
 {
     Assert.AreEqual(Color.LightBlue, control.GetPixel(0, 0));
     Assert.AreEqual(Color.LightGreen, control.GetPixel(0, 2));
     Assert.AreEqual(Color.DarkGreen, control.GetPixel(2, 2));
     Assert.AreEqual(Color.DarkBlue, control.GetPixel(2, 0));
     Assert.AreEqual(Color.Red, control.GetPixel(1, 1));
 }
Exemplo n.º 25
0
 private void AssertGettingOutOfBoundsPixelsThrows(IScreenObject control)
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => control.GetPixel(-1, 0));
     Assert.Throws <ArgumentOutOfRangeException>(() => control.GetPixel(-1, -1));
     Assert.Throws <ArgumentOutOfRangeException>(() => control.GetPixel(0, -1));
     Assert.Throws <ArgumentOutOfRangeException>(() => control.GetPixel(-5, -100));
     Assert.Throws <ArgumentOutOfRangeException>(() => control.GetPixel(0, 4));
     Assert.Throws <ArgumentOutOfRangeException>(() => control.GetPixel(10, 49));
 }
        private void DrawObject(IScreenObject o, Rectangle panelBounds)
        {
            if (!panelBounds.IntersectsWith(o.GetBounds()))
            {
                return;
            }

            o.Draw(_panelGraphics);
        }
Exemplo n.º 27
0
            public override void ProcessKeyboard(IScreenObject host, Keyboard keyboard, out bool handled)
            {
                if (keyboard.IsKeyPressed(Keys.Space))
                {
                    LoadNextMap((Screens.WorldPlay)host);
                }

                handled = true;
            }
Exemplo n.º 28
0
 public override void Hide()
 {
     base.Hide();
     _originalScreen.Parent   = null;
     GameHost.Instance.Screen = _originalScreen;
     _originalScreen          = null;
     _wrapperScreen           = null;
     GameHost.Instance.FocusedScreenObjects = _inputConsoles;
 }
Exemplo n.º 29
0
 public TreeListItem(IScreenObject parent, IInputDevice inputDevice, IOCRReader ocr, TreeListItem parentItem, int left, int right, int top, int offset, int height)
     : base(parent, inputDevice, top, top + 16, left, right)
 {
     ParentItem      = parentItem;
     CharacterOffset = offset;
     CharacterHeight = height;
     Colors          = new[] { new byte[] { 0, 0, 0 } };
     OCR             = ocr;
 }
Exemplo n.º 30
0
        /// <summary>
        /// Called when the instruction finishes.
        /// </summary>
        protected virtual void OnFinished(IScreenObject componentHost)
        {
            Finished?.Invoke(this, EventArgs.Empty);

            if (RemoveOnFinished)
            {
                componentHost.SadComponents.Remove(this);
            }
        }
Exemplo n.º 31
0
        /// <inheritdoc />
        public void OnRemoved(IScreenObject host)
        {
            var map = (RogueLikeMap)host;

            map.Entities.ItemAdded   -= EntitiesOnItemAdded;
            map.Entities.ItemRemoved -= EntitiesOnItemRemoved;

            _mapEntities.Clear();
        }
Exemplo n.º 32
0
		public ModalWrapper(IScreenObject screen, string windowName, string headerName = null, string headerText = null)
		{
			this.screen = screen;
			this.WindowName = windowName;
			this.HeaderName = headerName;
			this.header = headerText ?? "";
			this.proceedMethod = () => { };
			this.cancelMethod = () => { };
			this.Result = null;
			this.Tag = null;
		}
Exemplo n.º 33
0
 public static void SetCurrentParentScreen(IScreenObject scr)
 {
     currentParentScreen = scr;
 }