示例#1
0
        public PwBar()
        {
            InitializeComponent();
            tas = Program.TasClient;
            timerLabel.AutoSize = true;
            headerLabel.AutoSize = true;

            timer = new Timer();
            timer.Interval = 1000;
            timer.Tick += (sender, args) =>
            {
                if (Program.NotifySection.Contains(this)) timerLabel.Text = ZkData.Utils.PrintTimeRemaining((int)deadline.Subtract(DateTime.Now).TotalSeconds);
            };
            timer.Start();

            pnl.Controls.Add(timerLabel);
            pnl.Controls.Add(headerLabel);

            tas.Extensions.JsonDataReceived += (sender, e) =>
            {
                var newPw = e as PwMatchCommand;
                if (newPw != null)
                {
                    pw = newPw;
                    UpdateGui();
                }
            };

            tas.MyExtensionsChanged += (sender, args) => UpdateGui();
        }
示例#2
0
 void AddButtonClick(PwMatchCommand.VoteOption opt, Button but)
 {
     PwMatchCommand.VoteOption opt1 = opt;
     but.Click += (s2, ev) =>
     {
         if (Program.SpringScanner.HasResource(opt1.Map)) tas.Say(SayPlace.User, GlobalConst.NightwatchName, "!" + opt1.PlanetID, true);
         else tas.Say(SayPlace.Channel, tas.MyUser.Faction, string.Format("wants to play {0}, but lacks the map..", opt1.PlanetID), true);
     };
 }
            public PwMatchCommand.VoteOption ToVoteOption(PwMatchCommand.ModeType mode)
            {
                var opt = new PwMatchCommand.VoteOption
                {
                    PlanetID = PlanetID,
                    PlanetName = Name,
                    Map = Map,
                    Count = mode == PwMatchCommand.ModeType.Attack ? Attackers.Count : Defenders.Count,
                    Needed = TeamSize
                };

                return opt;
            }
 public PwMatchCommand GenerateLobbyCommand()
 {
     PwMatchCommand command;
     if (Challenge == null)
     {
         command = new PwMatchCommand(PwMatchCommand.ModeType.Attack)
         {
             Options = AttackOptions.Select(x => x.ToVoteOption(PwMatchCommand.ModeType.Attack)).ToList(),
             DeadlineSeconds = (int)GetAttackDeadline().Subtract(DateTime.UtcNow).TotalSeconds,
             AttackerFaction = AttackingFaction.Shortcut
         };
     }
     else
     {
         command = new PwMatchCommand(PwMatchCommand.ModeType.Defend)
         {
             Options = new List<PwMatchCommand.VoteOption> { Challenge.ToVoteOption(PwMatchCommand.ModeType.Defend) },
             DeadlineSeconds = (int)GetAcceptDeadline().Subtract(DateTime.UtcNow).TotalSeconds,
             AttackerFaction = AttackingFaction.Shortcut,
             DefenderFactions = GetDefendingFactions(Challenge).Select(x => x.Shortcut).ToList()
         };
     }
     return command;
 }