当前位置: 首页>>代码示例>>C#>>正文


C# Sector.ToString方法代码示例

本文整理汇总了C#中Sector.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Sector.ToString方法的具体用法?C# Sector.ToString怎么用?C# Sector.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sector的用法示例。


在下文中一共展示了Sector.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            //the player (aka the attacker) is always the current player
            player = Wc3o.Game.CurrentPlayer;

            //get the enemy
            if (Request.QueryString["Enemy"] != null)
                if (Request.QueryString["Enemy"].ToString() == "-")
                    enemy = null;
                else
                    enemy = Wc3o.Game.GameData.Players[Request.QueryString["Enemy"]];
            else {
                Wc3o.Game.Message(Master, "This enemy does not exist.", MessageType.Error);
                return;
            }

            //get the sector
            try {
                sector = Wc3o.Game.GameData.Sectors[new Coordinate(Request.QueryString["Sector"])];
            } catch {
                Wc3o.Game.Message(Master, "This sector does not exist.", MessageType.Error);
                return;
            }

            if (!IsPostBack) {
                if (!player.CanAttack(enemy)) {
                    Wc3o.Game.Message(Master, "You cannot attack this enemy.", MessageType.Error);
                    return;
                }

                bool hasUnits = false;
                bool hasAlliedUnits = false;
                foreach (Unit u in sector.Units)
                    if (u.IsAvailable)
                        if (player == u.Owner)
                            hasUnits = true;
                        else if (player.IsAlly(u.Owner) && player.HasAHigherAllianceRank(u.Owner))
                            hasAlliedUnits = true;
                if (!hasUnits) {
                    Wc3o.Game.Message(Master, "You have no available units on this sector.", MessageType.Error);
                    return;
                }

                if (hasAlliedUnits)
                    if (Request.QueryString["Type"] != null && Request.QueryString["Type"].ToString() == "Allied")
                        chkAllied.Checked = true;
                    else
                        chkAllied.Enabled = false;

                if (enemy == null)
                    lblHostile.Text = "some Creeps";
                else
                    lblHostile.Text = enemy.FullName;
                lblSector.Text = sector.ToString();

                pnlAttack.Visible = false;
                pnlSettings.Visible = true;
            }
        }
开发者ID:BackupTheBerlios,项目名称:wc3o-svn,代码行数:59,代码来源:Battle.aspx.cs

