コード例 #1
0
    public FlyerIdleState(FlyerFSM stateMachine, Flyer flyer)
    {
        _stateMachine = stateMachine;
        _flyer        = flyer;

        _playerInRange = flyer.PlayerDetector.PlayerInRange;
    }
コード例 #2
0
    public FlyerChasingState(FlyerFSM stateMachine, Flyer flyer)
    {
        _stateMachine = stateMachine;
        _flyer        = flyer;

        _playerInRange = flyer.PlayerDetector.PlayerInRange;
        _movement      = flyer.Movement;
    }
コード例 #3
0
    private GameObject _detectedGraphic;    // graphic icon that communicates detect state

    public Patroller_PlayerDetectedState(PatrollerFSM stateMachine, Patroller patroller)
    {
        _stateMachine = stateMachine;
        _patroller    = patroller;
        _data         = patroller.Data;

        _playerLOS          = patroller.PlayerDetector.PlayerLOS;
        _closeRangeDetector = patroller.PlayerDetector.PlayerClose;
        _detectedGraphic    = patroller.DetectedGraphic;
    }
コード例 #4
0
    public CrawlerMoveState(CrawlerFSM stateMachine, Crawler crawler)
    {
        _stateMachine = stateMachine;
        _crawler      = crawler;

        _kinematicObject       = crawler.Movement;
        _wallDetector          = crawler.EnvironmentDetector.WallDetector;
        _groundDetector        = crawler.EnvironmentDetector.GroundDetector;
        _groundInFrontDetector = crawler.EnvironmentDetector.GroundInFrontDetector;
    }
コード例 #5
0
    public PlayerWallClimbState(PlayerFSM stateMachine, Player player) : base(stateMachine, player)
    {
        _stateMachine = stateMachine;
        _player       = player;

        _movement          = player.Movement;
        _data              = player.Data;
        _input             = player.Input;
        _aboveWallDetector = player.EnvironmentDetector.AboveWallDetector;
        _wallDetector      = player.EnvironmentDetector.WallDetector;
    }
コード例 #6
0
    public PlayerGroundedSuperState(PlayerFSM stateMachine, Player player)
    {
        _stateMachine = stateMachine;
        _player       = player;

        _input           = player.Input;
        _data            = player.Data;
        _groundDetector  = player.EnvironmentDetector.GroundDetector;
        _ceilingDetector = player.EnvironmentDetector.CeilingDetector;
        _dashSystem      = player.DashSystem;
    }
コード例 #7
0
    public PlayerCrouchState(PlayerFSM stateMachine, Player player) : base(stateMachine, player)
    {
        _stateMachine = stateMachine;
        _player       = player;

        _movement        = player.Movement;
        _input           = player.Input;
        _data            = player.Data;
        _playerAnimator  = player.PlayerAnimator;
        _ceilingDetector = player.EnvironmentDetector.CeilingDetector;
    }
コード例 #8
0
    public Patroller_MoveState(PatrollerFSM stateMachine, Patroller patroller)
    {
        _stateMachine = stateMachine;
        _patroller    = patroller;
        _data         = patroller.Data;

        _movement              = patroller.Movement;
        _playerLOS             = patroller.PlayerDetector.PlayerLOS;
        _wallDetector          = patroller.EnvironmentDetector.WallDetector;
        _groundDetector        = patroller.EnvironmentDetector.GroundDetector;
        _groundInFrontDetector = patroller.EnvironmentDetector.GroundInFrontDetector;
    }
コード例 #9
0
    public PlayerWallSuperState(PlayerFSM stateMachine, Player player)
    {
        _stateMachine = stateMachine;
        _player       = player;

        _data           = player.Data;
        _movement       = player.Movement;
        _input          = player.Input;
        _groundDetector = player.EnvironmentDetector.GroundDetector;
        _wallDetector   = player.EnvironmentDetector.WallDetector;
        _dashSystem     = player.DashSystem;
    }
コード例 #10
0
    public PlayerGroundAttackState(PlayerFSM stateMachine, Player player)
    {
        _stateMachine = stateMachine;
        _animator     = player.PlayerAnimator;

        _movement       = player.Movement;
        _data           = player.Data;
        _input          = player.Input;
        _weaponSystem   = player.WeaponSystem;
        _dashSystem     = player.DashSystem;
        _weaponData     = player.WeaponSystem.EquippedWeapon;
        _groundDetector = player.EnvironmentDetector.GroundDetector;
    }
