public IndexedValueInfosView(IndexedValueView value)
        {
            InitializeComponent();
            Value = value;

            // Labels initialisation
            ValueNameLabel.Text        = value.Value.Name;
            ValueDescriptionLabel.Text = value.Value.Description;
            ActualValueLabel.Text      = "Valeur actuelle : " + value.Value.Value;
            MinValueLabel.Text         = "Valeur minimale : " + value.Value.MinValue;
            MaxValueLabel.Text         = "Valeur maximale : " + value.Value.MaxValue;

            if (value.Value.MoneyAmount.HasValue && value.Value.MoneyAmount.GetValueOrDefault(0) < 0)
            {
                MoneyImpactLabel.Text = "Coûte " + value.Value.MoneyImpacted + " pièces d'or par tour.";
            }
            else if (value.Value.MoneyAmount.HasValue && value.Value.MoneyAmount.GetValueOrDefault(0) > 0)
            {
                MoneyImpactLabel.Text = "Rapporte " + value.Value.MoneyImpacted + " pièces d'or par tour.";
            }

            if (value.Value.GloryAmount.HasValue && value.Value.GloryAmount.GetValueOrDefault(0) < 0)
            {
                GloryImpactedLabel.Text = "Coûte " + Math.Abs(value.Value.GloryAmount.Value) + " gloire.";
            }
            else if (value.Value.GloryAmount.HasValue && value.Value.GloryAmount.GetValueOrDefault(0) > 0)
            {
                GloryImpactedLabel.Text = "Rapporte " + value.Value.GloryImpacted + " gloire par tour.";
            }

            ValueActiveLabel.Text = "Actuellement " + ((value.Value.Active == true) ? "en action." : "hors action.");
        }
Example #2
0
        /// <summary>
        /// Create a window that will change the value of the given policy
        /// </summary>
        /// <param name="policy">the policy</param>
        public ChangePolicyView(IndexedValueView policy, int worldGold, int worldGlory)
        {
            InitializeComponent();
            Value      = policy;
            WorldGold  = worldGold;
            WorldGlory = worldGlory;
            InitialiseLabels();

            // Value changer and progress bar initialisation
            ValueChanger.Maximum = ProgressBar.Maximum = Value.Value.MaxValue;
            ValueChanger.Minimum = ProgressBar.Minimum = Value.Value.MinValue;
            ValueChanger.Value   = ProgressBar.Value = ChosenValue = Value.Value.Value;
        }
Example #3
0
        /// <summary>
        /// Create the link lines corresponding to the link values from the given value.
        /// </summary>
        /// <param name="value">the value to create the link lines from</param>
        /// <returns>A list containing all the link lines ready to be displayed</returns>
        private List <LinkLine> GetLinkLines(IndexedValueView value)
        {
            List <LinkLine> linkedLines = new List <LinkLine>();

            foreach (KeyValuePair <IndexedValue, double> link in value.Value.OutputWeights)
            {
                IndexedValueView linkedValueView = ValueViews.Find(v => v.Value == link.Key);
                linkedLines.Add(new LinkLine(value.GetCenter(), linkedValueView.GetCenter(),
                                             GetLineColor(link.Value),
                                             GetLineThickness(link.Value)));
            }

            return(linkedLines);
        }
Example #4
0
        /// <summary>
        /// The constructor for the main window. Initialise the value views.
        /// </summary>
        public GameView(WorldState world)
        {
            InitializeComponent();
            theWorld = world;

            InitialiseContainers();

            // Initialisation of the values
            ValueViews = new List <IndexedValueView>();
            BuildAllIndexedValues();
            ConsulteValueViews = ValueViews.FindAll(valueView => valueView.Container != PoliciesBox);
            Policies           = ValueViews.FindAll(valueView => valueView.Container == PoliciesBox);
            HoveredValue       = null;
        }
Example #5
0
        private void GameView_MouseDown(object sender, MouseEventArgs e)
        {
            IndexedValueView valueClicked =
                ValueViews.FirstOrDefault(value => value.Contains(e.Location));

            if (valueClicked != null)
            {
                if (valueClicked.Container == PoliciesBox)
                {
                    DisplayPoliciesInfos(valueClicked);
                }
                else
                {
                    DisplayValueInfos(valueClicked);
                }
            }
        }
Example #6
0
 /// <summary>
 /// Display the change policy view or a dialog box saying when the policy will be available.
 /// </summary>
 /// <param name="valueView">The policy</param>
 private void DisplayPoliciesInfos(IndexedValueView valueView)
 {
     if (IsPolicyAvailable(valueView.Value))
     {
         ChangePolicyView changePolicyView = new ChangePolicyView(valueView, theWorld.Money, theWorld.Glory);
         changePolicyView.ShowDialog();
         if (valueView.Value.Value != changePolicyView.ChosenValue)
         {
             GameController.ApplyPolicyChanges(valueView.Value.Name + " " + changePolicyView.ChosenValue);
             valueView.ValueHistory.Add(new KeyValuePair <int, int>(theWorld.Turns + 1, changePolicyView.ChosenValue));
         }
     }
     else
     {
         MessageBox.Show("Cette politique sera disponible au tour "
                         + (valueView.Value.AvailableAt + 1).ToString()
                         + ".", "Politique non disponible");
     }
 }
Example #7
0
        /// <summary>
        /// Select or unselect the hovered value and its link depending on the mouse position
        /// </summary>
        private void GameView_MouseMove(object sender, MouseEventArgs e)
        {
            if (ValueViews.FirstOrDefault(value => value.Contains(e.Location)) != null)
            {
                HoveredValue = ValueViews.FirstOrDefault(value => value.Contains(e.Location));
                foreach (IndexedValueView value in ValueViews)
                {
                    if (!HoveredValue.Value.OutputWeights.ContainsKey(value.Value) &&
                        value != HoveredValue)
                    {
                        value.Opacity   = 25;
                        value.BackColor = Color.FromArgb(0, value.BackColor);
                    }
                    else
                    {
                        value.Opacity   = 255;
                        value.BackColor = Color.FromArgb(255, value.BackColor);
                    }
                }
                Refresh();
            }

            // If no value is selected, then stop the link display
            else if (HoveredValue != null)
            {
                HoveredValue = null;
                foreach (IndexedValueView value in ValueViews)
                {
                    if (value.Opacity != 255)
                    {
                        value.Opacity   = 255;
                        value.BackColor = Color.FromArgb(255, value.BackColor);
                    }
                }
                Refresh();
            }
        }
Example #8
0
 /// <summary>
 /// Display the indexed value infos view of the given value.
 /// </summary>
 /// <param name="valueView">The value to display its informations</param>
 private void DisplayValueInfos(IndexedValueView valueView) => new IndexedValueInfosView(valueView).ShowDialog();