private void InitializeChart()
        {
            tChart1.Header.Text       = "Scroll Pager Tool";
            tChart1.Series.Add(series = new FastLine());
            series.FillSampleValues(1000);
            tChart1.Tools.Add(tool     = new ScrollPager());
            tChart1.Tools.Add(point    = new NearestPoint());
            tChart1.Tools.Add(annotate = new Annotation());

            point.Brush.Color = tool.PointerHighlightColor;
            point.DrawLine    = false;
            point.Size        = 6;
            point.Direction   = NearestPointDirection.Horizontal;
            point.Series      = series;
            point.Change     += new EventHandler(point_Change);

            annotate.Position             = AnnotationPositions.RightTop;
            annotate.Text                 = "YValue:";
            annotate.Shape.Shadow.Visible = false;
            annotate.Shape.Font.Color     = tChart1.Header.Font.Color;
            annotate.Shape.Color          = tool.PointerHighlightColor;
            annotate.Shape.Pen.Visible    = false;
            annotate.TextAlign            = StringAlignment.Center;

            Theme.ApplyChartTheme(typeof(FlatTheme), tool.SubChartTChart.Chart);
        }
Exemplo n.º 2
0
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            tChart1.Header.Text   = "Nearest Tool Directions";

            tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);

            tool1 = new NearestPoint(tChart1.Chart);
            tool2 = new NearestPoint(tChart1.Chart);

            vertAxis  = new Axis(false, false, tChart1.Chart);
            horizAxis = new Axis(true, false, tChart1.Chart);
            line      = new Line(tChart1.Chart);
            horizLine = new HorizLine(tChart1.Chart);

            tChart1.Axes.Custom.Add(vertAxis);
            tChart1.Axes.Custom.Add(horizAxis);

            tChart1.Axes.Left.StartPosition  = 0;
            tChart1.Axes.Left.EndPosition    = 45;
            vertAxis.StartPosition           = 55;
            vertAxis.EndPosition             = 100;
            tChart1.Axes.Bottom.Grid.Visible = false;

            line.HorizAxis             = HorizontalAxis.Custom;
            line.CustomHorizAxis       = horizAxis;
            line.VertAxis              = VerticalAxis.Left;
            horizAxis.PositionUnits    = PositionUnits.Percent;
            horizAxis.RelativePosition = 55;
            horizAxis.Grid.Visible     = false;

            horizLine.VertAxis       = VerticalAxis.Custom;
            horizLine.CustomVertAxis = vertAxis;
            horizLine.HorizAxis      = HorizontalAxis.Bottom;

            tool1.Series      = line;
            tool1.Direction   = NearestPointDirection.Horizontal;
            tool1.DrawLine    = false;
            tool1.Brush.Color = horizLine.Color;
            tool1.Size        = 5;
            tool1.Change     += new EventHandler(tool1_Change);
            tool2.Series      = horizLine;
            tool2.Direction   = NearestPointDirection.Vertical;
            tool2.DrawLine    = false;
            tool2.Brush.Color = line.Color;
            tool2.Size        = 5;
            tool2.Change     += new EventHandler(tool2_Change);

            horizLine.FillSampleValues();
            line.FillSampleValues();

            anno1          = new Annotation(tChart1.Chart);
            anno2          = new Annotation(tChart1.Chart);
            anno1.Position = AnnotationPositions.LeftTop;
            anno2.Position = AnnotationPositions.RightBottom;
            anno1.Active   = false;
            anno2.Active   = false;
        }
        private void InitializeChart()
        {
            tChart1.Frame = this.View.Frame;

            tChart1.Header.Text       = "Scroll Pager Tool";
            tChart1.Panning.Active    = true;
            tChart1.Series.Add(series = new FastLine());
            series.FillSampleValues(1000);

            tChart1.Tools.Add(tool = new ScrollPager());

            for (int i = 0; i < tChart1.Series.Count; i++)
            {
                if (tChart1.Series[i].Count > 0)
                {
                    tool.Series = tChart1.Series[i];
                }
            }

            tool.ColorBandTool.StartLine.AllowDrag = true;
            tool.ColorBandTool.EndLine.AllowDrag   = true;
            tool.ColorBandTool.StartLine.Active    = true;
            tool.ColorBandTool.EndLine.Active      = true;


            tChart1.Tools.Add(colorlinetool = new ColorLine());
            colorlinetool.Value             = 100;
            colorlinetool.AllowDrag         = true;
            colorlinetool.Pen.Color         = Color.Blue;

            tChart1.ClickBackground += TChart1_ClickBackground;

            tChart1.Tools.Add(point    = new NearestPoint());
            tChart1.Tools.Add(annotate = new Annotation());

            point.Brush.Color = tool.PointerHighlightColor;
            point.DrawLine    = false;
            point.Size        = 6;
            point.Direction   = NearestPointDirection.Horizontal;
            point.Series      = series;
            point.Change     += Point_Change;

            annotate.Position             = AnnotationPositions.RightTop;
            annotate.Text                 = "YValue:";
            annotate.Shape.Shadow.Visible = false;
            annotate.Shape.Font.Color     = Color.Red;
            annotate.Shape.Color          = tool.PointerHighlightColor;
            annotate.Shape.Font.Size      = 15;
            annotate.Shape.Pen.Visible    = false;
            annotate.Shape.Transparent    = true;
            annotate.TextAlign            = CoreText.CTTextAlignment.Center;

            tChart1.Panel.Gradient.Visible = false;

            this.View.AddSubview(tChart1);
        }
