예제 #1
0
파일: Program.cs 프로젝트: dested/CTFMMO
 public PlayerClusterInfo(Player player)
 {
     Player = player;
     Neighbors = new List<Tuple<double, Player>>();
 }
예제 #2
0
파일: Program.cs 프로젝트: dested/CTFMMO
        private static void start()
        {
            canvas = (CanvasElement)Document.GetElementById("canvas");
            context = (CanvasRenderingContext2D)canvas.GetContext(CanvasContextId.Render2D);

            Offset = new Vector2(0, 0);

            Vector2 draggingPos = null;
            canvas.OnMousedown = @event =>
            {
                int mouseX = ((dynamic)@event).pageX;
                int mouseY = ((dynamic)@event).pageY;
                draggingPos = new Vector2(mouseX, mouseY);
            };
            canvas.OnMouseup = @event =>
            {
                /*
                                if (draggingPos == null) return;

                                int mouseX = ((dynamic)@event).pageX;
                                int mouseY = ((dynamic)@event).pageY;

                                draggingPos = new Vector2(draggingPos.X - mouseX, draggingPos.Y - mouseY);

                                Offset = new Vector2(Offset.X + draggingPos.X, Offset.Y + draggingPos.Y);
                                draw();


                */
                draggingPos = null;
            };
            Document.OnMousemove = @event =>
            {
                if (draggingPos == null) return;

                int mouseX = ((dynamic)@event).pageX;
                int mouseY = ((dynamic)@event).pageY;

                Offset = new Vector2(Offset.X + (draggingPos.X - mouseX) * 6, Offset.Y + (draggingPos.Y - mouseY) * 6);

                draggingPos = new Vector2(mouseX, mouseY);
                Draw();
            };



            canvas.Width = Document.Body.ClientWidth - 100;
            canvas.Height = Document.Body.ClientHeight - 100;
            context.Save();
            context.Font = "50px Arial";
            context.FillText("Loading...", canvas.Width / 2, canvas.Height / 2);
            context.Restore();


            Window.OnKeydown = @event =>
            {
                if (((dynamic)@event).keyCode == 17)
                {
                    drawLines = !drawLines;
                }
                Draw();
            };


        
             


            Window.SetTimeout(() =>
            {
                Console.WriteLine("Started");
                Console.Profile();

                Stopwatch sw = new Stopwatch();
                sw.Start();
                tree = new RTree<Player>();
                players = new List<Player>();
                for (int j = 0; j < numberOfPlayers; j++)
                {
                    var player = new Player(nextId());
                    player.X = rand.Next(0, gameSize);
                    player.Y = rand.Next(0, gameSize);
                    players.Add(player);
                    tree.Add(new Rectangle(player.X, player.Y), player);
                }

                buildClusters(viewRadius);

                sw.Stop();
                Console.ProfileEnd();
                Console.WriteLine(string.Format("Time {0}", sw.ElapsedMilliseconds));
                Console.WriteLine("Done");
                Draw();
            });
        }
예제 #3
0
파일: Program.cs 프로젝트: dested/CTFMMO
        private static double pointDistance(Player nearPlayer, Player currentPlayer)
        {
            return (Math.Pow(currentPlayer.X - nearPlayer.X, 2) + Math.Pow(currentPlayer.Y - nearPlayer.Y, 2));

        }