public void UpadteResourceDisplayText(UpdateUiEventArgs args) { m_LastUpdatedData = args.SelectedData; this.GoldCostText = $"{args.GoldCost}"; this.LumberCostText = $"{args.LumberCost}"; this.StoneCostText = $"{args.StoneCost}"; this.CapacityCostText = $"{args.CapacityCost}"; //ChangeColor based on affordability. if (args.ShouldCheckAffordability) { var gameScreen = ScreenManager.CurrentScreen as Screens.GameScreen; GoldTextColorState = gameScreen.Gold >= args.GoldCost ? ResourceCostDisplayRuntime.TextColor.CanAfford : ResourceCostDisplayRuntime.TextColor.CannotAfford; LumberTextColorState = gameScreen.Lumber >= args.LumberCost ? ResourceCostDisplayRuntime.TextColor.CanAfford : ResourceCostDisplayRuntime.TextColor.CannotAfford; StoneTextColorState = gameScreen.Stone >= args.StoneCost ? ResourceCostDisplayRuntime.TextColor.CanAfford : ResourceCostDisplayRuntime.TextColor.CannotAfford; CapacityTextColorState = gameScreen.MaxCapacity >= gameScreen.CurrentCapacityUsed + args.CapacityCost || gameScreen.HasTrainingUnits ? ResourceCostDisplayRuntime.TextColor.CanAfford : ResourceCostDisplayRuntime.TextColor.CannotAfford; } else { GoldTextColorState = ResourceCostDisplayRuntime.TextColor.CanAfford; LumberTextColorState = ResourceCostDisplayRuntime.TextColor.CanAfford; StoneTextColorState = ResourceCostDisplayRuntime.TextColor.CanAfford; CapacityTextColorState = ResourceCostDisplayRuntime.TextColor.CanAfford; } }
private IconButtonRuntime CreateNewIconButtonWithOffset(int stackIndex, ICommonEntityData data, IUpdatesStatus selectedEntity = null) { IconButtonRuntime button = new IconButtonRuntime(); button.Parent = this; IconButtonList.Add(button); button.EntityCreatedFrom = selectedEntity; button.HotkeyData = data; button.X = stackIndex % 3 != 0 ? PixelsBetweenButtons : 0; button.Y = stackIndex > 2 && stackIndex % 3 == 0 ? PixelsBetweenButtons : 0; button.RollOn += (notused) => { UpdateUIDisplay?.Invoke(this, new UpdateUiEventArgs(data)); }; button.RollOff += (notused) => { //If we will default to the build menu if an entity is not selected when adding toggle buttons. var args = selectedEntity == null ? UpdateUiEventArgs.RollOffValue : new UpdateUiEventArgs() { TitleDisplay = selectedEntity.EntityData.MenuTitleDisplay }; UpdateUIDisplay?.Invoke(this, args); }; return(button); }
public UpdateUiEventArgs(ICommonEntityData dataToSetFrom) { SelectedData = dataToSetFrom; TitleDisplay = dataToSetFrom.MenuTitleDisplay; GoldCost = dataToSetFrom.Gold; LumberCost = dataToSetFrom.Lumber; StoneCost = dataToSetFrom.Stone; CapacityCost = dataToSetFrom.CapacityUsed; ShouldCheckAffordability = true; }