示例#1
0
        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;
            }
        }
 public void ReactToUpdateUiChangeEvent(object sender, UpdateUiEventArgs args)
 {
     this.MenuTitleDisplayText = args.TitleDisplay;
     this.ResourceCostContainer.UpadteResourceDisplayText(args);
 }