示例#1
0
        protected virtual void Draw(DrawEvent ev, DrawTransformation transform)
        {
            TimeSinceDraw.Restart();
            float deltaTime = (float)deltaWatch.Elapsed.TotalSeconds;

            deltaWatch.Restart();
            if (deltaTime > 1f)
            {
                return;
            }

            using (var ac = BlendMode.Activate())
            {
                for (int i = 0; i < ParticleCount; i++)
                {
                    particles[i].Age += deltaTime;

                    if (particles[i].Age >= particles[i].Life)
                    {
                        particles[i] = particles[ParticleCount - 1];
                        ParticleCount--;

                        if (i >= ParticleCount)
                        {
                            break;
                        }
                    }
                    else
                    {
                        UpdateAndDraw(particles[i], deltaTime, ev.RenderTarget);
                    }
                }
            }
        }
示例#2
0
 private void TestDrawEvent(DrawEvent evt)
 {
     if (DrawModel.TryGetEventAction(evt, out _))
     {
         PostEvent(evt);
     }
 }
示例#3
0
        protected virtual void Draw(DrawEvent ev, DrawTransformation transform)
        {
            TimeSinceDraw.Restart();
            float deltaTime = (float)deltaWatch.Elapsed.TotalSeconds;
            deltaWatch.Restart();
            if (deltaTime > 1f)
                return;

            using (var ac = BlendMode.Activate())
            {
                for (int i = 0; i < ParticleCount; i++)
                {
                    particles[i].Age += deltaTime;

                    if (particles[i].Age >= particles[i].Life)
                    {
                        particles[i] = particles[ParticleCount - 1];
                        ParticleCount--;

                        if (i >= ParticleCount)
                            break;
                    }
                    else
                    {
                        UpdateAndDraw(particles[i], deltaTime, ev.RenderTarget);
                    }
                }
            }
        }
示例#4
0
        public void Draw(DrawEvent ev)
        {
            int start = (int)(Scene.Camera.WorldCoord.X - Engine.Resolution.X / 2f),
                end   = (int)(Scene.Camera.WorldCoord.X + Engine.Resolution.X / 2f);

            if (start < 0)
            {
                start = 0;
            }
            if (start >= Data.Length)
            {
                start = Data.Length - 1;
            }
            if (end < 0)
            {
                end = 0;
            }
            if (end >= Data.Length)
            {
                end = Data.Length - 1;
            }

            for (int x = start; x < end; x++)
            {
                var list = Data[x];
                for (int i = 0; i < list.Count; i++)
                {
                    var line = list[i];

                    ev.RenderTarget.DrawTexture(Program.Pixel, new Vector2(x, line.From), line.IsStatic ? Program.Static : Program.Foreground, new Vector2(1f, line.To - line.From), Vector2.Zero, 0f, new Rectangle(Vector2.Zero, Vector2.One));
                }
            }
        }
示例#5
0
        public DrawEventArgs ExecuteDraw(int amount)
        {
            var args = new DrawEventArgs(this, amount);

            DrawEvent.Call(args);
            return(args);
        }
示例#6
0
        public void Update(int cx, int cz)
        {
            updateTimer.Restart();
            if (centerX != cx || centerZ != cz)
            {
                centerX = cx;
                centerZ = cz;

                UpdateChunkQueues();
            }
            UnloadChunks();
            LoadChunks();
            MeshChunks();

            if (Settings.Instance.DebugInfo && debugTimer.ElapsedMilliseconds >= 250)
            {
                Console.WriteLine("");
                Console.WriteLine("Loaded Chunks: {0}", chunkMap.Count);
                Console.WriteLine("Loading Queue: {0}", chunkLoadQueue.Count);
                Console.WriteLine("Loading Tasks: {0}", currentlyLoading.Count);
                Console.WriteLine("Meshing Queue: {0}", meshUpdateQueue.Count);
                Console.WriteLine("Average Meshs: {0}", averageChunkUpdates);
                Console.WriteLine("ChunkRenderer: {0}", DrawEvent?.GetInvocationList().Length);
                debugTimer.Restart();
            }
        }
