示例#1
0
 public CharactStats(SerializationInfo info, StreamingContext context)
 {
     HP = (Int32)info.GetValue("HP", typeof(Int32));
     MP = (Int32)info.GetValue("MP", typeof(Int32));
     STR = (Int32)info.GetValue("STR", typeof(Int32));
     DEF = (Int32)info.GetValue("DEF", typeof(Int32));
     INT = info.GetInt32("INT");
     RES = info.GetInt32("RES");
     PrimaryElement = (Elemental)info.GetValue("PrimaryElement", typeof(Elemental));
     WeaknessElement = (Elemental)info.GetValue("WeaknessElement", typeof(Elemental));
     EXP = (Int32)info.GetValue("EXP", typeof(Int32));
     MONEY = (Int32)info.GetValue("MONEY", typeof(Int32));
 }
        public Color AssignColor(Elemental Elem)
        {
            Image Conversion;

            using (XNAUtils utils = new XNAUtils())
            {
                Conversion = utils.ConvertToImage(Elem.Icon.GetImage());
            }

            Bitmap Image = new Bitmap(Conversion);
            Color PixelColor = Image.GetPixel(Image.Width / 2, Image.Height / 2);

            //if (PixelColor.IsNearBlack(25))
            //    PixelColor = Color.FromArgb(50, 50, 50);
            //else if (PixelColor.IsNearWhite(25))
            //    PixelColor = Color.FromArgb(205, 205, 205);

            return PixelColor;
        }
        private void BTN_SaveElement_Click(object sender, EventArgs e)
        {
            using (XNAUtils utils = new XNAUtils())
            {
                if (linkLBL_ELEM_Name.Text == LIST_Elements.SelectedItem.ToString() || !ContainsSameName(LIST_Elements, linkLBL_ELEM_Name.Text))
                {
                    pIcon icon = new pIcon(utils.ConvertToTexture(PN_IconElement.BackgroundImage), linkLBL_ELEM_Name.Text);
                    Elemental elem = new Elemental(linkLBL_ELEM_Name.Text, icon);

                    elem.Immunities = new List<Elemental>();
                    elem.Resistances = new List<Elemental>();
                    elem.Weaknesses = new List<Elemental>();

                    elem.Immunities = ES_Immunites.UpdateList();
                    elem.Resistances = ES_Resistances.UpdateList();
                    elem.Weaknesses = ES_Faiblesses.UpdateList();

                    elem.SetDescription(TB_Description.Text);

                    LIST_Elements.Items[LIST_Elements.SelectedIndex] = elem;
                }

                else
                    GenerateSaveWarningBox("élément", linkLBL_ELEM_Name.Text);

                ES_Faiblesses.Init(LIST_Elements, linkLBL_ELEM_Name.Text);
                ES_Resistances.Init(LIST_Elements, linkLBL_ELEM_Name.Text);
                ES_Immunites.Init(LIST_Elements, linkLBL_ELEM_Name.Text);
            }
        }
        public void ButtonClicked(Object sender, EventArgs e)
        {
            Elemental pElement = new Elemental((((Control)sender).Name));
            Boolean Fini = false;

            foreach (Button button in ElementButtons)
                if (button.Name == pElement.GetName())
                {
                    switch (this.Type)
                    {
                        case SelectorType.Immunities:
                            if ((Boolean)button.Tag == false)
                            {
                                button.Tag = true;
                                button.BackColor = button.FlatAppearance.BorderColor;

                                for (int i = 0; i < ElementsContenus.Count && !Fini; i++)
                                {
                                    if (CurrentElement.GetName() == ElementsContenus.ElementAt(i).GetName())
                                    {
                                        if (ElementsContenus.ElementAt(i).Immunities == null)
                                            ElementsContenus.ElementAt(i).Immunities = new List<Elemental>();
                                        ElementsContenus.ElementAt(i).Immunities.Add(pElement);
                                        Fini = true;
                                    }
                                }
                            }

                            else
                            {
                                button.Tag = false;
                                button.BackColor = Button.DefaultBackColor;

                                for (int i = 0; i < ElementsContenus.Count && !Fini; i++)
                                {
                                    if (CurrentElement.GetName() == ElementsContenus.ElementAt(i).GetName())
                                    {
                                        ElementsContenus.ElementAt(i).Immunities.Remove(pElement);
                                        Fini = true;
                                    }
                                }
                            }
                            break;

                        case SelectorType.Weaknesses:
                            if ((Boolean)button.Tag == false)
                            {
                                button.Tag = true;
                                button.BackColor = button.FlatAppearance.BorderColor;

                                for (int i = 0; i < ElementsContenus.Count && !Fini; i++)
                                {
                                    if (CurrentElement.GetName() == ElementsContenus.ElementAt(i).GetName())
                                    {
                                        if (ElementsContenus.ElementAt(i).Weaknesses == null)
                                            ElementsContenus.ElementAt(i).Weaknesses = new List<Elemental>();
                                        ElementsContenus.ElementAt(i).Weaknesses.Add(pElement);
                                        Fini = true;
                                    }
                                }
                            }

                            else
                            {
                                button.Tag = false;
                                button.BackColor = Button.DefaultBackColor;

                                for (int i = 0; i < ElementsContenus.Count && !Fini; i++)
                                {
                                    if (CurrentElement.GetName() == ElementsContenus.ElementAt(i).GetName())
                                    {
                                        ElementsContenus.ElementAt(i).Weaknesses.Remove(pElement);
                                        Fini = true;
                                    }
                                }
                            }
                            break;

                        case SelectorType.Resistances:
                            if ((Boolean)button.Tag == false)
                            {
                                button.Tag = true;
                                button.BackColor = button.FlatAppearance.BorderColor;

                                for (int i = 0; i < ElementsContenus.Count && !Fini; i++)
                                {
                                    if (CurrentElement.GetName() == ElementsContenus.ElementAt(i).GetName())
                                    {
                                        if (ElementsContenus.ElementAt(i).Resistances == null)
                                            ElementsContenus.ElementAt(i).Resistances = new List<Elemental>();
                                        ElementsContenus.ElementAt(i).Resistances.Add(pElement);
                                        Fini = true;
                                    }
                                }
                            }

                            else
                            {
                                button.Tag = false;
                                button.BackColor = Button.DefaultBackColor;

                                for (int i = 0; i < ElementsContenus.Count && !Fini; i++)
                                {
                                    if (CurrentElement.GetName() == ElementsContenus.ElementAt(i).GetName())
                                    {
                                        ElementsContenus.ElementAt(i).Resistances.Remove(pElement);
                                        Fini = true;
                                    }
                                }
                            }
                            break;
                    }
                }
        }