public InventoryWindow(Skin skin, Vector2 position, float width = -1, float height = -1, string title = "Inventory", string styleName = null) : base(title, skin, styleName) { sprite = TextureContainer.GetSpriteAtlasByName("UI").GetSprite("bg_01_02"); SetMovable(true); SetResizable(true); SetResizeBorderSize(20); AddItems(skin); Pack(); if (width != -1) { SetWidth(width); } if (height != -1) { SetHeight(height); } if (position == new Vector2(-1, -1)) { SetPosition(Core.GraphicsDevice.Viewport.Width - GetWidth(), Core.GraphicsDevice.Viewport.Height - GetHeight()); } else { SetPosition(position.X, position.Y); } NinePatchDrawable drawable = new NinePatchDrawable(sprite, 0, 0, 0, 0) { MinHeight = this.MinHeight, MinWidth = this.MinWidth }; SetBackground(drawable); }
public OtherPlayerEntity(CharacterPlayer others) : base(others._name) { others.MaxHealth = 100; other = others; TextComponent textComponent = new TextComponent(Graphics.Instance.BitmapFont, others._name, Vector2.Zero, Color.White); //HealthtextComponent = new TextComponent(Graphics.Instance.BitmapFont, others.CurrentHealth.ToString(), Vector2.Zero, Color.White); this.SetPosition(others.physicalPosition); AddComponent(new OtherPlayerComponent(others)); AddComponent(textComponent); //AddComponent(HealthtextComponent).SetHorizontalAlign(HorizontalAlign.Left).SetVerticalAlign(VerticalAlign.Bottom).SetRenderLayer(-2); SetTag(7); this.SetScale(3.5f); SpriteAnimation Idle = TextureContainer.GetSpriteAtlasByName("Knight").GetAnimation("Idle"); SpriteAnimation Movement = TextureContainer.GetSpriteAtlasByName("Knight").GetAnimation("Movement"); SpriteAnimator animator = AddComponent <SpriteAnimator>(); animator.AddAnimation("Idle", Idle); animator.AddAnimation("Movement", Movement); animator.Play("Idle"); }
public AbilityAnimationEntity(AbilityHead ability, Entity target, Vector2 source) { this.ability = ability; this.target = target; this.SetScale(0.25f); this.source = source; switch (ability.ID) { case 1: animation = TextureContainer.GetSpriteAtlasByName("FireBall").GetAnimation("travel"); break; default: break; } float deltaX = target.Position.X - source.X; this.SetPosition(source); animator = AddComponent <SpriteAnimator>(); if (deltaX > 0) { animator.FlipX = true; } animator.AddAnimation("travel", animation); animator.Play("travel"); }
private void AddItems(Skin skin) { var textButtonStyle = new ImageButtonStyle { Up = new PrimitiveDrawable(Color.DarkGray, 6, 2), Over = new PrimitiveDrawable(Color.DimGray), Down = new PrimitiveDrawable(Color.DimGray), PressedOffsetX = 0, PressedOffsetY = 0 }; int count = 0; foreach (var i in LoginManagerClient.GetCharacter().Equipment) { float f = GetWidth(); if (count % 5 == 0) { Row(); } if (i != null && i.GetSprite() == null) { i.SetSprite(TextureContainer.GetSpriteAtlasByName("Items").GetSprite(i.TextureName)); } if (i != null) { SpriteDrawable spd = new SpriteDrawable(i.GetSprite()); NinePatchDrawable ninePatchDrawable = new NinePatchDrawable(i.GetSprite(), 0, 0, 0, 0) { MinHeight = 48, MinWidth = 48 }; ItemButton imButton = new ItemButton(ninePatchDrawable, count, i); imButton.SetTouchable(Touchable.Enabled); imButton.OnHovered += delegate { OnHovered(imButton, i, skin, stage); }; imButton.OnExited += delegate { OnExit(imButton, stage); }; imButton.OnMoved += delegate { OnMovedAndHovered(imButton); }; imButton.OnClicked += delegate { OnClickedCharacter(imButton); }; Add(imButton).Size(48, 48).Pad(4).Expand(); } else { ItemButton imButton = new ItemButton(textButtonStyle, count, null); imButton.Add(new Label("")).Expand().Left().SetAlign(Nez.UI.Align.BottomLeft); imButton.SetTouchable(Touchable.Disabled); Add(imButton).Size(48, 48).Pad(4).Expand(); } count++; } }
public PlayerEntity(CharacterPlayer player) { this.player = player; TextComponent textComponent = new TextComponent(Graphics.Instance.BitmapFont, player._name, Vector2.Zero, Color.White); HealthtextComponent = new TextComponent(Graphics.Instance.BitmapFont, player.CurrentHealth.ToString(), Vector2.Zero, Color.White); SetTag(2); this.SetPosition(player.physicalPosition); AddComponent(textComponent).SetHorizontalAlign(HorizontalAlign.Center).SetVerticalAlign(VerticalAlign.Top).SetRenderLayer(-200); AddComponent(new PlayerComponent()); AddComponent(HealthtextComponent).SetHorizontalAlign(HorizontalAlign.Right).SetVerticalAlign(VerticalAlign.Bottom).SetRenderLayer(-200); SpriteAnimation Idle = TextureContainer.GetSpriteAtlasByName("Knight").GetAnimation("Idle"); SpriteAnimation Movement = TextureContainer.GetSpriteAtlasByName("Knight").GetAnimation("Movement"); SpriteAnimator ani = textComponent.AddComponent <SpriteAnimator>(); ani.AddAnimation("Idle", Idle); ani.AddAnimation("Movement", Movement); ani.Play("Idle"); this.SetScale(3.5f); }
public override void Initialize() { base.Initialize(); //Load Assets, always load textures before generating items so they can match texture and ID TextureContainer.LoadTextures(); AbilityContainerClient.LoadAbilities(); KeyBindContainer.SetKeyBinds(); Entity e = CreateEntity("Wallpaper"); e.AddComponent(new SpriteRenderer(TextureContainer.LoginWallpaper)).SetOrigin(new Vector2(0, 0)); float h = (float)Screen.Height / (float)TextureContainer.LoginWallpaper.Height; float w = (float)Screen.Width / (float)TextureContainer.LoginWallpaper.Width; e.SetScale(new Vector2(w, h)); Sprite textfieldTexture = TextureContainer.GetSpriteAtlasByName("UI").GetSprite("Plank_03"); TextFieldStyle textFields = TextFieldStyle.Create(Color.White, Color.White, Color.Black, Color.DarkGray); NinePatchDrawable drawable = new NinePatchDrawable(textfieldTexture, 0, 0, 0, 0) { MinHeight = 20, MinWidth = 50 }; NinePatchDrawable drawablebutton = new NinePatchDrawable(TextureContainer.GetSpriteAtlasByName("UI").GetSprite("plank_15"), 0, 0, 0, 0) { MinHeight = 20, MinWidth = 50 }; NinePatchDrawable drawablehover = new NinePatchDrawable(TextureContainer.GetSpriteAtlasByName("UI").GetSprite("plank_18"), 0, 0, 0, 0) { MinHeight = 20, MinWidth = 50 }; textFields.Background = drawable; Label label = new Label("Menu").SetFontScale(5).SetFontColor(Color.MediumVioletRed); Table.Add(label); Label user = new Label("Username").SetFontScale(2).SetFontColor(Color.MediumVioletRed); Table.Row().SetPadTop(10); Table.Add(user).Pad(20); textFieldu = new TextField("", textFields); Table.Row().SetPadTop(10); Table.Add(textFieldu); Label pass = new Label("Password").SetFontScale(2).SetFontColor(Color.MediumVioletRed); Table.Row().SetPadTop(10); Table.Add(pass); textFieldp = new TextField("", textFields); Table.Row().SetPadTop(10); textFieldp.SetPasswordMode(true); Table.Add(textFieldp); TextButtonStyle textButtonStyle = new TextButtonStyle(drawablebutton, drawablehover, drawablehover); TextButton button = new TextButton("Login", textButtonStyle); button.Pad(10); button.PadLeft(20); button.PadRight(20); button.OnClicked += SendLogin; Table.Row().SetPadTop(10); Table.Add(button); TextButton buttonr = new TextButton("Register", textButtonStyle); buttonr.Pad(10); buttonr.PadLeft(20); buttonr.PadRight(20); buttonr.OnClicked += Sendregister; Table.Row().SetPadTop(10); Table.Add(buttonr); //var imGuiManager = new ImGuiManager(); //Core.RegisterGlobalManager(imGuiManager); //imGuiManager.SetEnabled(false); //imGuiManager.ShowDemoWindow = true; }