Пример #1
0
        private void CreateFleets()
        {
            Hashtable universeFleets = _ruler.UniverseFleets;

            _itemsTable.Title         = info.getContent("battle_fleetsReadyToBattle");
            _itemsTable.TitleCssClass = "planetInfoZoneTitle";
            _itemsTable.TableCssClass = "planetFrame";

            createTitle(_itemsTable);
            bool isOneReady = false;

            if (universeFleets != null && universeFleets.Count > 0)
            {
                IDictionaryEnumerator iter = universeFleets.GetEnumerator();

                while (iter.MoveNext())
                {
                    Chronos.Core.Fleet f = (Chronos.Core.Fleet)iter.Value;
                    Planet             p = Universe.instance.getPlanet(f.Coordinate);

                    if (f.GoodForBattle)
                    {
                        ItemsTableLine line = new ItemsTableLine();

                        ItemsTableText fleet = new ItemsTableText(f.Name, "resource");
                        ItemsTableText coord = new ItemsTableText(f.Coordinate.ToString(), "resource");

                        ItemsTableText rulerName;
                        if (p.Owner != null)
                        {
                            rulerName = new ItemsTableText(OrionGlobals.getLink((Ruler)p.Owner), "resource");
                        }
                        else
                        {
                            rulerName = new ItemsTableText(info.getContent("conquerplanet_none"), "resource");
                        }

                        ItemsTableItem action;

                        if (p.IsInBattle)
                        {
                            action = new ItemsTableText(info.getContent("battle_isInBattle"), "resource");
                        }
                        else
                        {
                            if (p.HasImmunity)
                            {
                                action = new ItemsTableText(string.Format(info.getContent("BattleImmunity"), p.Immunity), "resource");
                            }
                            else
                            {
                                if (p.Owner != null && Ruler.IsSameAlliance((Ruler)p.Owner, (Ruler)f.Owner))
                                {
                                    action = new ItemsTableText(info.getContent("battle_sameAlliance"), "resource");
                                }
                                else
                                {
                                    if (!p.HasProtection)
                                    {
                                        action = new ItemsTableText(info.getContent("planet_not_protected"), "resource");
                                    }
                                    else
                                    {
                                        action = new ItemsTableImageButton(OrionGlobals.getCommonImagePath("ok.gif"), fleet.ID);
                                        ((ItemsTableImageButton)action).Click += new ImageClickEventHandler(submit_Click);
                                    }
                                }
                            }
                        }

                        line.add(fleet);
                        line.add(coord);
                        line.add(rulerName);
                        line.add(action);

                        _itemsTable.addLine(line);

                        isOneReady = true;
                    }
                }
            }

            if (!isOneReady)
            {
                insertNoFleets();
            }
        }