コード例 #11
0
    public PlayerJumpState(PlayerFSM stateMachine, Player player)
    {
        _stateMachine = stateMachine;
        _player       = player;
        _animator     = player.PlayerAnimator;

        _movement       = player.Movement;
        _input          = player.Input;
        _data           = player.Data;
        _groundDetector = player.EnvironmentDetector.GroundDetector;
        _dashSystem     = player.DashSystem;
        _sfx            = player.SFX;
        _jumpDust       = player.Visuals.JumpDust;
    }
コード例 #12
0
    public PlayerFallingState(PlayerFSM stateMachine, Player player)
    {
        _stateMachine = stateMachine;
        _player       = player;
        _animator     = player.PlayerAnimator;

        _movement          = player.Movement;
        _data              = player.Data;
        _input             = player.Input;
        _groundDetector    = player.EnvironmentDetector.GroundDetector;
        _wallDetector      = player.EnvironmentDetector.WallDetector;
        _aboveWallDetector = player.EnvironmentDetector.AboveWallDetector;

        _dashSystem = player.DashSystem;
    }
コード例 #13
0
ファイル: MSGraphPane.cs プロジェクト: zrolfs/pwiz
        private void drawLabels(Graphics g)
        {
            foreach (GraphObj pa in _pointAnnotations)
            {
                GraphObjList.Remove(pa);
            }
            _pointAnnotations.Clear();
            _manualLabels.Clear();

            Axis xAxis = XAxis;
            Axis yAxis = YAxis;

            yAxis.Scale.MinAuto = false;
            if (LockYAxisAtZero)
            {
                yAxis.Scale.Min = 0;
            }

            // ensure that the chart rectangle is the right size
            AxisChange(g);
            // then setup axes scales to enable the Transform method
            xAxis.Scale.SetupScaleData(this, xAxis);
            yAxis.Scale.SetupScaleData(this, yAxis);

            if (Chart.Rect.Width < 1 || Chart.Rect.Height < 1)
            {
                return;
            }

            _overlapDetector = AllowLabelOverlap ? null : new OverlapDetector();
            Region chartRegion = new Region(Chart.Rect);
            Region clipRegion  = new Region();

            clipRegion.MakeEmpty();
            var previousClip = g.Clip.Clone();

            g.SetClip(Rect, CombineMode.Replace);
            g.SetClip(chartRegion, CombineMode.Exclude);

            /*Bitmap clipBmp = new Bitmap(Convert.ToInt32(Chart.Rect.Width), Convert.ToInt32(Chart.Rect.Height));
             * Graphics clipG = Graphics.FromImage(clipBmp);
             * clipG.Clear(Color.White);
             * clipG.FillRegion(new SolidBrush(Color.Black), g.Clip);
             * clipBmp.Save("C:\\clip.bmp");*/


            // some dummy labels for very fast clipping
            string baseLabel = "0"; // Not L10N

            foreach (CurveItem item in CurveList)
            {
                IMSGraphItemInfo info = item.Tag as IMSGraphItemInfo;
                if (info != null)
                {
                    PointAnnotation annotation = info.AnnotatePoint(new PointPair(0, 0));
                    if (annotation != null &&
                        annotation.Label != null &&
                        annotation.Label.Length > baseLabel.Length)
                    {
                        baseLabel = annotation.Label;
                    }
                }
            }

            TextObj baseTextObj = new TextObj(baseLabel, 0, 0);

            baseTextObj.FontSpec.Border.IsVisible = false;
            baseTextObj.FontSpec.Fill.IsVisible   = false;
            PointF[] pts = baseTextObj.FontSpec.GetBox(g, baseLabel, 0, 0,
                                                       AlignH.Center, AlignV.Bottom, 1.0f, new SizeF());
            float baseLabelWidth  = pts[1].X - pts[0].X;
            float baseLabelHeight = pts[2].Y - pts[0].Y;

            baseLabelWidth  = (float)xAxis.Scale.ReverseTransform(xAxis.Scale.Transform(0) + baseLabelWidth);
            baseLabelHeight = (float)yAxis.Scale.ReverseTransform(yAxis.Scale.Transform(0) - baseLabelHeight);
            float labelLengthToWidthRatio = baseLabelWidth / baseLabel.Length;

            float xAxisPixel = yAxis.Scale.Transform(0);

            double xMin = xAxis.Scale.Min;
            double xMax = xAxis.Scale.Max;
            double yMin = yAxis.Scale.Min;
            double yMax = yAxis.Scale.Max;

            // add manual annotations with TextObj priority over curve annotations
            foreach (CurveItem item in CurveList)
            {
                var         info   = item.Tag as IMSGraphItemExtended;
                MSPointList points = item.Points as MSPointList;
                if (info == null || points == null)
                {
                    continue;
                }

                info.AddPreCurveAnnotations(this, g, points, _pointAnnotations);
                AddAnnotations(g);
            }

            // add automatic labels for MSGraphItems
            foreach (CurveItem item in CurveList)
            {
                IMSGraphItemInfo info   = item.Tag as IMSGraphItemInfo;
                MSPointList      points = item.Points as MSPointList;
                if (info == null || points == null)
                {
                    continue;
                }

                if (info.ToString().Length == 0)
                {
                    continue;
                }

                PointPairList fullList               = points.FullList;
                List <int>    maxIndexList           = points.ScaledMaxIndexList;
                var           annotationsPrioritized = new Dictionary <PointAnnotation, int>();
                for (int i = 0; i < maxIndexList.Count; ++i)
                {
                    if (maxIndexList[i] < 0)
                    {
                        continue;
                    }
                    PointPair pt = fullList[maxIndexList[i]];

                    if (pt.X < xMin || pt.Y > yMax || pt.Y < yMin)
                    {
                        continue;
                    }
                    if (pt.X > xMax)
                    {
                        break;
                    }

                    float yPixel = yAxis.Scale.Transform(pt.Y);

                    // labelled points must be at least 3 pixels off the X axis
                    if (xAxisPixel - yPixel < 3)
                    {
                        continue;
                    }

                    PointAnnotation annotation = info.AnnotatePoint(pt);
                    if (annotation != null)
                    {
                        annotationsPrioritized.Add(annotation, i);
                    }
                }

                // Give the higher ranked point priority
                foreach (var annotation in annotationsPrioritized.Keys.OrderBy(a => a.ZOrder ?? int.MaxValue))
                {
                    if (annotation.ExtraAnnotation != null)
                    {
                        GraphObjList.Add(annotation.ExtraAnnotation);
                        _pointAnnotations.Add(annotation.ExtraAnnotation);
                    }

                    if (string.IsNullOrEmpty(annotation.Label))
                    {
                        continue;
                    }

                    float pointLabelWidth = labelLengthToWidthRatio * annotation.Label.Split('\n').Max(o => o.Length);

                    var       i      = annotationsPrioritized[annotation];
                    PointPair pt     = fullList[maxIndexList[i]];
                    float     yPixel = yAxis.Scale.Transform(pt.Y);
                    double    labelY = yAxis.Scale.ReverseTransform(yPixel - 5);

                    if (!AllowCurveOverlap)
                    {
                        // do fast check for overlap against all MSGraphItems
                        bool overlap = false;
                        foreach (CurveItem item2 in CurveList)
                        {
                            MSPointList points2 = item2.Points as MSPointList;
                            if (points2 != null)
                            {
                                int nearestMaxIndex = points2.GetNearestMaxIndexToBin(i);
                                if (nearestMaxIndex < 0)
                                {
                                    continue;
                                }
                                RectangleF r = new RectangleF((float)pt.X - pointLabelWidth / 2,
                                                              (float)labelY - baseLabelHeight,
                                                              pointLabelWidth,
                                                              baseLabelHeight);
                                overlap = detectLabelCurveOverlap(this, points2.FullList, nearestMaxIndex, item2 is StickItem, r);
                                if (overlap)
                                {
                                    break;
                                }
                            }
                        }

                        if (overlap)
                        {
                            continue;
                        }
                    }

                    TextObj text = new TextObj(annotation.Label, pt.X, labelY,
                                               CoordType.AxisXYScale, AlignH.Center, AlignV.Bottom)
                    {
                        ZOrder               = ZOrder.A_InFront,
                        FontSpec             = annotation.FontSpec,
                        IsClippedToChartRect = true
                    };

                    var  textRect = _labelBoundsCache.GetLabelBounds(text, this, g);
                    bool overlap2 = _overlapDetector != null && _overlapDetector.Overlaps(textRect);
                    _manualLabels[text] = textRect;
                    if (!overlap2)
                    {
                        _pointAnnotations.Add(text);
                        AddAnnotations(g);
                    }
                }
            }

            // add manual annotations
            foreach (CurveItem item in CurveList)
            {
                IMSGraphItemInfo info   = item.Tag as IMSGraphItemInfo;
                MSPointList      points = item.Points as MSPointList;
                if (info == null || points == null)
                {
                    continue;
                }

                info.AddAnnotations(this, g, points, _pointAnnotations);
                AddAnnotations(g);
            }

            autoScaleForManualLabels(g);
            g.Clip = previousClip;
        }