示例#7
0
 protected override void OnDraw(Canvas canvas)
 {
     canvas.DrawColor(ColorBank.GetColor(ColorBank.Background));
     canvas.Save();
     canvas.Translate(rootPivot.X, rootPivot.Y);
     DrawEvent?.Invoke(canvas);
     canvas.Restore();
 }
        public DoomScreenManager(DrawEvent DrawHirachy, int w, int h)
        {
            DrawScreen   += DrawHirachy;
            width         = w;
            height        = h;
            distPerHeigth = MAXDRAWDIST / height / 2;
            //allLines = Labyrinth;

            #region information
            Object3D Wall = new Object3D()
            {
                patternheight = 2,
                patternwidth  = 1,
                isTransparent = false,
                pattern       = new PInfo[, ]
                {
                    {
                        new PInfo()
                        {
                            HasBackground = true, Background = ConsoleColor.DarkGreen
                        },
                        new PInfo()
                        {
                            HasBackground = true, Background = ConsoleColor.Gray
                        },
                        //new PInfo(){HasBackground = true, Background = ConsoleColor.Black}
                    },
                    {
                        new PInfo()
                        {
                            HasBackground = true, Background = ConsoleColor.White
                        },
                        new PInfo()
                        {
                            HasBackground = true, Background = ConsoleColor.Black
                        },
                        //new PInfo(){HasBackground = true, Background = ConsoleColor.White}
                    }/*,
                      * {
                      * new PInfo(){HasBackground = true, Background = ConsoleColor.Yellow},
                      * new PInfo(){HasBackground = true, Background = ConsoleColor.Red},
                      * //new PInfo(){hasBackground = true, background = ConsoleColor.Black}
                      * }/*,
                      * {
                      * new PInfo(){hasBackground = true, background = ConsoleColor.White},
                      * new PInfo(){hasBackground = true, background = ConsoleColor.Black},
                      * new PInfo(){hasBackground = true, background = ConsoleColor.White}
                      * }  */
                }
            };
            foreach (var item in allLines)
            {
                DObjectects.Add(item.Item1, Wall);
            }
            //SpriteObjects.Add(enemy, new Tuple<double, double>(0, 5));
            #endregion
        }
 public DrawPixelHistoryEventViewModel(DrawEvent @event)
 {
     _parts = new List <DrawPixelHistoryEventPartViewModel>
     {
         new InputAssemblerDrawPixelHistoryEventPartViewModel(@event),
         new VertexShaderDrawPixelHistoryEventPartViewModel(@event),
         new OutputMergerDrawPixelHistoryEventPartViewModel(@event)
     };
     _event = @event;
 }
示例#10
0
        public static PixelResultViewModel Create(DrawEvent @event)
        {
            switch (@event.ExclusionReason)
            {
            case PixelExclusionReason.NotExcluded:
                return(new ColorResultViewModel(@event.Result.Value));

            default:
                return(new ExcludedPixelResultViewModel(@event));
            }
        }
示例#11
0
        public Player(string name, Card[] deck)
        {
            this.name = name;
            this.deck = new Deck(deck, this);
            hand      = new Hand(this);
            field     = new Field(this);
            grave     = new Grave(this);

            DrawEvent.Subscribe(this, 0, Draw);
            PlayCardEvent.Subscribe(this, 0, Play);
            AttackOrderEvent.Subscribe(this, 0, AttackOrder);
            AttackEvent.Subscribe(this, 0, Attack);
            DamageEvent.Subscribe(this, 0, Damage);
            DeathEvent.Subscribe(this, 0, Death);
        }
示例#12
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            base.GraphicsDevice.Clear(Color.Black);
            StaticClass.sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend,
                                 null, null, null, null, cam.Mat);

            DrawEvent?.Invoke();

            StaticClass.sb.DrawString(StaticClass.font, "Iteration number: " + StaticClass.PopulationNumber, new Vector2(0, 0), Color.White);
            StaticClass.sb.DrawString(StaticClass.font, "Last Fitness: " + StaticClass.Stats["LastFitness"], new Vector2(0, 20), Color.White);
            StaticClass.sb.DrawString(StaticClass.font, "Max Fitness: " + StaticClass.Stats["MaxFitness"], new Vector2(0, 40), Color.White);
            StaticClass.sb.DrawString(StaticClass.font, "Num of founds: " + StaticClass.Stats["NumOfFounds"], new Vector2(0, 60), Color.White);

            StaticClass.sb.End();

            base.Draw(gameTime);
        }
示例#13
0
    public void AddToDrawQueue(int n)
    {
        if (n == 0)
        {
            return;
        }

        Debug.Log("AddToDrawQueue() index " + n);

        DrawEvent newEvent = new DrawEvent(deck[0]);

        drawQueue.Add(newEvent);

        n--;

        AddToDrawQueue(n);
    }
示例#14
0
        private void On(DrawEvent gameEvent)
        {
            if (CurrentState.State != MatchState.Drawing)
            {
                throw new InvalidOperationException("Not Expected");
            }

            CurrentState.PlayerOnLeft = gameEvent.PlayerOnLeft;
            CurrentState.PlayerServes = gameEvent.PlayerServes;
            CurrentState.Sets         = new List <SetModel> {
                new SetModel()
            };
            CurrentState.GameScore     = new Score();
            CurrentState.SecondServe   = false;
            CurrentState.ServePosition = ServePosition.Right;
            CurrentState.GameStratedAt = gameEvent.OccuredAt;
            CurrentState.State         = MatchState.BeginningGame;
        }