Exemplo n.º 4
0
        private void InitializeChart()
        {
            tChart1.Chart.Header.Text       = "Scroll Pager Tool";
            tChart1.Chart.Panning.Active    = true;
            tChart1.Chart.Series.Add(series = new FastLine());
            series.FillSampleValues(1000);

            tChart1.Chart.Tools.Add(tool = new ScrollPager());

            for (int i = 0; i < tChart1.Chart.Series.Count; i++)
            {
                if (tChart1.Chart.Series[i].Count > 0)
                {
                    tool.Series = tChart1.Chart.Series[i];
                }
            }

            tool.ColorBandTool.StartLine.AllowDrag = true;
            tool.ColorBandTool.EndLine.AllowDrag   = true;
            tool.ColorBandTool.StartLine.Active    = true;
            tool.ColorBandTool.EndLine.Active      = true;


            tChart1.Chart.Tools.Add(colorlinetool = new ColorLine());
            colorlinetool.Value     = 100;
            colorlinetool.AllowDrag = true;
            colorlinetool.Pen.Color = Color.Blue;

            tChart1.Chart.ClickBackground += TChart1_ClickBackground;

            tChart1.Chart.Tools.Add(point    = new NearestPoint());
            tChart1.Chart.Tools.Add(annotate = new Annotation());

            point.Brush.Color = tool.PointerHighlightColor;
            point.DrawLine    = false;
            point.Size        = 6;
            point.Direction   = NearestPointDirection.Horizontal;
            point.Series      = series;
            point.Change     += new EventHandler(point_Change);

            annotate.Position             = AnnotationPositions.RightTop;
            annotate.Text                 = "YValue:";
            annotate.Shape.Shadow.Visible = false;
            annotate.Shape.Font.Color     = tChart1.Chart.Header.Font.Color;
            annotate.Shape.Color          = tool.PointerHighlightColor;
            annotate.Shape.Pen.Visible    = false;
            annotate.Shape.Font.Color     = Color.White;
            annotate.TextAlign            = TextAlignment.Center;

            //Theme.ApplyChartTheme(typeof(FlatTheme), tool.SubChartTChart.Chart);
        }
