Beispiel #1
0
 public MilleniumGoalsSet CompleteResearch(Research r, int year)
 {
     foreach (Research re in researchList)
     {
         if (re == r)
         {
             return(re.CompleteResearch(year));
         }
     }
     return(null);
 }
        public ResearchPanel(Game game)
            : base(game)
        {
            selectedResearch = null;
            selectedMG = ConstructionType.None;

            timeline = new Sprite(game, GraphicsCollection.GetPack("control-research-timeline"));
            timeline.XRelative = 91;
            timeline.YRelative = 197;
            AddChild(timeline);

            ok = new ControlPanelButton(game, ControlPanelButtonType.ResearchOK);
            ok.XRelative = 413;
            ok.YRelative = 64;
            ok.IsVisible = false;
            ok.Enabled = false;
            ok.OnPress += new EventHandler<ButtonEventArgs>(ok_OnPress);
            AddChild(ok);

            name = new SpriteText(game, FontsCollection.GetPack("Calibri 11").Font);
            name.Tint = Color.White;
            name.XRelative = 101;
            name.YRelative = 64;
            AddChild(name);

            description = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font);
            description.Tint = Color.White;
            description.XRelative = 101;
            description.YRelative = 82;
            AddChild(description);

            price = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font);
            price.Tint = Color.Lime;
            price.XRelative = 101;
            price.YRelative = 178;
            AddChild(price);

            year = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font);
            year.Tint = Color.Lime;
            year.XRelative = 347;
            year.YRelative = 178;
            AddChild(year);

            icons = new List<ControlPanelButton>();
        }
 public void CompleteResearch(Research r)
 {
     researchHistory.CompleteResearch(r,CurrentYear);
     SpendMoney(CurrentYear, r.Cost);
     GUI.SetMoney(GetMoney(CurrentYear));
     GameMap.ChangesMade = true;
 }
Beispiel #4
0
 public void AddResearchToList(Research r)
 {
     researchList.Add(r);
 }
Beispiel #5
0
 public void CancelResearch(Research r)
 {
     r.CancelResearch();
 }
 private void Refresh(Research research)
 {
     name.Text = research.Name;
     description.Text = research.Description;
     description.SplitTextToRows(RightPositioningLimit-LeftPositioningLimit);
     if (research.Completed == false || (research.Completed && research.YearCompleted > GameManager.CurrentYear))
     {
         price.Text = "$" + research.Cost.ToString();
         if (research.Cost <= GameManager.GetMoney(GameManager.CurrentYear))
         {
             ok.IsVisible = this.IsVisible;
             ok.Enabled = true;
         }
     }
     else
     {
         price.Text = "Researched: "+research.YearCompleted.ToString();
         ok.IsVisible = false;
         ok.Enabled = false;
     }
     year.Text = "Available: " + research.YearAvailable.ToString();
     selectedResearch = research;
 }
Beispiel #7
0
        public List<Research> LoadResearchList(string profilePath)
        {
            List<Research> researchList = new List<Research>();

            xmlLoader = XElement.Load(profilePath + "\\" + ResearchFile);
            IEnumerable<XElement> researchListData = from element in xmlLoader.Elements() select element;

            Research currentResearch = null;

            foreach (XElement researchElement in researchListData)
            {
                currentResearch = new Research();
                currentResearch.YearAvailable = Convert.ToInt32(researchElement.Element("year").Value);
                currentResearch.YearCompleted = Convert.ToInt32(researchElement.Element("completionYear").Value);
                currentResearch.ResearchType = (ConstructionType)Enum.Parse(typeof(ConstructionType),researchElement.Element("ResearchType").Value);
                currentResearch.Bonus = new MilleniumGoalsSet(1, 1, 1, 1, 1, 1);
                float bonus = (float)Convert.ToDouble(researchElement.Element("bonus").Value);
                switch (currentResearch.ResearchType)
                {
                    case ConstructionType.Economy:
                        currentResearch.Bonus.Economy = bonus;
                        break;
                    case ConstructionType.Education:
                        currentResearch.Bonus.Education = bonus;
                        break;
                    case ConstructionType.Environment:
                        currentResearch.Bonus.Environment = bonus;
                        break;
                    case ConstructionType.Food:
                        currentResearch.Bonus.Food = bonus;
                        break;
                    case ConstructionType.Health:
                        currentResearch.Bonus.Health = bonus;
                        break;
                    case ConstructionType.Energy:
                        currentResearch.Bonus.Energy = bonus;
                        break;
                }
                currentResearch.Cost = Convert.ToInt32(researchElement.Element("cost").Value);
                currentResearch.Name = researchElement.Element("name").Value.ToString();
                currentResearch.Description = Convert.ToString(researchElement.Element("description").Value);
                currentResearch.Completed = Convert.ToBoolean(researchElement.Element("done").Value);

                researchList.Add(currentResearch);
            }
            return researchList;
        }