Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        private ItemsTable CreateBattles()
        {
            ICollection battles = ruler.GetAllBattles( type );

            ItemsTable _itemsTable = new ItemsTable();

            if( TitleRef == null ) {
                _itemsTable.Title = info.getContent("currentBattle_title");
            }else {
                _itemsTable.Title = info.getContent(TitleRef);
            }

            _itemsTable.TitleCssClass = "planetInfoZoneTitle";
            _itemsTable.TableCssClass = "planetFrame";

            createTitle( _itemsTable );

            if( battles != null && battles.Count > 0 ) {

                string onlineImage = OrionGlobals.getCommonImagePath("online.gif");
                string offlineImage = OrionGlobals.getCommonImagePath("offline.gif");

                IEnumerator iter = battles.GetEnumerator( );
                while( iter.MoveNext() ) {
                    SimpleBattleInfo battleInfo = iter.Current as SimpleBattleInfo;

                    if( null == battleInfo)
                        continue;

                    if( !battleInfo.Accepted ) {
                        continue;
                    }

                    ItemsTableLine line = new ItemsTableLine();

                    ItemsTableText turn = new ItemsTableText( battleInfo.CurrentTurn.ToString(  ), "resource" );

                    ItemsTableText opponent = new ItemsTableText( OrionGlobals.getLink( battleInfo.Enemy ) , "resource" );

                    string onlineState;

                    // indicar se o utilizador está online
                    if( OrionGlobals.isUserOnline(battleInfo.Enemy.ForeignId) ) {
                        onlineState = string.Format("<img src='{0}' />", onlineImage);
                    } else {
                        onlineState = string.Format("<img src='{0}' />", offlineImage);
                    }

                    ItemsTableText opponentStatus = new ItemsTableText( onlineState , "resource" );

                    ItemsTableText battleType = new ItemsTableText( info.getContent(battleInfo.Type) , "resource" );

                    ItemsTableItem status;
                    string rulerTurn;
                    if( battleInfo.IsPositionTime ) {
                        rulerTurn = info.getContent("currentBattle_rulerPosition");
                    }else {
                        if( battleInfo.IsTurn ) {
                            if( battleInfo.EnemyIsPositionTime ) {
                                rulerTurn = info.getContent("currentBattle_enemyPositioning");
                            }else {
                                rulerTurn = info.getContent("currentBattle_rulerTurn");
                            }
                        }else{
                            rulerTurn = info.getContent("currentBattle_enemyTurn");
                        }
                    }

                    status = new ItemsTableLink(
                        rulerTurn,
                        OrionGlobals.calculatePath( "battle.aspx?id=" + battleInfo.BattleId ),
                        "resource"
                    );

                    ItemsTableText timeLeft = new ItemsTableText( modifyTime(battleInfo.TurnsLeft.ToString()) , "resource" );

                    ItemsTableText coordPlanet = null;
                    if( type == Chronos.Battle.BattleType.BATTLE ) {
                        if( battleInfo.IsPlanet  ) {
                            Planet p = Universe.instance.getPlanet( battleInfo.Coordinate );
                            coordPlanet = new ItemsTableText( getPlanetLink( p ), "resource" );
                        } else {
                            coordPlanet = new ItemsTableText( battleInfo.Coordinate.ToString(), "resource" );
                        }
                    }

                    ItemsTableText timeout = new ItemsTableText( battleInfo.MissedTurns.ToString() , "resource" );

                    line.add( turn );
                    line.add( opponent );
                    line.add( opponentStatus );
                    line.add( battleType );
                    line.add( status );
                    line.add( timeout );

                    if( type == Chronos.Battle.BattleType.BATTLE ) {
                        line.add( coordPlanet );
                    }

                    line.add( timeLeft );
                    _itemsTable.addLine( line );
                }
            }

            if( !_itemsTable.HasControls() ) {
                ItemsTableLine line = new ItemsTableLine();
                ItemsTableText txt = new ItemsTableText( info.getContent("currentBattle_noBattles"), "resource" );

                if( type == Chronos.Battle.BattleType.BATTLE ) {
                    txt.ColumnSpan = 8;
                }else {
                    txt.ColumnSpan = 7;
                }

                line.add( txt );
                _itemsTable.addLine( line );
            }

            return _itemsTable;
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        private ItemsTable CreateBattles()
        {
            ICollection battles = ruler.GetAllBattles(type);

            ItemsTable _itemsTable = new ItemsTable();

            if (TitleRef == null)
            {
                _itemsTable.Title = info.getContent("currentBattle_title");
            }
            else
            {
                _itemsTable.Title = info.getContent(TitleRef);
            }

            _itemsTable.TitleCssClass = "planetInfoZoneTitle";
            _itemsTable.TableCssClass = "planetFrame";

            createTitle(_itemsTable);

            if (battles != null && battles.Count > 0)
            {
                string onlineImage  = OrionGlobals.getCommonImagePath("online.gif");
                string offlineImage = OrionGlobals.getCommonImagePath("offline.gif");

                IEnumerator iter = battles.GetEnumerator( );
                while (iter.MoveNext())
                {
                    SimpleBattleInfo battleInfo = iter.Current as SimpleBattleInfo;

                    if (null == battleInfo)
                    {
                        continue;
                    }

                    if (!battleInfo.Accepted)
                    {
                        continue;
                    }

                    ItemsTableLine line = new ItemsTableLine();

                    ItemsTableText turn = new ItemsTableText(battleInfo.CurrentTurn.ToString(  ), "resource");

                    ItemsTableText opponent = new ItemsTableText(OrionGlobals.getLink(battleInfo.Enemy), "resource");

                    string onlineState;

                    // indicar se o utilizador está online
                    if (OrionGlobals.isUserOnline(battleInfo.Enemy.ForeignId))
                    {
                        onlineState = string.Format("<img src='{0}' />", onlineImage);
                    }
                    else
                    {
                        onlineState = string.Format("<img src='{0}' />", offlineImage);
                    }

                    ItemsTableText opponentStatus = new ItemsTableText(onlineState, "resource");

                    ItemsTableText battleType = new ItemsTableText(info.getContent(battleInfo.Type), "resource");

                    ItemsTableItem status;
                    string         rulerTurn;
                    if (battleInfo.IsPositionTime)
                    {
                        rulerTurn = info.getContent("currentBattle_rulerPosition");
                    }
                    else
                    {
                        if (battleInfo.IsTurn)
                        {
                            if (battleInfo.EnemyIsPositionTime)
                            {
                                rulerTurn = info.getContent("currentBattle_enemyPositioning");
                            }
                            else
                            {
                                rulerTurn = info.getContent("currentBattle_rulerTurn");
                            }
                        }
                        else
                        {
                            rulerTurn = info.getContent("currentBattle_enemyTurn");
                        }
                    }

                    status = new ItemsTableLink(
                        rulerTurn,
                        OrionGlobals.calculatePath("battle.aspx?id=" + battleInfo.BattleId),
                        "resource"
                        );

                    ItemsTableText timeLeft = new ItemsTableText(modifyTime(battleInfo.TurnsLeft.ToString()), "resource");

                    ItemsTableText coordPlanet = null;
                    if (type == Chronos.Battle.BattleType.BATTLE)
                    {
                        if (battleInfo.IsPlanet)
                        {
                            Planet p = Universe.instance.getPlanet(battleInfo.Coordinate);
                            coordPlanet = new ItemsTableText(getPlanetLink(p), "resource");
                        }
                        else
                        {
                            coordPlanet = new ItemsTableText(battleInfo.Coordinate.ToString(), "resource");
                        }
                    }

                    ItemsTableText timeout = new ItemsTableText(battleInfo.MissedTurns.ToString(), "resource");

                    line.add(turn);
                    line.add(opponent);
                    line.add(opponentStatus);
                    line.add(battleType);
                    line.add(status);
                    line.add(timeout);

                    if (type == Chronos.Battle.BattleType.BATTLE)
                    {
                        line.add(coordPlanet);
                    }

                    line.add(timeLeft);
                    _itemsTable.addLine(line);
                }
            }


            if (!_itemsTable.HasControls())
            {
                ItemsTableLine line = new ItemsTableLine();
                ItemsTableText txt  = new ItemsTableText(info.getContent("currentBattle_noBattles"), "resource");

                if (type == Chronos.Battle.BattleType.BATTLE)
                {
                    txt.ColumnSpan = 8;
                }
                else
                {
                    txt.ColumnSpan = 7;
                }

                line.add(txt);
                _itemsTable.addLine(line);
            }

            return(_itemsTable);
        }