Exemplo n.º 1
0
 public TIconUserObj(Icon icon, DrawPosition drawPosition, MapView mapView)
     : base(new GeoPoint[] { null }, null, null, mapView, "", TEditUserObj.eType.Point)
 {
     //
     _iconToDraw   = icon;
     _drawPosition = drawPosition;
 }
Exemplo n.º 2
0
 public void Draw(DrawPosition position, GameTime gameTime, SpriteBatch spritebatch,Matrix matrix)
 {
     foreach (GameEvent ge in events)
     {
         if (ge.DrawPosition == position)
         {
             ge.Draw(gameTime, spritebatch, matrix);
         }
     }
 }
Exemplo n.º 3
0
        protected sealed override void Draw(RendererBatch batch)
        {
            for (int i = 0; i < DrawRegion.Width * DrawRegion.Height; i++)
            {
                var x        = DrawRegion.Left + (i % DrawRegion.Width);
                var y        = DrawRegion.Top + (i / DrawRegion.Width);
                var position = DrawPosition.Floor() + new Vector2(x * TileWidth, y * TileHeight);

                GetTile(x, y)?.Draw(
                    batch,
                    position,
                    Vector2.Zero,
                    Vector2.One,
                    0f,
                    Color * Opacity.Clamp(0f, 1f),
                    SpriteEffects);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///     On update event callback.
        /// </summary>
        public override void OnUpdate()
        {
            if (!Flags.HasFlag(NotificationFlags.Update) || Variables.TickCount - _lastUpdateTick < UpdateInterval)
            {
                return;
            }
            _lastUpdateTick = Variables.TickCount;

            if (Flags.HasFlag(NotificationFlags.Initalized))
            {
                if (!DrawPosition.IsValid())
                {
                    DrawPosition = Position;
                }

                Flags = Flags.ClearFlags(NotificationFlags.Initalized).SetFlags(NotificationFlags.Animation);
            }
            else if (Flags.HasFlag(NotificationFlags.Animation))
            {
                switch (AnimationId)
                {
                }

                Flags = Flags.ClearFlags(NotificationFlags.Animation).SetFlags(NotificationFlags.Idle);
            }
            else if (Flags.HasFlag(NotificationFlags.Idle))
            {
                if (DrawPosition != Position && Variables.TickCount - _lastPositionTick >= Speed * 0.5f)
                {
                    DrawPosition = DrawPosition.Extend(Position, 1f * Speed);
                    if (DrawPosition.X > Position.X)
                    {
                        DrawPosition = new Vector2(Position.X, DrawPosition.Y);
                    }
                    if (DrawPosition.Y > Position.Y)
                    {
                        DrawPosition = new Vector2(DrawPosition.X, Position.Y);
                    }
                    _lastPositionTick = Variables.TickCount;
                }
            }
        }
        public static void DrawSplitTexture(Rect position, Texture2D image, float left, float right, float top, float bottom, DrawPosition drawPosition)
        {
            if (drawPosition == DrawPosition.Left)
            {
                //  left top
                GUI.DrawTextureWithTexCoords(new Rect(position.x, position.y, left, top), image, new Rect(0f, 1.0f - top / image.height, left / image.width, top / image.height));

                // left bottom
                GUI.DrawTextureWithTexCoords(new Rect(position.x, position.y + position.height - bottom, left, bottom), image, new Rect(0f, 0f, left / image.width, bottom / image.height));

                //  Left line
                GUI.DrawTextureWithTexCoords(new Rect(position.x, position.y + top, left, position.height - top - bottom), image, new Rect(0f, bottom / image.height, left / image.width, (image.height - top - bottom) / image.height));

                // Right line
                GUI.DrawTextureWithTexCoords(new Rect(position.x + position.width - right * 0.5f, position.y, right * 0.5f, position.height), image, new Rect((image.width - right) / image.width, bottom / image.height, right / image.width, (image.height - top - bottom) / image.height));

                // bottom line
                GUI.DrawTextureWithTexCoords(new Rect(position.x + left, position.y + position.height - bottom, position.width - left, bottom), image, new Rect(left / image.width, 0f, (image.width - right - left) / image.width, bottom / image.height));

                // top line
                GUI.DrawTextureWithTexCoords(new Rect(position.x + left, position.y, position.width - left, top), image, new Rect(left / image.width, 1.0f - top / image.height, (image.width - right - left) / image.width, top / image.height));

                // inside
                GUI.DrawTextureWithTexCoords(new Rect(position.x + left * 0.5f, position.y + top, position.width - left * 0.5f, position.height - top - bottom), image, new Rect(left / image.width, 1.0f - top / image.height, (image.width - right - left) / image.width, (image.height - top - bottom) / image.height));
            }
            else if (drawPosition == DrawPosition.Center)
            {
                //  Left line
                GUI.DrawTextureWithTexCoords(new Rect(position.x, position.y, left * 0.5f, position.height), image, new Rect(0f, bottom / image.height, left / image.width, (image.height - top - bottom) / image.height));

                // Right line
                GUI.DrawTextureWithTexCoords(new Rect(position.x + position.width - right * 0.5f, position.y, right * 0.5f, position.height), image, new Rect((image.width - right) / image.width, bottom / image.height, right / image.width, (image.height - top - bottom) / image.height));

                // bottom line
                GUI.DrawTextureWithTexCoords(new Rect(position.x, position.y + position.height - bottom, position.width, bottom), image, new Rect(left / image.width, 0f, (image.width - right - left) / image.width, bottom / image.height));

                // top line
                GUI.DrawTextureWithTexCoords(new Rect(position.x, position.y, position.width, top), image, new Rect(left / image.width, 1.0f - top / image.height, (image.width - right - left) / image.width, top / image.height));

                // inside
                GUI.DrawTextureWithTexCoords(new Rect(position.x + left * 0.5f, position.y + top, position.width - left * 0.5f - right * 0.5f, position.height - top - bottom), image, new Rect(left / image.width, 1.0f - top / image.height, (image.width - right - left) / image.width, (image.height - top - bottom) / image.height));

            }
            else if(drawPosition == DrawPosition.Right)
            {
                //  right top
                GUI.DrawTextureWithTexCoords(new Rect(position.x + position.width - right, position.y, right, top), image, new Rect((image.width - right) / image.width, 1.0f - top / image.height, right / image.width, top / image.height));

                // right bottom
                GUI.DrawTextureWithTexCoords(new Rect(position.x + position.width - right, position.y + position.height - bottom, right, bottom), image, new Rect((image.width - right) / image.width, 0f, right / image.width, bottom / image.height));

                //  Left line
                GUI.DrawTextureWithTexCoords(new Rect(position.x, position.y, left * 0.5f, position.height), image, new Rect(0f, bottom / image.height, left / image.width, (image.height - top - bottom) / image.height));

                // Right line
                GUI.DrawTextureWithTexCoords(new Rect(position.x + position.width - right, position.y + top, right, position.height - top - bottom), image, new Rect((image.width - right) / image.width, bottom / image.height, right / image.width, (image.height - top - bottom) / image.height));

                // bottom line
                GUI.DrawTextureWithTexCoords(new Rect(position.x, position.y + position.height - bottom, position.width - right, bottom), image, new Rect(left / image.width, 0f, (image.width - right - left) / image.width, bottom / image.height));

                // top line
                GUI.DrawTextureWithTexCoords(new Rect(position.x, position.y, position.width - right, top), image, new Rect(left / image.width, 1.0f - top / image.height, (image.width - right - left) / image.width, top / image.height));

                // inside
                GUI.DrawTextureWithTexCoords(new Rect(position.x + left * 0.5f, position.y + top, position.width - left * 0.5f - right, position.height - top - bottom), image, new Rect(left / image.width, 1.0f - top / image.height, (image.width - right - left) / image.width, (image.height - top - bottom) / image.height));
            }
        }
Exemplo n.º 6
0
        public List <DrawPosition> Draw()
        {
            var lotsCount     = GetLotCount(Players.Count, out int depth);
            var startPos      = GetStartPos(depth);
            var drawPositions = new List <DrawPosition>(lotsCount);
            var seedCount     = Players.Count(p => p.Seed.HasValue);
            var byeCount      = lotsCount - Players.Count;
            var nodeList      = new List <Node <DrawPositionNode> >();

            for (int i = 0; i < lotsCount; i++)
            {
                var drawPosition = new DrawPosition()
                {
                    SortOrder = i + 1,
                    LotNumber = (int)startPos[i]
                };
                if (drawPosition.LotNumber <= seedCount)
                {
                    var seedPlayer = Players.FirstOrDefault(
                        p => p.Seed == drawPosition.LotNumber);
                    if (seedPlayer != null)
                    {
                        drawPosition.RegisterId = seedPlayer.Id;
                        drawPosition.PlayerName = seedPlayer.Name;
                        drawPosition.Delegation = seedPlayer.DelegationName;
                        drawPosition.Seed       = seedPlayer.Seed;
                    }
                }
                if (drawPosition.LotNumber > lotsCount - byeCount)
                {
                    drawPosition.PlayerName = "Bye";
                }
                drawPositions.Add(drawPosition);
                nodeList.Add(new Node <DrawPositionNode>
                {
                    Data = new DrawPositionNode
                    {
                        DrawPosition = drawPosition,
                        FreeCount    = drawPosition.PlayerName == null ? 1 : 0
                    }
                });
            }

            var players      = Players.Where(p => p.Seed == null).ToList();
            var tempNodeList = new List <Node <DrawPositionNode> >();

            for (int i = lotsCount >> 1; i > 0; i >>= 1)
            {
                tempNodeList.Clear();
                tempNodeList.AddRange(nodeList);
                nodeList.Clear();
                Node <DrawPositionNode> node = null;
                for (int j = 0; j < tempNodeList.Count; j++)
                {
                    if (j % 2 == 0)
                    {
                        node = new Node <DrawPositionNode>
                        {
                            LeftChild = tempNodeList[j],
                            Data      = new DrawPositionNode
                            {
                                FreeCount = tempNodeList[j].Data.FreeCount
                            }
                        };
                        nodeList.Add(node);
                    }
                    else
                    {
                        node.RightChild      = tempNodeList[j];
                        node.Data.FreeCount += tempNodeList[j].Data.FreeCount;
                    }
                }
            }

            var provider = new DrawProvider <Player>();

            provider.Shuffle(players);
            var groups = players.GroupBy(p => p.DelegationName).ToList();

            foreach (var group in groups)
            {
                players = group.ToList();
                var tempList = new List <DrawPositionNodeWithData>();
                var nodes    = new List <DrawPositionNodeWithData>
                {
                    new DrawPositionNodeWithData
                    {
                        Players = players,
                        Node    = nodeList[0]
                    }
                };
                for (int i = 0; i <= depth; i++)
                {
                    tempList.Clear();
                    tempList.AddRange(nodes);
                    nodes.Clear();
                    foreach (var item in tempList)
                    {
                        item.Node.Data.FreeCount -= item.Players.Count;
                        var position = item.Node.Data.DrawPosition;
                        if (item.Node.Data.DrawPosition != null)
                        {
                            position.RegisterId = item.Players[0].Id;
                            position.PlayerName = item.Players[0].Name;
                            position.Delegation = item.Players[0].DelegationName;
                        }
                        else
                        {
                            var node = item.Node;
                            if (item.Players.Count == 1)
                            {
                                if (node.LeftChild.Data.FreeCount >=
                                    node.RightChild.Data.FreeCount)
                                {
                                    nodes.Add(new DrawPositionNodeWithData
                                    {
                                        Node    = node.LeftChild,
                                        Players = item.Players
                                    });
                                }
                                else
                                {
                                    nodes.Add(new DrawPositionNodeWithData
                                    {
                                        Node    = node.RightChild,
                                        Players = item.Players
                                    });
                                }
                            }
                            else
                            {
                                Node <DrawPositionNode> moreFreeCountNode, lessFreeCountNode;

                                if (node.LeftChild.Data.FreeCount >=
                                    node.RightChild.Data.FreeCount)
                                {
                                    moreFreeCountNode = node.LeftChild;
                                    lessFreeCountNode = node.RightChild;
                                }
                                else
                                {
                                    moreFreeCountNode = node.RightChild;
                                    lessFreeCountNode = node.LeftChild;
                                }

                                var playersCount    = item.Players.Count;
                                var lessPlayerCount = playersCount / 2;

                                if (lessPlayerCount > lessFreeCountNode.Data.FreeCount)
                                {
                                    lessPlayerCount = lessFreeCountNode.Data.FreeCount;
                                }

                                if (lessPlayerCount != 0)
                                {
                                    nodes.Add(new DrawPositionNodeWithData
                                    {
                                        Node    = lessFreeCountNode,
                                        Players = item.Players.
                                                  Take(lessPlayerCount).ToList()
                                    });
                                }

                                nodes.Add(new DrawPositionNodeWithData
                                {
                                    Node    = moreFreeCountNode,
                                    Players = item.Players.
                                              TakeLast(playersCount - lessPlayerCount).ToList()
                                });
                            }
                        }
                    }
                }
            }

            return(drawPositions);
        }
Exemplo n.º 7
0
 public void Initialize(IServiceProvider serviceProvider,GraphicsDevice device,LevelVariables levelVariables,Options options)
 {
     content = new ContentManager(serviceProvider, "Data");
     drawposition = InitializeEvent(serviceProvider,device, levelVariables,options);
     FinishInitialization();
 }