Exemple #1
0
        public void GetUnitCanvasContent(Unit Unit, out Label HealthPoints, out Label RangeLeft, out Label RangeUsed, out Image UnitIcon)
        {
            HealthPoints = new Label();
            HealthPoints.Name = "Label_HealthPoints";
            HealthPoints.Content = Unit.Health.ToString();
            HealthPoints.Margin = new Thickness(FieldSize - 17, FieldSize - 17, 1, 1);
            HealthPoints.Padding = new Thickness(0);
            HealthPoints.FontSize = 12;
            HealthPoints.FontWeight = FontWeights.Bold;
            HealthPoints.Width = 16;
            HealthPoints.Height = 16;
            HealthPoints.Foreground = new SolidColorBrush(Colors.White);
            HealthPoints.Background = new SolidColorBrush(Colors.Black);
            HealthPoints.HorizontalContentAlignment = HorizontalAlignment.Center;
            HealthPoints.VerticalContentAlignment = VerticalAlignment.Center;

            // range left
            double RangeLeftPercentage = (double)Unit.Range / Unit.GetDefaultRange();
            int MaxWidth = FieldSize - 16 - 2;
            RangeLeft = new Label();
            RangeLeft.Margin = new Thickness(MaxWidth - RangeLeftPercentage * MaxWidth + 1, FieldSize - 4 - 1, 17, 1);
            RangeLeft.Height = 4;
            RangeLeft.Width = RangeLeftPercentage * MaxWidth;
            RangeLeft.Background = new SolidColorBrush((Unit.Fraction == GameControl.Game.Turn) ? Colors.DarkGreen : Colors.DarkRed);

            RangeUsed = new Label();
            RangeUsed.Margin = new Thickness(1, FieldSize - 4 - 1, MaxWidth - RangeLeftPercentage * MaxWidth + 1 + 16, 1);
            RangeUsed.Height = 4;
            RangeUsed.Width = MaxWidth - RangeLeftPercentage * MaxWidth;
            RangeUsed.Background = new SolidColorBrush(Colors.Gray);

            // image
            UnitIcon = new Image();
            UnitIcon.Name = "Image_UnitIcon";
            UnitIcon.Width = FieldSize;
            UnitIcon.Height = FieldSize;

            UnitIcon.Source = new BitmapImage(new Uri("Resources/Units58/" + ((Unit.Fraction == Fraction.Saracens) ? "S" : "C") + "_" + Unit.GetName() + ".png", UriKind.Relative));
            UnitIcon.Stretch = Stretch.Uniform;
        }
Exemple #2
0
        // display info of a unit
        public void DisplayClickedFieldInfo(Unit Unit)
        {
            HideClickedFieldInfo();

            if (Unit == null) return;
            this.ShownUnit = Unit;

            Label_Info_Name.Content = R.String(Unit.GetName());
            Label_Info_Type.Visibility = Visibility.Visible;
            Label_Info_Type.Content = Unit.UnitClassToString(Unit.GetClass());

            Image_Info_Unit.Source = new BitmapImage(new Uri("Resources/Units/" + ((Unit.Fraction == Fraction.Saracens) ? "S" : "C") + "_" + Unit.GetName() + ".png", UriKind.Relative)); ;

            ListBox_Info_GeneralInformation_Description.Visibility = Visibility.Visible;
            StackPanel_UnitInfoIcons.Visibility = Visibility.Visible;

            ListBox_Info_GeneralInformation_Value.Items.Add(Unit.Health.ToString() + " / " + Unit.GetMaxHealth().ToString());
            ListBox_Info_GeneralInformation_Value.Items.Add(Unit.Ammunition.ToString().Replace("-1", "++") + " / " + Unit.GetMaxAmmunition().ToString().Replace("-1", "++"));
            ListBox_Info_GeneralInformation_Value.Items.Add(Unit.Food.ToString().Replace("-1", "++") + " / " + Unit.GetMaxFood().ToString().Replace("-1", "++"));
            ListBox_Info_GeneralInformation_Value.Items.Add(Unit.Range.ToString() + " / " + Unit.GetDefaultRange().ToString());
            ListBox_Info_GeneralInformation_Value.Items.Add(Unit.GetInitiative().ToString());
            ListBox_Info_GeneralInformation_Value.Items.Add(Unit.GetFiringRange().ToString());
            ListBox_Info_GeneralInformation_Value.Items.Add(Unit.GetPrice().ToString());

            ShowUnitTypeInformationPopup(Unit);
        }