private void submit_Click(object sender, ImageClickEventArgs e) { string fleetName = _itemsTable.getSpecificText(_itemsTable.SelectedIndex, 0); Chronos.Core.Fleet fleet = _ruler.getFleet(fleetName); if (fleet == null) { throw new AlnitakException("Fleet é null no evento de Click @ ReadyForBattle::toBattle_Click"); } Chronos.Core.Planet currentPlanet = Universe.instance.getPlanet(fleet.Coordinate); if (currentPlanet == null) { throw new AlnitakException("O planeta é null no evento de Click @ ReadyForBattle::toBattle_Click"); } Ruler enemy = currentPlanet.Owner as Ruler; if (enemy == null) { throw new AlnitakException("O planeta onde a fleet " + fleetName + " está não tem dono"); } if (!currentPlanet.IsInBattle) { Universe.instance.CreateBattle(_ruler, fleet, enemy, currentPlanet, BattleType.BATTLE, "totalannihilation"); updateTable(); } }
/// <summary>Escreve um planeta</summary> private void writePlanet(Chronos.Core.Planet planet) { MasterSkinInfo masterSkinInfo = (MasterSkinInfo)Context.Items["MasterSkinInfo"]; string control = OrionGlobals.AppPath + masterSkinInfo.masterSkinName + "/controls/" + controlToLoad; Control planetPage = Page.LoadControl(control); Image img = (Image)planetPage.FindControl("img"); if (img != null) { img.ImageUrl = OrionGlobals.getCommonImagePath("planets/" + planet.Info.Id + ".jpg"); img.EnableViewState = false; } ResourcesList resources = (ResourcesList)planetPage.FindControl("resourcesList"); if (resources != null) { resources.Manager = planet; resources.Title = info.getContent("planetResources"); resources.Category = "Intrinsic"; resources.ShowImages = true; resources.ShowOnlyQuantity = false; resources.ShowZeroQuantity = true; resources.ShowDocumentation = false; } writeGeneral(planet, planetPage); Controls.Add(planetPage); }
/// <summary>Preenche os controlos relativos a um recurso</summary> private void fillResource(string resource, Control control, Chronos.Core.Planet planet) { Label quantity = (Label)control.FindControl(resource + "Quantity"); if (quantity != null) { quantity.EnableViewState = false; int val = planet.getResourceCount(resource); quantity.Text = val.ToString(); if (val < 0) { quantity.CssClass = "error"; } } Label ratio = (Label)control.FindControl(resource + "Ratio"); if (ratio != null) { ratio.EnableViewState = false; int val = planet.getRatio(resource); if (val > 0) { ratio.Text = val.ToString() + "%"; } else { ratio.Text = "-"; } } Label perTurn = (Label)control.FindControl(resource + "PerTurn"); if (perTurn != null) { perTurn.EnableViewState = false; int val = planet.getPerTurn("Intrinsic", resource); string str = val.ToString(); if (val > 0) { str = "+" + str; perTurn.Text = str; } else if (val == 0) { perTurn.Text = "-"; } else { perTurn.CssClass = "error"; perTurn.Text = str; } } }
protected override void OnInit(EventArgs e) { planet = getPlanet(); nameValidator.ErrorMessage = info.getContent("fleet_invalidFleetName"); createFleet.Text = info.getContent("fleet_createFleet"); createFleet.Click +=new EventHandler(createFleet_Click); base.OnInit( e ); }
protected override void OnInit(EventArgs e) { planet = getPlanet(); nameValidator.ErrorMessage = info.getContent("fleet_invalidFleetName"); createFleet.Text = info.getContent("fleet_createFleet"); createFleet.Click += new EventHandler(createFleet_Click); base.OnInit(e); }
/// <summary>Pinta o controlo</summary> protected override void OnPreRender(EventArgs args) { Chronos.Core.Planet planet = getPlanet(); OrionGlobals.RegisterRequest(Chronos.Messaging.MessageType.PlanetManagement, string.Format("{1} - {0}", info.getContent("section_planet"), planet.Name)); if (planet == null) { writeErrorResponse(); return; } writePlanet(planet); }
private void planets_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { Control planetSkin = e.Item; Chronos.Core.Planet planet = (Chronos.Core.Planet)e.Item.DataItem; Image img = (Image)planetSkin.FindControl("img"); if (img != null) { img.ImageUrl = string.Format("{0}planets/{1}.jpg", OrionGlobals.getCommonImagePath(""), planet.Info.Id); } HyperLink planetLink = (HyperLink)planetSkin.FindControl("planetLink"); if (planetLink != null) { //planetLink.NavigateUrl = OrionGlobals.resolveBase("ruler/planets/planet/default.aspx?id=" + planet.Id); planetLink.NavigateUrl = OrionGlobals.getSectionUrl("planet") + "default.aspx?id=" + planet.Id; } HyperLink buildingsLink = (HyperLink)planetSkin.FindControl("buildingsLink"); if (buildingsLink != null) { buildingsLink.NavigateUrl = OrionGlobals.resolveBase("ruler/planets/planet/buildings.aspx?id=" + planet.Id); buildingsLink.Text = info.getContent("Building"); } Label name = (Label)planetSkin.FindControl("name"); if (name != null) { name.Text = planet.Name; } Label coordinate = (Label)planetSkin.FindControl("coordinate"); if (coordinate != null) { coordinate.Text = planet.Coordinate.ToString(); } Control resources = (Control)planetSkin.FindControl("resourcesPanel"); if (resources != null) { resources.Controls.Add(new ShowPlanetResources(planet)); } fillResourceType("Building", planetSkin, planet); } }
/// <summary>Pinta o controlo</summary> protected override void OnPreRender(EventArgs args) { Ruler ruler = getRuler(); Chronos.Core.Planet planet = getPlanet(); if (planet == null) { writeErrorResponse(); return; } writeControl(ruler, planet); base.OnPreRender(args); }
/// <summary>Escreve as informações gerais de um planeta</summary> private void writeGeneral(Chronos.Core.Planet planet, Control control) { fillLabel(control, "name", planet.Name); fillLabel(control, "coordinate", planet.Coordinate.ToString()); fillLabel(control, "diameter", planet.Info.Diameter.ToString()); fillLabel(control, "mass", planet.Info.Mass.ToString()); fillLabel(control, "temperature", planet.Info.Temperature.ToString()); fillLabel(control, "escape", planet.Info.EscapeVelocity.ToString()); fillLabel(control, "terrain", info.getContent(planet.Info.Terrain.Description)); fillPanel(control, "mineral", (int)planet.ModifiersRatio["mp"]); fillPanel(control, "food", (int)planet.ModifiersRatio["food"]); fillPanel(control, "gold", (int)planet.ModifiersRatio["gold"]); fillPanel(control, "energy", (int)planet.ModifiersRatio["energy"]); fillPanel(control, "groundSpace", planet.getResourceCount("Intrinsic", "groundSpace")); fillPanel(control, "waterSpace", planet.getResourceCount("Intrinsic", "waterSpace")); fillPanel(control, "orbitSpace", planet.getResourceCount("Intrinsic", "orbitSpace")); }
/// <summary>Escreve a lista de edificios</summary> private void writeBuildingList(Chronos.Core.Planet planet, Control planetSkin, string cat, bool keys) { Resources resources = (Resources)planetSkin.FindControl(cat); resources.Manager = planet; resources.ShowSpaceCost = true; resources.ShowDocumentation = true; resources.AllowKeywords = keys; resources.Tooltip = "modifiers"; resources.Title = string.Format("<b>{0}</b> - {1}", info.getContent("recursos"), info.getContent(cat)); resources.ShowDuration = true; resources.CategoryDescription = cat; resources.ShowDemolish = keys; QueueErrorReport queueError = (QueueErrorReport)planetSkin.FindControl("queueError"); resources.QueueError = queueError; }
/// <summary>Pinta o Controlo</summary> protected void writeControl(Chronos.Core.Ruler ruler, Chronos.Core.Planet planet) { //MasterSkinInfo masterSkinInfo = (MasterSkinInfo)Context.Items["MasterSkinInfo"]; string control = OrionGlobals.AppPath + "skins/planetaria/controls/ManageBuildings.ascx"; Control planetSkin = Page.LoadControl(control); ResourcesList resources = (ResourcesList)planetSkin.FindControl("resourcesList"); if (resources != null) { resources.Manager = planet; resources.Title = info.getContent("planetResources"); resources.Category = "Intrinsic"; resources.ShowImages = true; resources.ShowDocumentation = false; resources.ResourcesToShow = new string[] { "gold", "mp", "food", "labor", "housing", "energy", "culture", "polution" }; resources.ShowSpace = true; } QueueNotifier queue = (QueueNotifier)planetSkin.FindControl("queue"); if (queue != null) { queue.Manager = planet; queue.Category = "Building"; queue.Title = info.getContent("inProduction"); queue.EmptyMessage = info.getContent("buildingsQueueEmpty"); } PlanetNavigation nav = (PlanetNavigation)planetSkin.FindControl("planetNavigation"); if (null != nav) { nav.Player = ruler; nav.Current = planet; nav.Section = "Buildings"; } writeBuildingList(planet, planetSkin, "general", true); writeBuildingList(planet, planetSkin, "upgrade", false); HyperLink intrinsicHelp = (HyperLink)planetSkin.FindControl("intrinsicHelp"); intrinsicHelp.NavigateUrl = Wiki.GetUrl("Intrinsic", "Intrinsic"); intrinsicHelp.Text = info.getContent("wiki_Intrinsecos"); HyperLink buildingHelp = (HyperLink)planetSkin.FindControl("buildingHelp"); buildingHelp.NavigateUrl = Wiki.GetUrl("Building", "Building"); buildingHelp.Text = info.getContent("wiki_Edificios"); HyperLink queueHelp = (HyperLink)planetSkin.FindControl("queueHelp"); queueHelp.NavigateUrl = Wiki.GetUrl("FilaDeEspera"); queueHelp.Text = info.getContent("wiki_FilaDeEspera"); Controls.Add(planetSkin); OrionGlobals.RegisterRequest(Chronos.Messaging.MessageType.PlanetManagement, string.Format("{1} - {0}", info.getContent("section_buildings"), planet.Name)); }
/// <summary>Construtor</summary> public ShowPlanetResources( Chronos.Core.Planet p ) { planet = p; }
/// <summary>Preenche os controlos relativos a um recurso</summary> private void fillResourceType(string resource, Control control, Chronos.Core.Planet planet) { QueueItem item = planet.current(resource); Label type = (Label)control.FindControl("resource" + resource); if (type != null) { if (item != null) { type.EnableViewState = false; if (item == null) { type.Text = "-"; } else { string resType = info.getContent(item.FactoryName); type.Text = resType; } } else { type.Text = "-"; } } Label queueCount = (Label)control.FindControl("queueCount" + resource); if (queueCount != null) { queueCount.EnableViewState = false; queueCount.Text = planet.queueCount(resource).ToString(); } Label quantity = (Label)control.FindControl("quantity" + resource); if (quantity != null) { if (item != null) { quantity.EnableViewState = false; quantity.Text = item.Quantity.ToString(); } else { quantity.Text = "-"; } } Label toGo = (Label)control.FindControl("toGo" + resource); if (toGo != null) { if (item != null) { toGo.EnableViewState = false; toGo.Text = "+ " + item.RemainingTurns; } else { toGo.Text = "-"; } } }
/// <summary>Construtor</summary> public ShowPlanetResources(Chronos.Core.Planet p) { planet = p; }