示例#15
0
    public Task DrawCards(Packet packet)
    {
        // ===================== Steps To Update Hand ===============
        // 1. Convert packet to POCO
        // 2. Get the new array from packet
        // 3. Update the player's hand array/list
        // 4. Render the new list to the view

        var poco = JsonUtility.FromJson <DrawPOCO>(packet.POCOJson);

        Player homePlayer = ServiceProvider.PlayerManager.GetPlayer(packet.PlayerId);

        homePlayer.Hand = poco.Hand;
        Game.Round      = poco.Round;

        DrawEvent.Invoke();

        return(Task.FromResult(0));
    }
示例#16
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (DrawPoolType != 0)
            {
                hash ^= DrawPoolType.GetHashCode();
            }
            if (DrawEvent != 0)
            {
                hash ^= DrawEvent.GetHashCode();
            }
            if (Resource != 0)
            {
                hash ^= Resource.GetHashCode();
            }
            if (ResourceId != 0)
            {
                hash ^= ResourceId.GetHashCode();
            }
            return(hash);
        }
示例#17
0
        public void Draw(DrawEvent ev, DrawTransformation transform)
        {
            var player = ((MainScene)Scene).Player;

            if (player == null)
            {
                return;
            }

            switch (HintId)
            {
            case 0:
                ev.RenderTarget.DrawTexture(Program.Hint1, transform.WorldCoord.Floor, Program.Foreground * opacity, Vector2.One, (new Vector2(31f, 21f) / 2f).Floor, 0f, new Rectangle(watch.Elapsed.TotalSeconds % 1f > .5 ? new Vector2(31f, 0f) : new Vector2(0f, 0f), new Vector2(31f, 21f)));
                break;

            case 1:
                ev.RenderTarget.DrawTexture(Program.Hint2, transform.WorldCoord.Floor, Program.Foreground * opacity, Vector2.One, (new Vector2(31f, 21f) / 2f).Floor, 0f, new Rectangle(watch.Elapsed.TotalSeconds % 1f > .5 ? new Vector2(31f, 0f) : new Vector2(0f, 0f), new Vector2(31f, 21f)));
                break;

            case 2:
                ev.RenderTarget.DrawTexture(Program.Hint3, transform.WorldCoord.Floor, Program.Foreground * opacity, Vector2.One, (new Vector2(9f, 10f) / 2f).Floor, 0f, new Rectangle(watch.Elapsed.TotalSeconds % 1f > .5 ? new Vector2(9f, 0f) : new Vector2(0f, 0f), new Vector2(9f, 10f)));
                break;
            }
        }
示例#18
0
 public LinearBitmapBehavior(DrawEvent drawEvent)
     : this()
 {
     DrawEvent = drawEvent;
 }
 public InputAssemblerDrawPixelHistoryEventPartViewModel(DrawEvent @event)
 {
     _event = @event;
 }
 public VertexShaderDrawPixelHistoryEventPartViewModel(DrawEvent @event)
 {
     _event = @event;
 }
示例#21
0
 public void TriggerDrawStart()
 {
     _startDrawTime = DateTime.UtcNow;
     DrawEvent?.Invoke();
 }
示例#22
0
 public RadialBitmapBehavior(DrawEvent drawEvent)
     : this()
 {
     DrawEvent = drawEvent;
 }
