Beispiel #1
0
        private void RenderPacketList(ToRender toRender)
        {
            bool           isSentList    = toRender.HasFlag(ToRender.SENT);
            bool           isReceiveList = toRender.HasFlag(ToRender.RECEIVED);
            PacketPrefixer prefixer      = isSentList && isReceiveList ? (PacketPrefixer)PacketDirectionPrefixer : PacketNoopPrefixer;

            for (int i = packets.Count - 1; i >= 0; i--)
            {
                PacketDebugWrapper wrapper = packets[i];
                if (wrapper.IsSent && !isSentList)
                {
                    continue;
                }
                if (!wrapper.IsSent && !isReceiveList)
                {
                    continue;
                }

                using (new GUILayout.VerticalScope("Box"))
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        wrapper.ShowDetails = GUILayout.Toggle(wrapper.ShowDetails, "", GUILayout.Width(20), GUILayout.Height(20));
                        GUILayout.Label($"{prefixer(wrapper)}{wrapper.Packet.GetType().FullName}", wrapper.IsSent ? "packet-type-up" : "packet-type-down");

                        packets[i] = wrapper; // Store again because value-type
                    }

                    if (wrapper.ShowDetails)
                    {
                        GUILayout.Label(wrapper.Packet.ToString());
                    }
                }
            }
        }
Beispiel #2
0
        public Action GetRenderModule(ToRender elements)
        {
            return(new Action(() =>
            {
                Window.Space.Children.Clear();

                StringBuilder stringBuilder = new StringBuilder();

                elements.Stones.ForEach(e => stringBuilder.Append(e.ToString()));

                elements.Bulets.ForEach(e => stringBuilder.Append(e.ToString()));

                elements.Branders.ForEach(e => stringBuilder.Append(e.ToString()));

                if (elements.Laser.Enabled)
                {
                    stringBuilder.Append(elements.Laser.ToString());
                }

                stringBuilder.Append(elements.Ship.ToString());

                Window.Vector.Text = stringBuilder.ToString();
                Window.Points.Text = $"Очки: {elements.Points}";
            }));
        }
Beispiel #3
0
        /// <summary>
        /// This method is onvoked every Tick in Game Universe
        /// Loads GameElements to render
        /// Checks Game State if Win the Create Player Score
        /// Invokes StateHasChanged that re render component
        /// </summary>
        /// <param name="sender">GameUniverse</param>
        /// <param name="eventArgs">Empty</param>
        public void Render(object sender, EventArgs eventArgs)
        {
            var toRender = GameUniverse.GameLogic.AllElements;

            lock (ToRender)
            {
                ToRender.Clear();
                ToRender.AddRange(toRender);
            }

            GameState = GameUniverse.GameLogic.GameState;
            if (GameState == GameState.Win && !_createScoreSent)
            {
                CreatePlayerScore();
                _createScoreSent = true;
            }
            ElapsedTime = GameUniverse.GameLogic.GameTime.GetFormattedElapsedTime();
            InvokeAsync(StateHasChanged);
        }
Beispiel #4
0
 public void Render(ToRender elements)
 {
     DoInvoke(actualRenders.GetRenderModule(elements));
 }
Beispiel #5
0
        public Action GetRenderModule(ToRender elements)
        {
            return(new Action(() => {
                Window.Space.Children.Clear();
                Window.Vector.Text = "";

                elements.Stones.ForEach(e =>
                {
                    Window.Space.Children.Add(new Ellipse()
                    {
                        Height = e.Size * 2,
                        Width = e.Size * 2,
                        Fill = stone,
                        Margin = new Thickness(e.Position.X - e.Size, e.Position.Y - e.Size, 0, 0),
                        HorizontalAlignment = HorizontalAlignment.Left,
                        VerticalAlignment = VerticalAlignment.Top,
                    });
                    Window.Vector.Text += e.ToString();
                });

                elements.Bulets.ForEach(e =>
                {
                    Window.Space.Children.Add(new Ellipse()
                    {
                        Height = e.Size * 2,
                        Width = e.Size * 2,
                        Fill = bulet,
                        Margin = new Thickness(e.Position.X - e.Size, e.Position.Y - e.Size, 0, 0),
                        HorizontalAlignment = HorizontalAlignment.Left,
                        VerticalAlignment = VerticalAlignment.Top,
                    });
                    Window.Vector.Text += e.ToString();
                });

                elements.Branders.ForEach(e =>
                {
                    Window.Space.Children.Add(new Ellipse()
                    {
                        Height = e.Size * 2,
                        Width = e.Size * 2,
                        Fill = brander,
                        Margin = new Thickness(e.Position.X - e.Size, e.Position.Y - e.Size, 0, 0),
                        HorizontalAlignment = HorizontalAlignment.Left,
                        VerticalAlignment = VerticalAlignment.Top,
                    });
                    Window.Vector.Text += e.ToString();
                });

                Window.LaserPower.Maximum = elements.Laser.MaxPower;
                Window.LaserPower.Value = elements.Laser.Power;
                Window.LaserPower.Foreground = elements.Laser.Reloaded ? laser_work : laser_reload;
                if (elements.Laser.Enabled)
                {
                    Window.Space.Children.Add(new Line()
                    {
                        Stroke = laser,
                        X1 = elements.Laser.FromPoint.X,
                        Y1 = elements.Laser.FromPoint.Y,
                        X2 = elements.Laser.Position.X,
                        Y2 = elements.Laser.Position.Y,
                        StrokeThickness = 5,
                    });
                    Window.Vector.Text += elements.Laser.ToString();
                }

                Window.Space.Children.Add(new Ellipse()
                {
                    Height = elements.Ship.Size * 2,
                    Width = elements.Ship.Size * 2,
                    Fill = ship,
                    Margin = new Thickness(elements.Ship.Position.X - elements.Ship.Size, elements.Ship.Position.Y - elements.Ship.Size, 0, 0),
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment = VerticalAlignment.Top,
                });
                Window.Vector.Text += elements.Ship.ToString();
                Window.Points.Text = $"Очки: {elements.Points}";
            }));
        }