コード例 #14
0
ファイル: MSGraphPane.cs プロジェクト: lgatto/proteowizard
        private void drawLabels( Graphics g )
        {
            foreach( GraphObj pa in _pointAnnotations )
                GraphObjList.Remove( pa );
            _pointAnnotations.Clear();
            _manualLabels.Clear();

            Axis xAxis = XAxis;
            Axis yAxis = YAxis;

            yAxis.Scale.MinAuto = false;
            if (LockYAxisAtZero)
                yAxis.Scale.Min = 0;

            // ensure that the chart rectangle is the right size
            AxisChange(g);
            // then setup axes scales to enable the Transform method
            xAxis.Scale.SetupScaleData(this, xAxis);
            yAxis.Scale.SetupScaleData( this, yAxis );

            if( Chart.Rect.Width < 1 || Chart.Rect.Height < 1 )
                return;

            _overlapDetector = AllowLabelOverlap ? null : new OverlapDetector();
            Region chartRegion = new Region( Chart.Rect );
            Region clipRegion = new Region();
            clipRegion.MakeEmpty();
            var previousClip = g.Clip.Clone();
            g.SetClip( Rect, CombineMode.Replace );
            g.SetClip( chartRegion, CombineMode.Exclude );

            /*Bitmap clipBmp = new Bitmap(Convert.ToInt32(Chart.Rect.Width), Convert.ToInt32(Chart.Rect.Height));
            Graphics clipG = Graphics.FromImage(clipBmp);
            clipG.Clear(Color.White);
            clipG.FillRegion(new SolidBrush(Color.Black), g.Clip);
            clipBmp.Save("C:\\clip.bmp");*/


            // some dummy labels for very fast clipping
            string baseLabel = "0"; // Not L10N
            foreach( CurveItem item in CurveList )
            {
                IMSGraphItemInfo info = item.Tag as IMSGraphItemInfo;
                if( info != null )
                {
                    PointAnnotation annotation = info.AnnotatePoint( new PointPair( 0, 0 ) );
                    if( annotation != null &&
                        annotation.Label != null &&
                        annotation.Label.Length > baseLabel.Length )
                        baseLabel = annotation.Label;
                }
            }

            TextObj baseTextObj = new TextObj( baseLabel, 0, 0 );
            baseTextObj.FontSpec.Border.IsVisible = false;
            baseTextObj.FontSpec.Fill.IsVisible = false;
            PointF[] pts = baseTextObj.FontSpec.GetBox( g, baseLabel, 0, 0,
                                AlignH.Center, AlignV.Bottom, 1.0f, new SizeF() );
            float baseLabelWidth = pts[1].X - pts[0].X;
            float baseLabelHeight = pts[2].Y - pts[0].Y;
            baseLabelWidth = (float) xAxis.Scale.ReverseTransform( xAxis.Scale.Transform( 0 ) + baseLabelWidth );
            baseLabelHeight = (float) yAxis.Scale.ReverseTransform( yAxis.Scale.Transform( 0 ) - baseLabelHeight );
            float labelLengthToWidthRatio = baseLabelWidth / baseLabel.Length;

            float xAxisPixel = yAxis.Scale.Transform( 0 );

            double xMin = xAxis.Scale.Min;
            double xMax = xAxis.Scale.Max;
            double yMin = yAxis.Scale.Min;
            double yMax = yAxis.Scale.Max;

            // add manual annotations with TextObj priority over curve annotations
            foreach (CurveItem item in CurveList)
            {
                var info = item.Tag as IMSGraphItemExtended;
                MSPointList points = item.Points as MSPointList;
                if (info == null || points == null)
                    continue;

                info.AddPreCurveAnnotations(this, g, points, _pointAnnotations);
                AddAnnotations(g);
            }

            // add automatic labels for MSGraphItems
            foreach( CurveItem item in CurveList )
            {
                IMSGraphItemInfo info = item.Tag as IMSGraphItemInfo;
                MSPointList points = item.Points as MSPointList;
                if( info == null || points == null )
                    continue;

                if( info.ToString().Length == 0 )
                    continue;

                PointPairList fullList = points.FullList;
                List<int> maxIndexList = points.ScaledMaxIndexList;
                for( int i = 0; i < maxIndexList.Count; ++i )
                {
                    if( maxIndexList[i] < 0 )
                        continue;
                    PointPair pt = fullList[maxIndexList[i]];

                    if( pt.X < xMin || pt.Y > yMax || pt.Y < yMin )
                        continue;
                    if( pt.X > xMax )
                        break;

                    float yPixel = yAxis.Scale.Transform( pt.Y );

                    // labelled points must be at least 3 pixels off the X axis
                    if( xAxisPixel - yPixel < 3 )
                        continue;

                    PointAnnotation annotation = info.AnnotatePoint( pt );
                    if( annotation == null )
                        continue;

                    if( annotation.ExtraAnnotation != null )
                    {
                        GraphObjList.Add( annotation.ExtraAnnotation );
                        _pointAnnotations.Add( annotation.ExtraAnnotation );
                    }

                    if( string.IsNullOrEmpty(annotation.Label) )
                        continue;

                    float pointLabelWidth = labelLengthToWidthRatio * annotation.Label.Split('\n').Max(o => o.Length);

                    double labelY = yAxis.Scale.ReverseTransform(yPixel - 5);

                    if (!AllowCurveOverlap)
                    {
                        // do fast check for overlap against all MSGraphItems
                        bool overlap = false;
                        foreach (CurveItem item2 in CurveList)
                        {
                            MSPointList points2 = item2.Points as MSPointList;
                            if (points2 != null)
                            {
                                int nearestMaxIndex = points2.GetNearestMaxIndexToBin(i);
                                if (nearestMaxIndex < 0)
                                    continue;
                                RectangleF r = new RectangleF((float)pt.X - pointLabelWidth / 2,
                                                               (float)labelY - baseLabelHeight,
                                                               pointLabelWidth,
                                                               baseLabelHeight);
                                overlap = detectLabelCurveOverlap(this, points2.FullList, nearestMaxIndex, item2 is StickItem, r);
                                if (overlap)
                                    break;
                            }
                        }

                        if (overlap)
                            continue;
                    }

                    TextObj text = new TextObj( annotation.Label, pt.X, labelY,
                                                CoordType.AxisXYScale, AlignH.Center, AlignV.Bottom )
                    {
                        ZOrder = ZOrder.A_InFront,
                        FontSpec = annotation.FontSpec,
                        IsClippedToChartRect = true
                    };

                    var textRect = _labelBoundsCache.GetLabelBounds(text, this, g);
                    bool overlap2 = _overlapDetector != null && _overlapDetector.Overlaps(textRect);
                    _manualLabels[text] = textRect;
                    if (!overlap2)
                    {
                        _pointAnnotations.Add(text);
                        AddAnnotations(g);
                    }
                }
            }

            // add manual annotations
            foreach( CurveItem item in CurveList )
            {
                IMSGraphItemInfo info = item.Tag as IMSGraphItemInfo;
                MSPointList points = item.Points as MSPointList;
                if( info == null || points == null )
                    continue;

                info.AddAnnotations( this, g,  points, _pointAnnotations );
                AddAnnotations(g);
            }

            autoScaleForManualLabels(g);
            g.Clip = previousClip;
        }