示例#23
0
        public Cloth()
        {
            this.CellSizeProperty = 32;
            this.Patch            = new Patch();

            Base             = Inv.Canvas.New();
            Base.PressEvent += (Point) =>
            {
                this.PanningPoint = Point;

                Base.Draw();
            };

            Base.AdjustEvent += () =>
            {
                Base.Draw();
            };

            Base.MoveEvent += (Point) =>
            {
                if (PanningPoint != null)
                {
                    var DeltaPoint = PanningPoint.Value - Point;

                    PanningX += DeltaPoint.X;
                    PanningY += DeltaPoint.Y;

                    this.PanningPoint = Point;

                    Base.Draw();
                }
            };

            Base.ReleaseEvent += (Point) =>
            {
                PanningPoint = null;

                Base.Draw();
            };

            Base.ZoomEvent += (Z) =>
            {
                Zoom(Z.Point.X, Z.Point.Y, Z.Delta);
            };

            Base.DrawEvent += (DC) =>
            {
                var CanvasDimension = Base.GetDimension();
                var CanvasWidth     = CanvasDimension.Width;
                var CanvasHeight    = CanvasDimension.Height;
                var MapWidth        = Dimension.Width * CellSizeProperty;
                var MapHeight       = Dimension.Height * CellSizeProperty;
                var BufferX         = Math.Max(300, CanvasWidth - MapWidth);
                var BufferY         = Math.Max(300, CanvasHeight - MapHeight);

                if (InitialDraw)
                {
                    this.InitialDraw = false;

                    if (PanningX == 0 && PanningY == 0)
                    {
                        if (MapWidth < CanvasWidth)
                        {
                            PanningX = (MapWidth - CanvasWidth) / 2;
                        }

                        if (MapHeight < CanvasHeight)
                        {
                            PanningY = (MapHeight - CanvasHeight) / 2;
                        }
                    }
                }

                if (PanningX + CanvasWidth > MapWidth + BufferX)
                {
                    PanningX = MapWidth - CanvasWidth + BufferX;
                }

                if (PanningX < -BufferX)
                {
                    PanningX = -BufferX;
                }

                if (PanningY + CanvasHeight > MapHeight + BufferY)
                {
                    PanningY = MapHeight - CanvasHeight + BufferY;
                }

                if (PanningY < -BufferY)
                {
                    PanningY = -BufferY;
                }

                SetPanningParameters();

                var CellY = -(PanningY % CellSizeProperty);

                for (var Y = PanningTop; Y <= PanningBottom; Y++)
                {
                    var CellX = -(PanningX % CellSizeProperty);

                    for (var X = PanningLeft; X <= PanningRight; X++)
                    {
                        if (X >= 0 && X < Dimension.Width && Y >= 0 && Y < Dimension.Height)
                        {
                            Patch.X    = X;
                            Patch.Y    = Y;
                            Patch.Rect = new Inv.Rect(CellX, CellY, CellSizeProperty, CellSizeProperty);

                            DrawEvent?.Invoke(DC, Patch);
                        }

                        CellX += CellSizeProperty;
                    }

                    CellY += CellSizeProperty;
                }
            };
        }
示例#24
0
 public static void AddDraw(DrawEvent drawEvent) => MGame.Room._drawEvents.Add(drawEvent);
示例#25
0
 public void SetDrawEvent(DrawEvent drawEvent)
 {
     animStr.DrawBitmap += drawEvent;
     userDrawEvent       = drawEvent;
 }
示例#26
0
 public SolidBitmapBehavior(DrawEvent drawEvent)
     : this()
 {
     DrawEvent = drawEvent;
 }
 public WindowScreenManager(int width, int height, DrawEvent DrawHirachy, PInfo BackgroundStyle) : this(width, height, DrawHirachy)
 {
     Background = BackgroundStyle;
 }
 public OutputMergerDrawPixelHistoryEventPartViewModel(DrawEvent @event)
 {
     _event = @event;
 }
示例#29
0
 public MainForm()
 {
     InitializeComponent();
     _appendText   = DrawText;
     _DrawUserList = DrawUserList;
 }
示例#30
0
        public override void OnPaint(DrawEvent dea)
        {
            fController.OnPaint();
            //result = User32.DefWindowProc(msg.hWnd, msg.message, msg.wParam, msg.lParam);

            //if (null != WindowRepaintEvent)
            //    WindowRepaintEvent(this, dea);
        }
示例#31
0
 public static void RemoveDraw(DrawEvent drawEvent) => MGame.Room._drawEvents.Remove(drawEvent);
 public WindowScreenManager(int width, int height, DrawEvent DrawHirachy)
 {
     DrawScreen += DrawHirachy;
     this.width  = width;
     this.height = height;
 }
示例#33
0
文件: World.cs 项目: andi2/ld32-1
        public void Draw(DrawEvent ev)
        {
            int start = (int)(Scene.Camera.WorldCoord.X - Engine.Resolution.X / 2f),
                end = (int)(Scene.Camera.WorldCoord.X + Engine.Resolution.X / 2f);
            if (start < 0)
                start = 0;
            if (start >= Data.Length)
                start = Data.Length - 1;
            if (end < 0)
                end = 0;
            if (end >= Data.Length)
                end = Data.Length - 1;

            for (int x = start; x < end; x++)
            {
                var list = Data[x];
                for (int i = 0; i < list.Count; i++)
                {
                    var line = list[i];

                    ev.RenderTarget.DrawTexture(Program.Pixel, new Vector2(x, line.From), line.IsStatic ? Program.Static : Program.Foreground, new Vector2(1f, line.To - line.From), Vector2.Zero, 0f, new Rectangle(Vector2.Zero, Vector2.One));
                }
            }
        }