/// <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(); } }
public void CancelChangesAction(object sender) { for (int i = 0; i < attributeNumericSpriteFontList.Count; i++) { NumericSpriteFont nsf = attributeNumericSpriteFontList[i]; nsf.UpdateValue(attributes[i]); } remainingPoints = GameInformation.Instance.PlayerInformation.GetCurrentAttributePoints() - attributes.ToList().Sum(); cancel.Disable(); accept.Disable(); UpdateAttributeButtons(); }
public ThorSatellite() { targetList = new List <Projectile>(); beamColor = Parameter.NeonGreen; oscilatingPositionOffset = new Vector2(3, 0); cannonOffset = new Vector2(50, 0); position = new Vector2(0, -500); flipbook = new Flipbook(position, new Vector2(118, 111), 197, 190, "Graphics/Entity/Thor/Spritesheet", thorStatePresets[ActorFlipbookState.Stand], DepthParameter.Mobile, MathHelper.PiOver2); levelSpriteFont = new NumericSpriteFont(FontType.HUDBlueThorLevelIndicator, 1, DepthParameter.MobileSatellite, textAnchor: TextAnchor.Right, attachToCamera: false, StartingValue: 1); experienceSpriteFont = new CurrencySpriteFont(FontType.HUDBlueThorExperienceIndicator, 5, DepthParameter.MobileSatellite, textAnchor: TextAnchor.Right, attachToCamera: false); levelText = new Sprite("Interface/Spritefont/HUD/Blue/ThorLevelLV", Vector2.Zero, layerDepth: DepthParameter.MobileSatellite); levelText.Pivot = Vector2.Zero; lastFocusedPosition = Vector2.Zero; }
public AttributeMenu(Vector2 basePosition, Player player) { this.basePosition = basePosition; numericSpriteFontList = new List <NumericSpriteFont>(); attributeNumericSpriteFontList = new List <NumericSpriteFont>(); buttonList = new List <Button>(); addAttributeButtonList = new List <Button>(); removeAttributeButtonList = new List <Button>(); attributes = GameInformation.Instance.PlayerInformation.Attribute; //Nameplates nameplate = new Nameplate(player, Alignment.Left, basePosition + new Vector2(15, 43)); //Gold/Cash goldSpriteText = new SpriteText(FontTextType.Consolas10, "", Parameter.InterfaceAvatarShopButtonGoldColor, Alignment.Right, DepthParameter.InterfaceButton, basePosition, Parameter.InterfaceAvatarShopButtonGoldOutlineColor); goldSpriteText.Position = basePosition + new Vector2(192, 133); goldIcon = new Sprite("Interface/StaticButtons/AvatarShop/AvatarButton/GoldIcon", basePosition + new Vector2(202, 138), DepthParameter.InterfaceButton, new Rectangle(0, 0, 26, 21)); goldIcon.Pivot = new Vector2(13, 10.5f); goldIcon.Scale /= 2; cashSpriteText = new SpriteText(FontTextType.Consolas10, "", Parameter.InterfaceAvatarShopButtonCashColor, Alignment.Right, DepthParameter.InterfaceButton, basePosition, Parameter.InterfaceAvatarShopButtonCashOutlineColor); cashSpriteText.Position = basePosition + new Vector2(192, 152); cashIcon = new Sprite("Interface/StaticButtons/AvatarShop/AvatarButton/CashIcon", basePosition + new Vector2(202, 157), DepthParameter.InterfaceButton, new Rectangle(0, 0, 26, 21)); cashIcon.Pivot = new Vector2(13, 10.5f); cashIcon.Scale /= 2; //Confirm/Cancel points accept = new Button(ButtonType.Accept, DepthParameter.InterfaceButton, AcceptChangesAction, -new Vector2(362, 182)); cancel = new Button(ButtonType.Cancel, DepthParameter.InterfaceButton, CancelChangesAction, -new Vector2(332, 182)); accept.ButtonSprite.Scale = cancel.ButtonSprite.Scale *= 3f / 4f; cancel.Disable(); accept.Disable(); //Remaining Points remainingPointsSpriteTextList = new List <SpriteText>() { new SpriteText(FontTextType.Consolas10, "Remaining", Color.White, Alignment.Center, DepthParameter.InterfaceButtonText, outlineColor: Color.Black), new SpriteText(FontTextType.Consolas10, "Points", Color.White, Alignment.Center, DepthParameter.InterfaceButtonText, outlineColor: Color.Black), }; remainingPointsSpriteTextList[0].Position = basePosition + new Vector2(53, 60); remainingPointsSpriteTextList[1].Position = basePosition + new Vector2(53, 75); //Calculate remaining points remainingPoints = GameInformation.Instance.PlayerInformation.GetCurrentAttributePoints() - attributes.ToList().Sum(); remaningPointsNumericSpriteFont = new NumericSpriteFont(FontType.AvatarShopStatusCounter, 3, DepthParameter.InterfaceButton, PositionOffset: new Vector2(-356, -210), StartingValue: remainingPoints, forceRendingAllNumbers: true); numericSpriteFontList.Add(remaningPointsNumericSpriteFont); //Attribute Points AddAttributePoints(); RefreshCurrencyValues(); buttonList.Add(accept); buttonList.Add(cancel); }
public AttributeStatusBarItem(Sprite sprite, NumericSpriteFont numericSpriteFont) { Sprite = sprite; NumericSpriteFont = numericSpriteFont; }
public void Update(GameTime GameTime) { #if DEBUG //DEBUG debugCrosshair1.Update(CannonPosition); debugCrosshair2.Update(CrosshairPointer.Position); #endif //Calculating Cannon Position, Cannon Frame (Sprite) Position & Angle int newPosX = (int)(crosshairPreset.CannonOffsetDistance * Math.Cos(mobile.MobileFlipbook.Rotation + crosshairPreset.CannonOffsetRotation)); int newPosY = (int)(crosshairPreset.CannonOffsetDistance * Math.Sin(mobile.MobileFlipbook.Rotation + crosshairPreset.CannonOffsetRotation)); crosshairFrame.Position = CannonPosition = mobile.MobileFlipbook.Position + new Vector2(newPosX, newPosY); crosshairFrame.Rotation = mobile.MobileFlipbook.Rotation; //Update the shooting angle based on how much time up/down key has been pressed if (mobile.IsPlayable) { UpdateShootingAngle(GameTime); } else { AutomaticUpdateShootingAngle(GameTime); } // Force shooting angle to keep between the selected min and max ShootingAngle = MathHelper.Clamp(ShootingAngle, aimPreset.AimFalseRotationMin, aimPreset.AimFalseRotationMax); // Update the crosshair angle if (mobile.IsPlayable) { if (!IsTrueAngle) { selectedCrosshairAngle = crosshairAngleList[0]; } else { selectedCrosshairAngle = crosshairAngleList[1]; } } // Calculate new crosshair pointer depending on wich side the tank is facing if (mobile.Facing == Facing.Left) { CrosshairPointer.Rotation = crosshairFrame.Rotation + MathHelper.ToRadians(270 + ShootingAngle); newPosX = (int)(crosshairPreset.CrosshairPointerOffset * Math.Cos(crosshairDesiredRotation + MathHelper.ToRadians(ShootingAngle))); newPosY = (int)(crosshairPreset.CrosshairPointerOffset * Math.Sin(crosshairDesiredRotation + MathHelper.ToRadians(ShootingAngle))); //And calculate the Delay numeric field position if (mobile.IsPlayable) { selectedCrosshairAngle.Position = crosshairFrame.Position + 30 * new Vector2( (float)Math.Cos(crosshairFrame.Rotation + MathHelper.ToRadians(150)), (float)Math.Sin(crosshairFrame.Rotation + MathHelper.ToRadians(150))); } } else { CrosshairPointer.Rotation = crosshairFrame.Rotation + MathHelper.ToRadians(90 - ShootingAngle); newPosX = (int)(crosshairPreset.CrosshairPointerOffset * Math.Cos(crosshairDesiredRotation - MathHelper.ToRadians(ShootingAngle))); newPosY = (int)(crosshairPreset.CrosshairPointerOffset * Math.Sin(crosshairDesiredRotation - MathHelper.ToRadians(ShootingAngle))); //And calculate the Delay numeric field position if (mobile.IsPlayable) { selectedCrosshairAngle.Position = crosshairFrame.Position - 30 * new Vector2( (float)Math.Cos(crosshairFrame.Rotation - MathHelper.ToRadians(150)), (float)Math.Sin(crosshairFrame.Rotation - MathHelper.ToRadians(150))); } } CalculateHUDAngle(); // Update the HUD angle text after defining its position selectedCrosshairAngle?.UpdateValue(HUDSelectedAngle); selectedCrosshairAngle?.Update(); // Update the crosshair pointer location CrosshairPointer.Position = CannonPosition - new Vector2(newPosX, newPosY); // Update crosshair aim range indicators crosshairRangeIndicatorList.ForEach( (x) => { x.Position = crosshairFrame.Position; x.Rotation = crosshairFrame.Rotation; }); //Update Animations animationEventHandler?.Invoke(GameTime, null); }
private RoomButton(RoomMetadata roomMetadata, Vector2 buttonPosition, Action <object> action, ButtonPreset buttonPreset) : base(ButtonType.RoomButton, DepthParameter.InterfaceButton, action, buttonPosition, buttonPreset) { spriteList = new List <Sprite>(); spriteFontList = new List <NumericSpriteFont>(); //Since the button elements dont update, the screencenter //must be added in order to create the right position //on the elements buttonPosition += Parameter.ScreenCenter; //MAP Vector2 mapCenter = buttonPosition + new Vector2(28, 11f); Sprite map = new Sprite($"Graphics/Maps/{roomMetadata.Map.GameMap}/GameListThumb{roomMetadata.Map.GameMapType}", mapCenter, DepthParameter.InterfaceButtonIcon); spriteList.Add(map); //RoomStatus int rectangleOffset = roomMetadata.IsPlaying ? 0 : (roomMetadata.IsFull ? 2 * 91 : 91); Sprite roomStatus = new Sprite("Interface/StaticButtons/GameList/Status", mapCenter - new Vector2(100, 0), DepthParameter.InterfaceButtonIcon, new Rectangle(rectangleOffset, 0, 91, 27)) { Pivot = new Vector2(91 / 2, 27 / 2) }; spriteList.Add(roomStatus); //RoomName SpriteText[] roomName = new SpriteText[2] { new SpriteText(FontTextType.Consolas11, string.Format("{0,3}", roomMetadata.ID) + " ", Color.White, Alignment.Left, DepthParameter.InterfaceButtonText), new SpriteText(FontTextType.Consolas11, roomMetadata.Name, Color.White, Alignment.Left, DepthParameter.InterfaceButtonText) }; compositeSpriteText = CompositeSpriteText.CreateCompositeSpriteText(roomName.ToList(), Orientation.Horizontal, Alignment.Left, buttonPosition - new Vector2(115, 25), 0); //SpriteFont NumericSpriteFont nsf = new NumericSpriteFont(FontType.GameListPlayerCounter, 1, DepthParameter.InterfaceButtonText, Position: buttonPosition + new Vector2(91, -24), StartingValue: roomMetadata.NumberOfPlayers, attachToCamera: false); spriteFontList.Add(nsf); NumericSpriteFont nsf2 = new NumericSpriteFont(FontType.GameListPlayerCounter, 1, DepthParameter.InterfaceButtonText, Position: buttonPosition + new Vector2(105, -24), StartingValue: (int)roomMetadata.Size, attachToCamera: false); spriteFontList.Add(nsf2); //IsPasswordProtected if (roomMetadata.HasPassword) { Sprite passwordLock = new Sprite("Interface/StaticButtons/GameList/PasswordProtected", mapCenter, DepthParameter.InterfaceButtonAnimatedIcon); spriteList.Add(passwordLock); } //HasBuddyInRoom if (HasBuddyInside(roomMetadata)) { Sprite buddy = new Sprite("Interface/StaticButtons/GameList/BuddyInside", mapCenter + new Vector2(32, 0), DepthParameter.InterfaceButtonAnimatedIcon); spriteList.Add(buddy); } }