public ConstructionPanel(Game game, BaseConstruction construction) : base(game) { frame = new Sprite(game, GraphicsCollection.GetPack("construction-panel-frame")); frame.StackOrder = 1; AddChild(frame); selectedConstruction = construction; if (Destroyable()) { destroy = new ConstructionPanelButton(game, ConstructionPanelButtonType.Destroy); destroy.StackOrder = 2; destroy.XRelative = buttonsXposition; destroy.YRelative = 45; destroy.OnMouseRelease += new EventHandler <Operation_Cronos.Input.MouseEventArgs>(destroy_OnMouseRelease); destroy.OnMouseOver += new EventHandler <ButtonEventArgs>(Button_OnMouseOver); destroy.OnMouseLeave += new EventHandler <ButtonEventArgs>(Button_OnMouseLeave); AddChild(destroy); } if (GeneralConstructionUpgradeable()) { upgrade = new ConstructionPanelButton(game, ConstructionPanelButtonType.Upgrade); upgrade.StackOrder = 2; upgrade.XRelative = buttonsXposition; upgrade.YRelative = 173; upgrade.OnMouseRelease += new EventHandler <Operation_Cronos.Input.MouseEventArgs>(upgrade_OnMouseRelease); upgrade.OnMouseOver += new EventHandler <ButtonEventArgs>(Button_OnMouseOver); upgrade.OnMouseLeave += new EventHandler <ButtonEventArgs>(Button_OnMouseLeave); AddChild(upgrade); textUpgradeCost = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font); textUpgradeCost.StackOrder = 2; textUpgradeCost.XRelative = 95; textUpgradeCost.YRelative = 225; textUpgradeCost.Tint = Color.Green; textUpgradeCost.Text = GetUpgradeText() + GetUpgradeCost().ToString(); AddChild(textUpgradeCost); } if (PopulationConstructionUpgradeable()) { upgrade = new ConstructionPanelButton(game, ConstructionPanelButtonType.Upgrade); upgrade.StackOrder = 2; upgrade.XRelative = buttonsXposition; upgrade.YRelative = 173; upgrade.OnMousePress += new EventHandler <Operation_Cronos.Input.MouseEventArgs>(upgrade_OnMouseRelease); upgrade.OnMouseOver += new EventHandler <ButtonEventArgs>(Button_OnMouseOver); upgrade.OnMouseLeave += new EventHandler <ButtonEventArgs>(Button_OnMouseLeave); AddChild(upgrade); textUpgradeCost = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font); textUpgradeCost.XRelative = 95; textUpgradeCost.YRelative = 225; textUpgradeCost.StackOrder = 2; textUpgradeCost.Tint = Color.Green; textUpgradeCost.Text = GetUpgradeText() + GetUpgradeCost().ToString(); AddChild(textUpgradeCost); } if (Repairable()) { repair = new ConstructionPanelButton(game, ConstructionPanelButtonType.Repair); repair.StackOrder = 2; repair.XRelative = buttonsXposition; repair.YRelative = 108; repair.OnMouseRelease += new EventHandler <Operation_Cronos.Input.MouseEventArgs>(repair_OnMouseRelease); repair.OnMouseOver += new EventHandler <ButtonEventArgs>(Button_OnMouseOver); repair.OnMouseLeave += new EventHandler <ButtonEventArgs>(Button_OnMouseLeave); AddChild(repair); textRepairCost = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font); textRepairCost.XRelative = 323; textRepairCost.YRelative = 225; textRepairCost.StackOrder = 2; textRepairCost.Tint = Color.Green; textRepairCost.Text = "Repair price: " + GetRepairCost().ToString(); AddChild(textRepairCost); } else //not repairable { if (AlreadyRepairedInCurrentYear()) { textRepairCost = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font); textRepairCost.XRelative = 323; textRepairCost.YRelative = 225; textRepairCost.Tint = Color.Green; textRepairCost.StackOrder = 2; textRepairCost.Text = "Repaired this year"; AddChild(textRepairCost); } } close = new ConstructionPanelButton(game, ConstructionPanelButtonType.Close); close.StackOrder = 2; close.XRelative = 430; close.YRelative = 7; close.OnMouseRelease += new EventHandler <Operation_Cronos.Input.MouseEventArgs>(close_OnMouseRelease); AddChild(close); textBuildingNameAndStage = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font); textBuildingNameAndStage.XRelative = 95; textBuildingNameAndStage.YRelative = 20; textBuildingNameAndStage.Tint = Color.Gray; textBuildingNameAndStage.StackOrder = 2; textBuildingNameAndStage.Text = GetDescriptionFromEnum(selectedConstruction.ConstructionName, 0); if (selectedConstruction.ConstructionType != ConstructionType.Population) { textBuildingNameAndStage.Text += " - " + GetDescriptionFromEnum((selectedConstruction.Slot.GetReservation(GameManager.CurrentYear).Status(GameManager.CurrentYear)), 0); } AddChild(textBuildingNameAndStage); textGeneralInfo = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font); textGeneralInfo.XRelative = 95; textGeneralInfo.YRelative = 60; textGeneralInfo.StackOrder = 2; textGeneralInfo.Tint = Color.White; textGeneralInfo.Text = GetConstructionYear() + "\n" + GetLifetimeLeft() + "\n" + GetConstructionParameters(); AddChild(textGeneralInfo); selectedConstruction.SelectConstruction = true; if (selectedConstruction.ConstructionType == ConstructionType.Education || selectedConstruction.ConstructionType == ConstructionType.Health || selectedConstruction.ConstructionType == ConstructionType.Population || selectedConstruction.ConstructionType == ConstructionType.Energy) { SoundManager.PlaySound((Sounds)Enum.Parse(typeof(Sounds), selectedConstruction.ConstructionType.ToString())); } else { SoundManager.PlaySound((Sounds)Enum.Parse(typeof(Sounds), selectedConstruction.ConstructionName.ToString())); } }
public ConstructionPanel(Game game, BaseConstruction construction) : base(game) { frame = new Sprite(game, GraphicsCollection.GetPack("construction-panel-frame")); frame.StackOrder = 1; AddChild(frame); selectedConstruction = construction; if (Destroyable()) { destroy = new ConstructionPanelButton(game, ConstructionPanelButtonType.Destroy); destroy.StackOrder = 2; destroy.XRelative = buttonsXposition; destroy.YRelative = 45; destroy.OnMouseRelease += new EventHandler<Operation_Cronos.Input.MouseEventArgs>(destroy_OnMouseRelease); destroy.OnMouseOver += new EventHandler<ButtonEventArgs>(Button_OnMouseOver); destroy.OnMouseLeave += new EventHandler<ButtonEventArgs>(Button_OnMouseLeave); AddChild(destroy); } if (GeneralConstructionUpgradeable()) { upgrade = new ConstructionPanelButton(game, ConstructionPanelButtonType.Upgrade); upgrade.StackOrder = 2; upgrade.XRelative = buttonsXposition; upgrade.YRelative = 173; upgrade.OnMouseRelease += new EventHandler<Operation_Cronos.Input.MouseEventArgs>(upgrade_OnMouseRelease); upgrade.OnMouseOver += new EventHandler<ButtonEventArgs>(Button_OnMouseOver); upgrade.OnMouseLeave += new EventHandler<ButtonEventArgs>(Button_OnMouseLeave); AddChild(upgrade); textUpgradeCost = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font); textUpgradeCost.StackOrder = 2; textUpgradeCost.XRelative = 95; textUpgradeCost.YRelative = 225; textUpgradeCost.Tint = Color.Green; textUpgradeCost.Text = GetUpgradeText() + GetUpgradeCost().ToString(); AddChild(textUpgradeCost); } if (PopulationConstructionUpgradeable()) { upgrade = new ConstructionPanelButton(game, ConstructionPanelButtonType.Upgrade); upgrade.StackOrder = 2; upgrade.XRelative = buttonsXposition; upgrade.YRelative = 173; upgrade.OnMousePress += new EventHandler<Operation_Cronos.Input.MouseEventArgs>(upgrade_OnMouseRelease); upgrade.OnMouseOver += new EventHandler<ButtonEventArgs>(Button_OnMouseOver); upgrade.OnMouseLeave += new EventHandler<ButtonEventArgs>(Button_OnMouseLeave); AddChild(upgrade); textUpgradeCost = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font); textUpgradeCost.XRelative = 95; textUpgradeCost.YRelative = 225; textUpgradeCost.StackOrder = 2; textUpgradeCost.Tint = Color.Green; textUpgradeCost.Text = GetUpgradeText() + GetUpgradeCost().ToString(); AddChild(textUpgradeCost); } if (Repairable()) { repair = new ConstructionPanelButton(game, ConstructionPanelButtonType.Repair); repair.StackOrder = 2; repair.XRelative = buttonsXposition; repair.YRelative = 108; repair.OnMouseRelease += new EventHandler<Operation_Cronos.Input.MouseEventArgs>(repair_OnMouseRelease); repair.OnMouseOver += new EventHandler<ButtonEventArgs>(Button_OnMouseOver); repair.OnMouseLeave += new EventHandler<ButtonEventArgs>(Button_OnMouseLeave); AddChild(repair); textRepairCost = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font); textRepairCost.XRelative = 323; textRepairCost.YRelative = 225; textRepairCost.StackOrder = 2; textRepairCost.Tint = Color.Green; textRepairCost.Text = "Repair price: " + GetRepairCost().ToString(); AddChild(textRepairCost); } else //not repairable { if (AlreadyRepairedInCurrentYear()) { textRepairCost = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font); textRepairCost.XRelative = 323; textRepairCost.YRelative = 225; textRepairCost.Tint = Color.Green; textRepairCost.StackOrder = 2; textRepairCost.Text = "Repaired this year"; AddChild(textRepairCost); } } close = new ConstructionPanelButton(game, ConstructionPanelButtonType.Close); close.StackOrder = 2; close.XRelative = 430; close.YRelative = 7; close.OnMouseRelease += new EventHandler<Operation_Cronos.Input.MouseEventArgs>(close_OnMouseRelease); AddChild(close); textBuildingNameAndStage = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font); textBuildingNameAndStage.XRelative = 95; textBuildingNameAndStage.YRelative = 20; textBuildingNameAndStage.Tint = Color.Gray; textBuildingNameAndStage.StackOrder = 2; textBuildingNameAndStage.Text = GetDescriptionFromEnum(selectedConstruction.ConstructionName, 0); if (selectedConstruction.ConstructionType != ConstructionType.Population) textBuildingNameAndStage.Text += " - " + GetDescriptionFromEnum((selectedConstruction.Slot.GetReservation(GameManager.CurrentYear).Status(GameManager.CurrentYear)), 0); AddChild(textBuildingNameAndStage); textGeneralInfo = new SpriteText(game, FontsCollection.GetPack("Calibri 10").Font); textGeneralInfo.XRelative = 95; textGeneralInfo.YRelative = 60; textGeneralInfo.StackOrder = 2; textGeneralInfo.Tint = Color.White; textGeneralInfo.Text = GetConstructionYear() + "\n" + GetLifetimeLeft() + "\n" + GetConstructionParameters(); AddChild(textGeneralInfo); selectedConstruction.SelectConstruction = true; if (selectedConstruction.ConstructionType == ConstructionType.Education || selectedConstruction.ConstructionType == ConstructionType.Health || selectedConstruction.ConstructionType == ConstructionType.Population || selectedConstruction.ConstructionType == ConstructionType.Energy) SoundManager.PlaySound((Sounds)Enum.Parse(typeof(Sounds), selectedConstruction.ConstructionType.ToString())); else SoundManager.PlaySound((Sounds)Enum.Parse(typeof(Sounds), selectedConstruction.ConstructionName.ToString())); }