示例2: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            player = Wc3o.Game.CurrentPlayer;
            sector = Wc3o.Game.CurrentSector;

            if (!IsPostBack) {
                hplSector.Text = sector.ToString();
                hplSector.NavigateUrl = "Map.aspx?Sector=" + sector.Coordinate.ToString();
                if (sector.Owner == null)
                    hplSector.ForeColor = System.Drawing.Color.FromName(Configuration.Color_Neutral);
                else if (sector.Owner == player)
                    hplSector.ForeColor = System.Drawing.Color.FromName(Configuration.Color_Player);
                else if (player.IsAlly(sector.Owner))
                    hplSector.ForeColor = System.Drawing.Color.FromName(Configuration.Color_Ally);
                else if (player.CanAttack(sector.Owner))
                    hplSector.ForeColor = System.Drawing.Color.FromName(Configuration.Color_Enemy);
                else
                    hplSector.ForeColor = System.Drawing.Color.FromName(Configuration.Color_League);

                if (sector.Owner != null) {
                    hplOwner.Text = sector.Owner.FullName;
                    hplOwner.NavigateUrl = "PlayerInfo.aspx?Player=" + sector.Owner.Name;
                }
                else
                    hplOwner.Text = "<i>this sector has no owner.</i>";

                if (sector is GoldAndLumberSector) {
                    GoldAndLumberSector goldAndLumberSector = sector as GoldAndLumberSector;
                    lblSectorInfo.Text = "<br />This sector has <img src='" + player.Gfx + "/Game/Gold.gif' /> (" + ((int)goldAndLumberSector.GoldEfficiency * 100) + " %) and <img src='" + player.Gfx + "/Game/Lumber.gif' /> (" + ((int)goldAndLumberSector.LumberEfficiency * 100) + " %)";
                }
                else if (sector is GoldSector)
                    lblSectorInfo.Text = "<br />This sector has <img src='" + player.Gfx + "/Game/Gold.gif' /> (" + ((int)(sector as GoldSector).GoldEfficiency * 100) + " %)";
                else if (sector is LumberSector)
                    lblSectorInfo.Text = "<br />This sector has <img src='" + player.Gfx + "/Game/Lumber.gif' /> (" + ((int)(sector as LumberSector).LumberEfficiency * 100) + " %)";
                else if (sector is HealingSector)
                    lblSectorInfo.Text = "<br />This sector heals your units (" + ((int)(sector as HealingSector).HealingEfficiency * 100) + " %)";
                else if (sector is MercenarySector)
                    lblSectorInfo.Text = "<br />This sector has mercenaries (" + (sector as MercenarySector).Mercenaries.Length + ")";

                foreach (Sector s in player.Sectors)
                    drpSectors.Items.Add(new System.Web.UI.WebControls.ListItem(s.ToString(), s.Coordinate.ToString()));

                foreach (Unit u in player.Units)
                    if (drpSectors.Items.FindByValue(u.Sector.Coordinate.ToString()) == null)
                        drpSectors.Items.Add(new System.Web.UI.WebControls.ListItem("< " + u.Sector.ToString() + " >", u.Sector.Coordinate.ToString()));

                if (!Wc3o.Game.SelectByValue(drpSectors, sector.Coordinate.ToString()))
                    drpSectors.Items.Insert(0, new System.Web.UI.WebControls.ListItem("- " + sector.ToString() + " -", sector.Coordinate.ToString()));

                bool canAnnect = false;
                bool creepsOnSector = false;
                bool creepBuildingsOnSector = false;
                List<Player> l = new List<Player>();
                foreach (Unit u in sector.Units) {
                    if (u.Owner == null)
                        creepsOnSector = true;
                    else if (!l.Contains(u.Owner)) {
                        if (u.Owner == player && u.IsAvailable)
                            canAnnect = true;
                        l.Add(u.Owner);
                    }
                }

                if (canAnnect && !player.IsAlly(sector.Owner))
                    btnCapture.Visible = true;
                else
                    btnCapture.Visible = false;

                if (sector.Buildings.Count > 0)
                    if (sector.Owner == null)
                        creepBuildingsOnSector = true;
                    else if (!l.Contains(sector.Owner))
                        l.Add(sector.Owner);

                bool hasView = player.HasView(sector);

                foreach (Player p in l)
                    if (p == player)
                        lblPlayer.Text += "<div class='Player'><a href=\"javascript:LoadUnits('" + sector.Coordinate + "','')\"><b>Your units</b></a><br /><div id='u_' name='u_'></div></div>";
                    else if (p.IsAlly(player))
                        lblOthers.Text += "<div class='Ally'><a href=\"javascript:LoadSector('" + sector.Coordinate + "','" + p.Name + "')\"><b>" + p.FullName + "</b></a><br /><div id='u_" + p.Name + "' name='u_" + p.Name + "'></div><div id='b_" + p.Name + "' name='b_" + p.Name + "'></div></div><br />";
                    else if (hasView && player.CanAttack(p))
                        lblOthers.Text += "<div class='Enemy'><a href=\"javascript:LoadSector('" + sector.Coordinate + "','" + p.Name + "')\"><b>" + p.FullName + "</b></a><br /><div id='u_" + p.Name + "' name='u_" + p.Name + "'></div><div id='b_" + p.Name + "' name='b_" + p.Name + "'></div></div><br />";
                    else if (hasView)
                        lblOthers.Text += "<div class='League'><a href=\"javascript:LoadSector('" + sector.Coordinate + "','" + p.Name + "')\"><b>" + p.FullName + "</b></a><br /><div id='u_" + p.Name + "' name='u_" + p.Name + "'></div><div id='b_" + p.Name + "' name='b_" + p.Name + "'></div></div><br />";

                if (hasView && (creepsOnSector || creepBuildingsOnSector)) //creeps are represented as "-"
                    lblOthers.Text += "<div class='Neutral'><a href=\"javascript:LoadSector('" + sector.Coordinate + "','-')\"><b>Creeps</b></a><br /><br /><div id='u_-' name='u_-'></div><div id='b_-' name='b_-'></div></div><br />";

                if (sector.Owner == player) {
                    lblPlayer.Text += "<br /><div class='Player'><a href=\"javascript:LoadBuildings('" + sector.Coordinate + "','')\"><b>Your buildings</b></a><br /><div id='b_' name='b_'></div></div>";
                    lblPlayer.Text += "<br /><div class='Player'><a href=\"javascript:LoadTraining('" + sector.Coordinate + "')\"><b>Train units</b></a><br /><div id='training' name='training'></div></div>";
                    lblPlayer.Text += "<br /><div class='Player'><a href=\"javascript:LoadConstructing('" + sector.Coordinate + "')\"><b>Construct buildings</b></a><br /><div id='constructing' name='constructing'></div></div>";
                }

                if (sector is MercenarySector && player.IsAlly(sector.Owner))
                    lblPlayer.Text += "<br /><div class='Player'><a href=\"javascript:LoadMercenaries('" + sector.Coordinate + "')\"><b>Recruit mercenaries</b></a><br /><div id='divMercenaries' name='divMercenaries'></div></div>";

                if (!hasView)
                    lblOthers.Text = "<i>You have no view on this sector.</i>";
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:wc3o-svn,代码行数:101,代码来源:Sector.aspx.cs

示例3: Write

 public void Write(Sector sector, string entry, TraceEventType traceEventType)
 {
     byte[] message = Encoding.UTF8.GetBytes(Guid.NewGuid() + entry);
     string routingKey = string.Format("{0}.{1}.{2}", _clientId, sector.ToString(), traceEventType.ToString());
     _channel.BasicPublish("topic-exchange-example", routingKey, null, message);
     Console.WriteLine(String.Format("I am sending {0},{1}", routingKey, entry));
 }
开发者ID:dotnetdude,项目名称:playingwithRabbit,代码行数:7,代码来源:Program.cs


注:本文中的Sector.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。