private IXNAButton CreateStateChangeButton(InGameStates whichState) { if (whichState == InGameStates.News) { throw new ArgumentOutOfRangeException(nameof(whichState), "News state does not have a button associated with it"); } var buttonIndex = (int)whichState; var mainButtonTexture = _nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 25); var widthDelta = mainButtonTexture.Width / 2; var heightDelta = mainButtonTexture.Height / 11; var xPosition = buttonIndex < 6 ? 62 : 590; var yPosition = (buttonIndex < 6 ? 330 : 350) + (buttonIndex < 6 ? buttonIndex : buttonIndex - 6) * 20; var retButton = new XNAButton( mainButtonTexture, new Vector2(xPosition, yPosition), new Rectangle(0, heightDelta * buttonIndex, widthDelta, heightDelta), new Rectangle(widthDelta, heightDelta * buttonIndex, widthDelta, heightDelta)) { DrawOrder = HUD_CONTROL_LAYER }; retButton.OnClick += (o, e) => DoHudStateChangeClick(whichState); retButton.OnMouseEnter += (o, e) => _statusLabelSetter.SetStatusLabel( EOResourceID.STATUS_LABEL_TYPE_BUTTON, EOResourceID.STATUS_LABEL_HUD_BUTTON_HOVER_FIRST + buttonIndex); return(retButton); }
private void HandleWalkToWarpTile(IWarp warp) { if (warp.DoorType != DoorSpec.NoDoor) { if (!_unlockDoorValidator.CanMainCharacterOpenDoor(warp)) { var requiredKey = _unlockDoorValidator.GetRequiredKey(warp); var messageBox = _eoMessageBoxFactory.CreateMessageBox(DialogResourceID.DOOR_LOCKED); messageBox.ShowDialog(); _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.STATUS_LABEL_THE_DOOR_IS_LOCKED_EXCLAMATION, " - " + requiredKey); } else if (!_currentMapStateRepository.OpenDoors.Contains(warp) && !_currentMapStateRepository.PendingDoors.Contains(warp)) { var packet = new PacketBuilder(PacketFamily.Door, PacketAction.Open) .AddChar((byte)warp.X) .AddChar((byte)warp.Y) .Build(); _packetSendService.SendPacket(packet); _currentMapStateRepository.PendingDoors.Add(warp); } } else if (warp.LevelRequirement > 0 && MainCharacter.Stats[CharacterStat.Level] < warp.LevelRequirement) { _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.STATUS_LABEL_NOT_READY_TO_USE_ENTRANCE, " - LVL " + warp.LevelRequirement); } }
private void AttemptAttack() { var validationResult = _attackValidationActions.ValidateCharacterStateBeforeAttacking(); if (validationResult != AttackValidationError.OK) { if (validationResult == AttackValidationError.Overweight) { _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.STATUS_LABEL_CANNOT_ATTACK_OVERWEIGHT); } else if (validationResult == AttackValidationError.Exhausted) { _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.ATTACK_YOU_ARE_EXHAUSTED_SP); } else if (validationResult == AttackValidationError.NotYourBattle) { _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, EOResourceID.STATUS_LABEL_UNABLE_TO_ATTACK); } } else { //todo: lower SP for character when attacking _characterActions.Attack(); _characterAnimationActions.StartAttacking(); } }
public void NotifyGainedExp(int expDifference) { _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, EOResourceID.STATUS_LABEL_YOU_GAINED_EXP, $"{expDifference} EXP"); var youGained = _localizedStringFinder.GetString(EOResourceID.STATUS_LABEL_YOU_GAINED_EXP); var message = $"{youGained} {expDifference} EXP"; var chatData = new ChatData(string.Empty, message, ChatIcon.Star); _chatRepository.AllChat[ChatTab.System].Add(chatData); }
public void LeftClick(IMapCellState cellState) { var item = cellState.Items.OptionalFirst(); if (item.HasValue) { if (!_inventorySpaceValidator.ItemFits(item.Value)) { _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, EOResourceID.STATUS_LABEL_ITEM_PICKUP_NO_SPACE_LEFT); } else { HandlePickupResult(_mapActions.PickUpItem(item.Value), item.Value); } } }
public void ToggleMapView() { var mapFile = _mapFileProvider.MapFiles[_currentMapStateRepository.CurrentMapID]; if (!mapFile.Properties.MapAvailable) { _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.STATUS_LABEL_NO_MAP_OF_AREA); return; } _currentMapStateRepository.ShowMiniMap = !_currentMapStateRepository.ShowMiniMap; }
public void NotifyPlayerMutedByAdmin(string adminName) { var chatTextBox = _hudControlProvider.GetComponent <ChatTextBox>(HudControlIdentifier.ChatTextBox); var chatMode = _hudControlProvider.GetComponent <ChatModePictureBox>(HudControlIdentifier.ChatModePictureBox); var endMuteTime = DateTime.Now.AddMinutes(Constants.MuteDefaultTimeMinutes); chatTextBox.SetMuted(endMuteTime); chatMode.SetMuted(endMuteTime); chatTextBox.Text = string.Empty; var chatData = new ChatData(_localizedStringFinder.GetString(EOResourceID.STRING_SERVER), _localizedStringFinder.GetString(EOResourceID.CHAT_MESSAGE_MUTED_BY) + " " + adminName, ChatIcon.Exclamation, ChatColor.Server); _chatRepository.AllChat[ChatTab.Local].Add(chatData); _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, Constants.MuteDefaultTimeMinutes.ToString(CultureInfo.InvariantCulture), EOResourceID.STATUS_LABEL_MINUTES_MUTED); }
public async Task LoginToCharacter(ICharacter character) { var requestCharacterLoginOperation = _networkOperationFactory.CreateSafeBlockingOperation( async() => await _loginActions.RequestCharacterLogin(character), SetInitialStateAndShowError, SetInitialStateAndShowError); if (!await requestCharacterLoginOperation.Invoke()) { return; } var unableToLoadMap = false; try { _mapFileLoadActions.LoadMapFileByID(_currentMapStateProvider.CurrentMapID); } catch (IOException) { // Try to load the map now that we know what Map ID we need // non-fatal exception unableToLoadMap = true; } GameLoadingDialog gameLoadingDialog = null; try { gameLoadingDialog = _gameLoadingDialogFactory.CreateGameLoadingDialog(); gameLoadingDialog.ShowDialog(); await InitialDelayInReleaseMode(); if (unableToLoadMap || _fileRequestActions.NeedsFileForLogin(InitFileType.Map, _currentMapStateProvider.CurrentMapID)) { gameLoadingDialog.SetState(GameLoadingDialogState.Map); if (!await SafeGetFile(async() => await _fileRequestActions.GetMapFromServer(_currentMapStateProvider.CurrentMapID))) { return; } await Task.Delay(1000); } if (_fileRequestActions.NeedsFileForLogin(InitFileType.Item)) { gameLoadingDialog.SetState(GameLoadingDialogState.Item); if (!await SafeGetFile(_fileRequestActions.GetItemFileFromServer)) { return; } await Task.Delay(1000); } if (_fileRequestActions.NeedsFileForLogin(InitFileType.Npc)) { gameLoadingDialog.SetState(GameLoadingDialogState.NPC); if (!await SafeGetFile(_fileRequestActions.GetNPCFileFromServer)) { return; } await Task.Delay(1000); } if (_fileRequestActions.NeedsFileForLogin(InitFileType.Spell)) { gameLoadingDialog.SetState(GameLoadingDialogState.Spell); if (!await SafeGetFile(_fileRequestActions.GetSpellFileFromServer)) { return; } await Task.Delay(1000); } if (_fileRequestActions.NeedsFileForLogin(InitFileType.Class)) { gameLoadingDialog.SetState(GameLoadingDialogState.Class); if (!await SafeGetFile(_fileRequestActions.GetClassFileFromServer)) { return; } await Task.Delay(1000); } gameLoadingDialog.SetState(GameLoadingDialogState.LoadingGame); var completeCharacterLoginOperation = _networkOperationFactory.CreateSafeBlockingOperation( _loginActions.CompleteCharacterLogin, SetInitialStateAndShowError, SetInitialStateAndShowError); if (!await completeCharacterLoginOperation.Invoke()) { return; } await Task.Delay(1000); //always wait 1 second } finally { if (gameLoadingDialog != null) { gameLoadingDialog.CloseDialog(); } } _gameStateActions.ChangeToState(GameStates.PlayingTheGame); _chatTextBoxActions.FocusChatTextBox(); _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.LOADING_GAME_HINT_FIRST); _firstTimePlayerActions.WarnFirstTimePlayers(); _mapChangedActions.ActiveCharacterEnterMapForLogin(); }