예제 #1
0
		/// <summary>
		/// Construct a character renderer pre-game (character creation dialog, character list)
		/// </summary>
		/// <param name="drawLocation">Where to draw it</param>
		/// <param name="data">Render data to use for drawing</param>
		public CharacterRenderer(Vector2 drawLocation, CharRenderData data)
			: base(drawLocation, null)
		{
			noLocUpdate = true;
			_char = new Character(null, -1, data);
			spriteSheet = new EOSpriteSheet(((EOGame)Game).GFXManager, _char);
			//when this is a part of a dialog, the drawareaoffset will be set accordingly and is used in the draw method
			//otherwise, it will just draw it at the absolute location specified by drawArea

			drawArea = new Rectangle((int) drawLocation.X, (int) drawLocation.Y, 1, 1);
			Data.SetUpdate(true);

			if (data.name.Length > 0)
			{
				//362, 167 abs loc
				levelLabel = new XNALabel(new Rectangle(-32, 75, 1, 1), Constants.FontSize08pt75)
				{
					ForeColor = Constants.BeigeText,
// ReSharper disable SpecifyACultureInStringConversionExplicitly
					Text = data.level.ToString()
// ReSharper restore SpecifyACultureInStringConversionExplicitly
				};
				levelLabel.SetParent(this);

				//504, 93 abs loc
				nameLabel = new XNALabel(new Rectangle(104, 2, 89, 22), Constants.FontSize08pt5)
				{
					ForeColor = Constants.BeigeText,
					Text = ((char) (data.name[0] - 32)) + data.name.Substring(1),
					TextAlign = LabelAlignment.MiddleCenter,
					AutoSize = false
				};
				nameLabel.SetParent(this);

				adminGraphic = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 22);
				if (data.admin == 1)
				{
					adminRect = new Rectangle(252, 39, 17, 17);
				}
				else if (data.admin > 1)
				{
					adminRect = new Rectangle(233, 39, 17, 17);
				}
				else
				{
					adminRect = null;
				}
			}
		}
예제 #2
0
		/// <summary>
		/// Construct a character renderer in-game
		/// </summary>
		/// <param name="charToRender">The character data that should be wrapped by this renderer</param>
		public CharacterRenderer(Character charToRender)
		{
			//this has been happening when shit gets disconnected due to invalid sequence or internal packet id
			if (charToRender == null)
			{
				EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
				return;
			}

			spriteSheet = new EOSpriteSheet(((EOGame)Game).GFXManager, charToRender);
			_char = charToRender;
			_data = charToRender.RenderData;
			Texture2D tmpSkin = spriteSheet.GetSkin(false, out m_skinSourceRect);
			if (_char != World.Instance.MainPlayer.ActiveCharacter)
			{
				drawArea = new Rectangle(
					_char.OffsetX + 304 - World.Instance.MainPlayer.ActiveCharacter.OffsetX,
					_char.OffsetY + 91 - World.Instance.MainPlayer.ActiveCharacter.OffsetY,
					m_skinSourceRect.Width, m_skinSourceRect.Height); //set based on size of the sprite and location of charToRender
			}
			else
			{
				drawArea = new Rectangle((618 - m_skinSourceRect.Width) / 2 + 4, (298 - m_skinSourceRect.Height) / 2 - 29, m_skinSourceRect.Width, m_skinSourceRect.Height);
				noLocUpdate = true; //make sure not to update the drawArea rectangle in the update method
			}
			Data.SetUpdate(true);

			//get the top pixel!
			Color[] skinData = new Color[m_skinSourceRect.Width * m_skinSourceRect.Height];
			tmpSkin.GetData(0, m_skinSourceRect, skinData, 0, skinData.Length);
			int i = 0;
			while (i < skinData.Length && skinData[i].A == 0) i++;
			//account for adjustment in drawing the skin in the draw method
			TopPixel = (Data.gender == 0 ? 12 : 13) + (i == skinData.Length - 1 ? 0 : i / m_skinSourceRect.Height);

			m_chatBubble = new EOChatBubble(this);
			m_damageCounter = new DamageCounter(this);

			_mouseoverName = new BlinkingLabel(new Rectangle(1, 1, 1, 1), Constants.FontSize08pt75)
			{
				Visible = false,
				Text = Character.Name,
				ForeColor = Color.White,
				DrawOrder = (int)ControlDrawLayer.BaseLayer + 3,
				AutoSize = false
			};
			_mouseoverName.DrawLocation = new Vector2(
				DrawAreaWithOffset.X + (32 - _mouseoverName.ActualWidth)/2f,
				DrawAreaWithOffset.Y + TopPixel - _mouseoverName.ActualHeight - 7);
			_mouseoverName.ResizeBasedOnText();
		}