Exemplo n.º 5
0
        public static List <Point> best_Waypoint(Battle _battle, Actor currentPlayer, Point pointToReach)
        {
            // methode qui retourne le meilleur waypoints vers une position on prenant en considération le bloquage
            // ici est la logique pour les invocations
            // variable de controle pour verifier la présence d'un adversaire acoté de l'invoc
            // cheque si l'invoc est a coté d'un adversaire, si non on recherche
            Point        up           = new Point(_battle.AllPlayersByOrder[_battle.Turn].map_position.X, _battle.AllPlayersByOrder[_battle.Turn].map_position.Y - 1);
            Point        down         = new Point(_battle.AllPlayersByOrder[_battle.Turn].map_position.X, _battle.AllPlayersByOrder[_battle.Turn].map_position.Y + 1);
            Point        right        = new Point(_battle.AllPlayersByOrder[_battle.Turn].map_position.X + 1, _battle.AllPlayersByOrder[_battle.Turn].map_position.Y);
            Point        left         = new Point(_battle.AllPlayersByOrder[_battle.Turn].map_position.X - 1, _battle.AllPlayersByOrder[_battle.Turn].map_position.Y);
            List <Actor> _cacOpponent = new List <Actor>();

            // variable qui dois contenir le nombre total des points de bloquages qui va permettre de savoir si le joueur va pouvoir se liberer si un autre adversaire se trouve quelque part
            int cacBlocage = 0;

            if (up.Y >= 0 && _battle.AllPlayersByOrder.Exists(f => f.map_position.X == up.X && f.map_position.Y == up.Y && f.teamSide != _battle.AllPlayersByOrder[_battle.Turn].teamSide))
            {
                Actor pi = _battle.AllPlayersByOrder.Find(f => f.map_position.X == up.X && f.map_position.Y == up.Y);
                if (pi != null)
                {
                    cacBlocage += pi.blocage;
                    _cacOpponent.Add(pi);
                }
            }

            if (down.Y < ScreenManager.TileHeight && _battle.AllPlayersByOrder.Exists(f => f.map_position.X == down.X && f.map_position.Y == down.Y && f.teamSide != _battle.AllPlayersByOrder[_battle.Turn].teamSide))
            {
                Actor pi = _battle.AllPlayersByOrder.Find(f => f.map_position.X == down.X && f.map_position.Y == down.Y);
                if (pi != null)
                {
                    cacBlocage += pi.blocage;
                    _cacOpponent.Add(pi);
                }
            }

            if (right.X < ScreenManager.TileWidth && _battle.AllPlayersByOrder.Exists(f => f.map_position.X == right.X && f.map_position.Y == right.Y && f.teamSide != _battle.AllPlayersByOrder[_battle.Turn].teamSide))
            {
                Actor pi = _battle.AllPlayersByOrder.Find(f => f.map_position.X == right.X && f.map_position.Y == right.Y);
                if (pi != null)
                {
                    cacBlocage += pi.blocage;
                    _cacOpponent.Add(pi);
                }
            }

            if (left.X >= 0 && _battle.AllPlayersByOrder.Exists(f => f.map_position.X == left.X && f.map_position.Y == left.Y && f.teamSide != _battle.AllPlayersByOrder[_battle.Turn].teamSide))
            {
                Actor pi = _battle.AllPlayersByOrder.Find(f => f.map_position.X == left.X && f.map_position.Y == left.Y);
                if (pi != null)
                {
                    cacBlocage += pi.blocage;
                    _cacOpponent.Add(pi);
                }
            }

            // recherche si un joueur a été trouvé au cac
            // on recherche une cible s'il y à eu aucun adversaire au cac, ou s'il y à des adversaires au cac mais ils sont pas humains (invoc)
            // on check a la fin si un joueur a été trouvé si non on prend une invoc qui été au cac, found est le variable de controle
            List <Point> wayPointList = new List <Point>();

            if (_cacOpponent.Count == 0 || (_cacOpponent.Count > 0 && _cacOpponent.FindAll(f => f.species == Species.Name.Human).Count == 0 && cacBlocage <= _battle.AllPlayersByOrder[_battle.Turn].escape))
            {
                // aucun joueur na été trouvé au cac, mise en recherche
                // check si l'invoc a plus que 0 pm
                if (_battle.AllPlayersByOrder[_battle.Turn].currentPm > 0)
                {
                    Enums.Team.Side      team  = _battle.AllPlayersByOrder[_battle.Turn].teamSide;
                    List <FiltrePlayers> fpiiL = new List <FiltrePlayers>();

                    // liste qui dois contenir tous les points qui sont a proximités de notre joueurs
                    List <Actor>        piL         = (team == Enums.Team.Side.A) ? _battle.SideB : _battle.SideA;
                    List <NearestPoint> tacledPoint = new List <NearestPoint>();      // contiens les points aproximités des joueurs

                    for (int cnt = 0; cnt < piL.Count; cnt++)
                    {
                        Point _up    = new Point(piL[cnt].map_position.X, piL[cnt].map_position.Y - 1);
                        Point _down  = new Point(piL[cnt].map_position.X, piL[cnt].map_position.Y + 1);
                        Point _right = new Point(piL[cnt].map_position.X + 1, piL[cnt].map_position.Y);
                        Point _left  = new Point(piL[cnt].map_position.X - 1, piL[cnt].map_position.Y);

                        // on check si cette cases est occupé déja par un joueur
                        if (!_battle.AllPlayersByOrder.Exists(f => f.map_position.X == _up.X && f.map_position.Y == _up.Y))
                        {
                            NearestPoint np_up = new NearestPoint();
                            np_up.index = piL[cnt].blocage;
                            np_up.point = _up;
                            np_up.actor = piL[cnt];
                            tacledPoint.Add(np_up);
                        }
                        if (!_battle.AllPlayersByOrder.Exists(f => f.map_position.X == _down.X && f.map_position.Y == _down.Y))
                        {
                            NearestPoint np_down = new NearestPoint();
                            np_down.index = piL[cnt].blocage;
                            np_down.point = _down;
                            np_down.actor = piL[cnt];
                            tacledPoint.Add(np_down);
                        }
                        if (!_battle.AllPlayersByOrder.Exists(f => f.map_position.X == _right.X && f.map_position.Y == _right.Y))
                        {
                            NearestPoint np_right = new NearestPoint();
                            np_right.index = piL[cnt].blocage;
                            np_right.point = _right;
                            np_right.actor = piL[cnt];
                            tacledPoint.Add(np_right);
                        }
                        if (!_battle.AllPlayersByOrder.Exists(f => f.map_position.X == _left.X && f.map_position.Y == _left.Y))
                        {
                            NearestPoint np_left = new NearestPoint();
                            np_left.index = piL[cnt].blocage;
                            np_left.point = _left;
                            np_left.actor = piL[cnt];
                            tacledPoint.Add(np_left);
                        }
                    }

                    /////////////// pathfinding   ////////////////////

                    MELHARFI.AStarAlgo.MapPoint startPoint = new MELHARFI.AStarAlgo.MapPoint(_battle.AllPlayersByOrder[_battle.Turn].map_position.X, _battle.AllPlayersByOrder[_battle.Turn].map_position.Y);
                    MELHARFI.AStarAlgo.MapPoint endPoint   = new MELHARFI.AStarAlgo.MapPoint(pointToReach.X, pointToReach.Y);
                    Actor target2 = _battle.AllPlayersByOrder.Find(f => f.map_position.X == endPoint.X && f.map_position.Y == endPoint.Y);
                    if (target2 == null)
                    {
                        // si on arrive ici c'est que le joueur n'est pas synchro avec le serveur
                        // le joueur essai de frapper un adversaire qui est existant chez le client mais pas sur le serveur, a voir le client
                        Console.WriteLine("team1 has " + _battle.SideA.Count + " team2 has " + _battle.SideB.Count);
                        Console.WriteLine("can't reach that code unless if client is not sync with server, no player was found to hit");

                        /*finishTurn(_battle, true);
                         * return;*/
                    }

                    byte[,] byteMap = new byte[ScreenManager.TileWidth, ScreenManager.TileHeight];
                    for (int i = 0; i < ScreenManager.TileWidth; i++)
                    {
                        for (int j = 0; j < ScreenManager.TileHeight; j++)
                        {
                            if (!_battle.IsFreeCellToWalk(new Point(i * 30, j * 30)) || _battle.AllPlayersByOrder.Exists(f => f.map_position.X == i && f.map_position.Y == j && f.Pseudo != _battle.AllPlayersByOrder[_battle.Turn].Pseudo && (target2 != null && f.Pseudo != target2.Pseudo)))
                            {
                                byteMap[i, j] = 3;
                            }
                            else if (tacledPoint.FindAll(f => f.point.X == i && f.point.Y == j && f.actor.Pseudo != _battle.AllPlayersByOrder[_battle.Turn].Pseudo && f.actor.Pseudo != target2.Pseudo).Count > 0)
                            {
                                // il ya plusieurs cases qui sont affecté par un joueur, on calcule le nombre de point de blocage
                                int npTotal            = 0;
                                List <NearestPoint> np = tacledPoint.FindAll(f => f.point.X == i && f.point.Y == j && f.actor.Pseudo != _battle.AllPlayersByOrder[_battle.Turn].Pseudo && f.actor.Pseudo != target2.Pseudo);
                                for (int cnt3 = 0; cnt3 < np.Count; cnt3++)
                                {
                                    npTotal += np[cnt3].actor.blocage;
                                }

                                if (npTotal > _battle.AllPlayersByOrder[_battle.Turn].blocage)
                                {
                                    byteMap[i, j] = 3;
                                }
                                else
                                {
                                    byteMap[i, j] = 0;
                                }
                            }
                            else
                            {
                                byteMap[i, j] = 0;
                            }
                        }
                    }
                    // mise en obstacle de tous les cases qui devais tacler l'invoc lorsqu'il passe a coté

                    MELHARFI.AStarAlgo.Map _map = new MELHARFI.AStarAlgo.Map(ScreenManager.TileWidth, ScreenManager.TileHeight, startPoint, endPoint, byteMap);

                    if (_map != null && _map.StartPoint != MELHARFI.AStarAlgo.MapPoint.InvalidPoint && _map.EndPoint != MELHARFI.AStarAlgo.MapPoint.InvalidPoint)
                    {
                        MELHARFI.AStarAlgo.AStar           astart = new MELHARFI.AStarAlgo.AStar(_map);
                        List <MELHARFI.AStarAlgo.MapPoint> sol    = astart.CalculateBestPath();
                        if (sol != null)
                        {
                            sol.Reverse();
                        }
                        else
                        {
                            // impossible de determiner le chemain, peux etre que la case ciblé est un obstacle
                        }
                        // conversion de la liste MapPoint a une liste Point
                        for (int i = 0; i < sol.Count; i++)
                        {
                            wayPointList.Add(new Point(sol[i].X * 30, sol[i].Y * 30));
                        }
                    }

                    // soustraction de la derniere case si elle correspand a la case ciblé, puisque le joueur ne peux pas occuper une case déja occupé
                    if (wayPointList.Count > 0)
                    {
                        if (wayPointList[wayPointList.Count - 1].X == endPoint.X * 30 && wayPointList[wayPointList.Count - 1].Y == endPoint.Y * 30)
                        {
                            wayPointList.RemoveAt(wayPointList.Count - 1);
                        }
                    }
                }
                ////////////////////////////
            }

            return(wayPointList);
        }