// CONSTRUCTORS public MenuGO() { this.background = new EntitySprite(new Sprite("gobackground", 4, false)); this.scorePanel = new EntitySprite(new Sprite("scorePanel", 3, false)); this.scorePanel.ESprite.X = Misc.WindowWidth / 2 - this.scorePanel.ESprite.Width / 2; this.scorePanel.ESprite.Y = 90; this.homeButton = new EntityButton("HOME"); this.homeButton.ESprite.X = Misc.WindowWidth / 2 - this.homeButton.ESprite.Width / 2; this.homeButton.ESprite.Y = Misc.WindowHeight / 2 + this.homeButton.ESprite.Height * 2; this.grayBarrelNumber = new Text("x" + Misc.grayBarrelGet, "ButtonFont", this.scorePanel.ESprite.X + 17 * 3, this.scorePanel.ESprite.Y + 21 * 3); this.grayBarrelNumber.TextColor = Color.DarkGray; this.blueBBarrelNumber = new Text("x" + Misc.blueBarrelGet, "ButtonFont", this.scorePanel.ESprite.X + 55 * 3, this.scorePanel.ESprite.Y + 21 * 3); this.blueBBarrelNumber.TextColor = Color.DarkBlue; this.redBarrelNumber = new Text("x" + Misc.redBarrelGet, "ButtonFont", this.scorePanel.ESprite.X + 93 * 3, this.scorePanel.ESprite.Y + 21 * 3); this.redBarrelNumber.TextColor = Color.DarkRed; this.questionBarrelNumber = new Text("x" + Misc.questionBarrelGet, "ButtonFont", this.scorePanel.ESprite.X + 131 * 3, this.scorePanel.ESprite.Y + 21 * 3); this.t1 = new Text("TIME :", "ButtonFont", this.scorePanel.ESprite.X + 176 * 3, this.scorePanel.ESprite.Y + 6 * 3); this.t2 = new Text(Misc.playTimer, "ButtonFont", this.scorePanel.ESprite.X + 175 * 3, this.scorePanel.ESprite.Y + 21 * 3); this.t1.TextColor = Color.DarkGreen; this.t2.TextColor = Color.LightGray; this.youDied = new Text("YOU DIDN'T HAVE ENOUGH POWER TO SURVIVE!", "timerFont", Misc.WindowWidth / 2, Misc.WindowHeight / 2); this.youDied.TextColor = Color.Red; this.stats = new Text("YOUR STATS", "ButtonFont", Misc.WindowWidth / 2, Misc.WindowHeight / 2 - 75); this.stats.TextColor = Color.Yellow; }
private Button MakeButton(int x, string line) { string[] type = line.Split(','); if (type.Length < 3) { return(null); } string asset = type[0]; int boundingy = int.Parse(type[1]); EntityType et = (EntityType)Enum.Parse(typeof(EntityType), type[2]); EntityButton button = new EntityButton(asset, boundingy, et); if (et == EntityType.Enemy) { button.EnemyType = (EnemyType)Enum.Parse(typeof(EnemyType), type[3]); } else if (et == EntityType.AnimatedItem || et == EntityType.SpriteItem) { button.ItemType = (ItemType)Enum.Parse(typeof(ItemType), type[3]); } button.Position = new Vector2(x, 230); button.Origin += new Vector2(0, button.Height); Add(button); return(button); }
// CONSTRUCTORS public MenuHome() { this.head1 = new EntityAnimatedSprite(new AnimatedSprite("playerHead", 1, 1, 10, 1f, 1f)); this.head1.ESprite.Origin = new Vector2(this.head1.ESprite.Width / 20, this.head1.ESprite.Height / 20); this.head1.ESprite.X = 0; this.head1.ESprite.Y = Misc.WindowHeight; this.head2 = new EntityAnimatedSprite(new AnimatedSprite("playerHead", 1, 1, 10, 1f, 1f)); this.head2.ESprite.Origin = new Vector2(this.head2.ESprite.Width / 20, this.head2.ESprite.Height / 20); this.head2.ESprite.X = Misc.WindowWidth; this.head2.ESprite.Y = Misc.WindowHeight; this.background = new EntitySprite(new Sprite("home_background", 4, false)); this.title = new EntitySprite(new Sprite("title", 2, true)); this.title.ESprite.X = Misc.WindowWidth / 2 - this.title.ESprite.Width / 2; this.title.ESprite.Y = Misc.WindowHeight / 2 - this.title.ESprite.Height * 2 - this.title.ESprite.Height / 2; this.startButton = new EntityButton("PLAY"); this.startButton.ESprite.X = Misc.WindowWidth / 2 - this.startButton.ESprite.Width / 2; this.startButton.ESprite.Y = Misc.WindowHeight / 2 - this.startButton.ESprite.Height / 2; this.quitButton = new EntityButton("QUIT"); this.quitButton.ESprite.X = Misc.WindowWidth / 2 - this.quitButton.ESprite.Width / 2; this.quitButton.ESprite.Y = Misc.WindowHeight / 2 + this.quitButton.ESprite.Width / 2; this.madeFor = new Text("Made by MatKubik for Ludum Dare 39", "ButtonFont", Misc.WindowWidth / 2, Misc.WindowHeight - 25); this.madeFor.TextColor = Color.Orange; }
/// <summary> /// Loops through stored entities creating buttons for each, updates information labels /// </summary> public void BuildEntityList() { EntityList.DisposeAllChildren(); var storagelist = StorageEntity.StoredEntities; foreach (var entityuid in storagelist) { var entity = IoCManager.Resolve <IEntityManager>().GetEntity(entityuid.Key); var button = new EntityButton() { EntityuID = entityuid.Key }; var container = button.GetChild("HBoxContainer"); button.ActualButton.OnToggled += OnItemButtonToggled; //Name and Size labels set container.GetChild <Label>("Name").Text = entity.Name; container.GetChild <Control>("Control").GetChild <Label>("Size").Text = string.Format("{0}", entityuid.Value); //Gets entity sprite and assigns it to button texture if (entity.TryGetComponent(out IconComponent icon)) { var tex = icon.Icon.Default; var rect = container.GetChild("TextureWrap").GetChild <TextureRect>("TextureRect"); if (tex != null) { rect.Texture = tex; // Copypasted but replaced with 32 dunno if good var scale = (float)32 / tex.Height; rect.Scale = new Vector2(scale, scale); } else { rect.Dispose(); } } EntityList.AddChild(button); } //Sets information about entire storage container current capacity if (StorageEntity.StorageCapacityMax != 0) { Information.Text = String.Format("Items: {0}, Stored: {1}/{2}", storagelist.Count, StorageEntity.StorageSizeUsed, StorageEntity.StorageCapacityMax); } else { Information.Text = String.Format("Items: {0}", storagelist.Count); } }
/// <summary> /// Loops through stored entities creating buttons for each, updates information labels /// </summary> public void BuildEntityList() { _entityList.DisposeAllChildren(); var storageList = StorageEntity.StoredEntities; var storedGrouped = storageList.GroupBy(e => e).Select(e => new { Entity = e.Key, Amount = e.Count() }); foreach (var group in storedGrouped) { var entity = group.Entity; var button = new EntityButton() { EntityUid = entity.Uid, MouseFilter = MouseFilterMode.Stop, }; button.ActualButton.OnToggled += OnItemButtonToggled; //Name and Size labels set button.EntityName.Text = entity.Name; button.EntitySize.Text = group.Amount.ToString(); //Gets entity sprite and assigns it to button texture if (entity.TryGetComponent(out ISpriteComponent sprite)) { button.EntitySpriteView.Sprite = sprite; } _entityList.AddChild(button); } //Sets information about entire storage container current capacity if (StorageEntity.StorageCapacityMax != 0) { _information.Text = String.Format("Items: {0}, Stored: {1}/{2}", storageList.Count, StorageEntity.StorageSizeUsed, StorageEntity.StorageCapacityMax); } else { _information.Text = String.Format("Items: {0}", storageList.Count); } }
protected override void UpdateSelf() { Player plr = GameLoop.MyPlayer; EntityButton.UpdateText($"{plr.SelectedEntityType}"); TileButton.UpdateText($"{(TileType)plr.SelectedTile}"); rightTile.SetPosition(new Vector2(34 + TileButton.ScaledWidth, 60)); rightEntity.SetPosition(new Vector2(34 + EntityButton.ScaledWidth, 10)); if (!plr.HasActions) { actionText.SetText($"{plr.Findtile(InputManager.MouseScreenPosition).SubTiles[0, 0]}" + $"{plr.Findtile(InputManager.MouseScreenPosition).SubTiles[0, 1]}" + $"{plr.Findtile(InputManager.MouseScreenPosition).SubTiles[1, 0]}" + $"{plr.Findtile(InputManager.MouseScreenPosition).SubTiles[1, 1]}"); } }
/// <summary> /// Loops through stored entities creating buttons for each, updates information labels /// </summary> public void BuildEntityList() { EntityList.DisposeAllChildren(); var storagelist = StorageEntity.StoredEntities; foreach (var entityuid in storagelist) { var entity = IoCManager.Resolve <IEntityManager>().GetEntity(entityuid.Key); var button = new EntityButton() { EntityuID = entityuid.Key, MouseFilter = MouseFilterMode.Stop, }; button.ActualButton.OnToggled += OnItemButtonToggled; //Name and Size labels set button.EntityName.Text = entity.Name; button.EntitySize.Text = string.Format("{0}", entityuid.Value); //Gets entity sprite and assigns it to button texture if (entity.TryGetComponent(out ISpriteComponent sprite)) { button.EntitySpriteView.Sprite = sprite; } EntityList.AddChild(button); } //Sets information about entire storage container current capacity if (StorageEntity.StorageCapacityMax != 0) { Information.Text = String.Format("Items: {0}, Stored: {1}/{2}", storagelist.Count, StorageEntity.StorageSizeUsed, StorageEntity.StorageCapacityMax); } else { Information.Text = String.Format("Items: {0}", storagelist.Count); } }
// CONSTRUCTORS public ButtonEvent(EntityButton button) { this.button = button; }