Пример #1
0
        /// <summary>
        /// Crosshair must be initialized inside the Concrete Mobile class after its name is set.
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="isAlly"></param>
        public Crosshair(Mobile mobile)
        {
            //Save References
            this.mobile = mobile;

            //Initialize Crosshair/Pointer Sprites
            crosshairFrame = new Sprite($"Interface/InGame/HUD/Crosshair/CrosshairFrame",
                                        new Vector2(0, 0), DepthParameter.CrosshairFrame);

            crosshairRangeIndicatorList = new List <Sprite>()
            {
                new Sprite($"Interface/InGame/HUD/Crosshair/{mobile.MobileType}{ShotType.S1}" + (mobile.IsEnemy ? "Enemy":"Ally"),
                           new Vector2(0, 0), DepthParameter.CrosshairAimRangeIndicator),
                new Sprite($"Interface/InGame/HUD/Crosshair/{mobile.MobileType}{ShotType.S2}" + (mobile.IsEnemy ? "Enemy":"Ally"),
                           new Vector2(0, 0), DepthParameter.CrosshairAimRangeIndicator),
                new Sprite($"Interface/InGame/HUD/Crosshair/{mobile.MobileType}{ShotType.SS}" + (mobile.IsEnemy ? "Enemy":"Ally"),
                           new Vector2(0, 0), DepthParameter.CrosshairAimRangeIndicator),
            };
            selectedCrosshairRangeIndicator = crosshairRangeIndicatorList[0];

            CrosshairPointer = new Sprite("Interface/InGame/HUD/Crosshair/Pointer",
                                          new Vector2(0, 0), DepthParameter.CrosshairPointer);

            //Initialize Crosshair Components
            crosshairPreset          = crosshairPresets[mobile.MobileType][mobile.SelectedShotType].Clone();
            crosshairDesiredRotation = 0f;

            if (mobile.IsPlayable)
            {
                crosshairAngleList = new List <NumericSpriteFont>()
                {
                    new NumericSpriteFont(FontType.HUDBlueCrosshairTrueAngle, 3, Parameter.HUDCrosshairAngleIndicator, textAnchor: TextAnchor.Middle, attachToCamera: false),
                    new NumericSpriteFont(FontType.HUDBlueCrosshairFalseAngle, 3, Parameter.HUDCrosshairAngleIndicator, textAnchor: TextAnchor.Middle, attachToCamera: false)
                };

                selectedCrosshairAngle = crosshairAngleList[0];
            }

            //Initialize Shooting Angle
            aimPreset     = mobile.MobileMetadata.MobileAimPreset[ShotType.S1];
            ShootingAngle = (aimPreset.AimTrueRotationMin + aimPreset.AimTrueRotationMax) / 2;

            CrosshairPointer.Rotation = crosshairFrame.Rotation + MathHelper.ToRadians(270 + ShootingAngle);

#if DEBUG
            //DEBUG
            debugCrosshair1 = new DebugCrosshair(Color.HotPink);
            debugCrosshair2 = new DebugCrosshair(Color.DarkTurquoise);
            DebugHandler.Instance.Add(debugCrosshair1);
            DebugHandler.Instance.Add(debugCrosshair2);
#endif
            if (mobile.IsPlayable)
            {
                FadeElement();
            }
            else
            {
                HideElement();
            }
        }
Пример #2
0
        private void ChangeCrosshairPreset(ShotType shotType)
        {
            CrosshairPreset prevPreset = crosshairPreset;

            if (crosshairPresets[mobile.MobileType].ContainsKey(shotType))
            {
                crosshairPreset = crosshairPresets[mobile.MobileType][shotType].Clone();
            }
            else
            {
                crosshairPreset = crosshairPresets[mobile.MobileType][ShotType.S1].Clone();
            }

            //neg = neg * -1 * pos
            //neg = neg * -1 * neg
            //pos = pos * -1 * pos
            if (Math.Sign(prevPreset.CannonOffsetRotation) != Math.Sign(crosshairPreset.CannonOffsetRotation))
            {
                crosshairPreset.CannonOffsetDistance *= -1;
                crosshairPreset.CannonOffsetRotation *= -1;
            }
        }