示例#1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            TimerCtr++;
            TotalTime++;
            lblRX.Text         = NumReceived.ToString();
            progressBar1.Value = (int)PBValue;

            lblTXPercent.Text = PBValue.ToString() + "%";
            lblToRX.Text      = NumToRXInt.ToString();

            ETALeft     = new TimeSpan(((NumToRXInt - NumReceived) / 14400) * TimeSpan.TicksPerSecond);
            lblETA.Text = ETALeft.ToString();

            /* If NO data received */
            if (TimerCtr > 30 && ComPort1.IsOpen)
            {
                lblStat.Parent.Invoke((MethodInvoker) delegate { lblStat.Text = "RX error."; lblStat.ForeColor = Color.Red; });
                ModifyProgressBarColor.SetState(progressBar1, 2); // 2 = red
                try {
                    ComPort1.Close();
                }
                catch
                {
                }

                b.Close();
            }
        }
示例#2
0
        // Method that triggers when the player takes damage or is healed (e.g. by resting)

        void playerDamaged()
        {
            lblHealthPlayer.Text = prgHealthPlayer.Value + " / " + playerMaxHP; // Change the health counter to reflect the new value

            // The code below uses my custom ColourProgressBar class. You can find the source for the code I borrowed in ColourProgressBar.cs.

            // If the player has less than half their health remaining but more than 1/5, set the ProgressBar to a yellow state
            if (prgHealthPlayer.Value < prgHealthPlayer.Maximum / 2 && prgHealthPlayer.Value > prgHealthPlayer.Maximum / 5)
            {
                ModifyProgressBarColor.SetState(prgHealthPlayer, 3);
            }
            // If the player has less than or equal to 1/5 of their health remaining, set the ProgressBar to a red state
            else if (prgHealthPlayer.Value <= prgHealthPlayer.Maximum / 5)
            {
                ModifyProgressBarColor.SetState(prgHealthPlayer, 2);
            }
            // Make sure it's green while >= half maximum health
            // Note: Leave this as an else if statement, as the math is imperfect and it will appear as green when healing while health is low.
            else if (prgHealthPlayer.Value >= prgHealthPlayer.Maximum / 2)
            {
                ModifyProgressBarColor.SetState(prgHealthPlayer, 1);
            }

            // This is all that happens when your health depletes to 0 for now
            if (prgHealthPlayer.Value == 0)
            {
                tmrPlayerHealthDecay.Stop();
                MessageBox.Show("YOU DIED. Click OK to cheat death and continue to battle against " + lblNameEnemy + ".\r\n\r\nPROTIP: Heal yourself by clicking REST and you literally cannot die in this demo. That way you can avoid this annoying death message!", "0 health");
            }
        }
示例#3
0
        private void BtnDump_Click(object sender, EventArgs e)
        {
            ComPort1.PortName = CmbPorts.Text;
            t = new Thread(ReceiveThread);
            t.Start();

            try
            {
                ComPort1.Open();
                TimerCtr       = 0;
                TotalTime      = 0;
                timer1.Enabled = true;
                ComPort1.DiscardInBuffer();
                ETALeft = new TimeSpan(0);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            /* Get the current Data and Time to use for filename */
            DTRightNow = DateTime.Now;

            DumpFileName = DTRightNow.Year.ToString() + "_" + DTRightNow.Month.ToString() + "_" + DTRightNow.Day.ToString() + "T" + DTRightNow.Hour.ToString() + "_" + DTRightNow.Minute.ToString() + "_" + DTRightNow.Second.ToString() + ".wrdt";

            SaveDefaultDirectory = "C:\\Users\\Surya\\Dropbox\\Education\\BiteCounter\\NewAppDump\\";


            lblFileName.Text = DumpFileName;
            /* Write to the file */


            b = new BinaryWriter(File.Open(SaveDefaultDirectory + DumpFileName, FileMode.Create));
            ModifyProgressBarColor.SetState(progressBar1, 1); // 1 = Green

            /* Open the Serial Port */
            NumReceived  = 0;
            NumToReceive = 0;

            /* The "Send Data" sd command */
            ComPort1.Write("sd");
            Thread.Sleep(200);
            ComPort1.Write("ab");
            Thread.Sleep(200);
            ComPort1.Write("cd");
            Command = true;
            runThread.Set();
            lblStat.Parent.Invoke((MethodInvoker) delegate { lblStat.Text = "Command Sent"; lblStat.ForeColor = Color.Green; });
        }
示例#4
0
 public Form1()
 {
     InitializeComponent();
     ModifyProgressBarColor.SetState(PlayerLifeBar, 2);
     playSimpleSound();
     foreach (Control x in this.Controls)
     {
         if (x is PictureBox && x.Tag == "invaders" || x.Tag == "invaders2")
         {
             Enemies.Add(x);
         }
     }
     startGame();
 }
示例#5
0
        // Same thing but for the enemy. Enemy currently cannot gain health / heal, so that part is left out

        void enemyDamaged()
        {
            lblHealthEnemy.Text = prgHealthEnemy.Value + " / " + prgHealthEnemy.Maximum; // Change the health counter to reflect the new value
            if (prgHealthEnemy.Value < prgHealthEnemy.Maximum / 2 && prgHealthEnemy.Value > prgHealthEnemy.Maximum / 5)
            {
                ModifyProgressBarColor.SetState(prgHealthEnemy, 3);
            }
            else if (prgHealthEnemy.Value < prgHealthEnemy.Maximum / 5)
            {
                ModifyProgressBarColor.SetState(prgHealthEnemy, 2);
            }

            // It is best to set the enemy to be dead here
            if (prgHealthEnemy.Value == 0)
            {
                enemyDead = true;
            }
        }
示例#6
0
        void wc_DownloadCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            int index = _webClients.IndexOf((WebClient)sender);

            if (index >= 0)
            {
                //progressBars[index].Enabled = false;
                _finished[index] = true;
                if (e.Error == null && !e.Cancelled)
                {
                    _labels[index].Text = "✔ " + _files[index];
                    ModifyProgressBarColor.SetState(_progressBars[index], 3);
                }
                else
                {
                    _labels[index].Text        = "✖ " + _files[index];
                    _progressBars[index].Value = _progressBars[index].Maximum;
                    File.Delete(_paths[index] + _files[index]);
                    ModifyProgressBarColor.SetState(_progressBars[index], 2);
                }
                bool allFinished = true;
                foreach (bool finish in _finished)
                {
                    if (!finish)
                    {
                        allFinished = false;
                    }
                }
                if (allFinished)
                {
                    if ((Form)this != Form.ActiveForm)
                    {
                        downloadFinishedNotification.Visible = true;
                        downloadFinishedNotification.ShowBalloonTip(2000);
                    }
                    _parentform.ReloadMedia();
                    _parentform.AllowClosing();
                }
            }
        }
示例#7
0
        void contexMenu_RestartItemClicked(object sender, EventArgs e)
        {
            int index = _restartItems.IndexOf((ToolStripItem)sender);

            if (index >= 0)
            {
                if (!_webClients[index].IsBusy)
                {
                    ModifyProgressBarColor.SetState(_progressBars[index], 1);
                    _progressBars[index].Value = _progressBars[index].Minimum;
                    _labels[index].Text        = _files[index];
                    panelDownloads.ScrollControlIntoView(_progressBars[index]);
                    _startTimes[index] = DateTime.Now;
                    using (_webClients[index])
                    {
                        _webClients[index].DownloadProgressChanged += wc_DownloadProgressChanged;
                        _webClients[index].DownloadFileCompleted   += wc_DownloadCompleted;
                        _webClients[index].DownloadFileAsync(new System.Uri(_URIs[index]), _paths[index] + _files[index]);
                    }
                    _finished[index] = false;
                    _parentform.DisAllowClosing();
                }
            }
        }
        public virtual void receberDano(ProgressBar pb, int dano)
        {
            podeAtacar = false;

            ModifyProgressBarColor.SetState(pb, 2);
            tmrBatalha.Stop();
            newLabel lblDaninho = new newLabel();

            lblDaninho.Text        = "-" + dano.ToString();
            lblDaninho.ForeColor   = Color.Red;
            lblDaninho.BackColor   = Color.White;
            lblDaninho.Font        = new Font(frmJogo.FONTE, 20);
            lblDaninho.Height      = pb.Height;
            lblDaninho.RotateAngle = -90;
            background.Frm.Controls.Add(lblDaninho);

            if (pb.Location.X > Convert.ToInt32(background.Frm.Width / 2))
            {
                lblDaninho.Location = new Point(pb.Location.X - lblDaninho.Width, pb.Location.Y);
            }
            else
            {
                lblDaninho.Location = new Point(pb.Location.X + pb.Width, pb.Location.Y);
            }

            int i = 0;

            while (i <= dano)
            {
                pb.Value--;

                if (pb.Value == 0)
                {
                    if (pb.Equals(pbVidaHeroi))
                    {
                        ganhou = 2;
                    }
                    else
                    {
                        ganhou = 1;
                    }
                    background.Frm.Controls.Remove(lblDaninho);
                    terminarBatalha();
                    return;
                }
                else
                {
                    Application.DoEvents();
                    Thread.Sleep(20);
                    i++;
                }
            }

            podeAtacar = true;

            ModifyProgressBarColor.SetState(pb, 1);

            lblContinha.Text  = this.gerarConta();
            lblResultado.Text = "";
            background.Frm.Controls.Remove(lblDaninho);

            tmrBatalha.Start();
        }
        public void carregarGame()
        {
            background.Frm.Controls.Add(pbVidaVilao);
            pbVidaVilao.Maximum  = 100;
            pbVidaVilao.Minimum  = 0;
            pbVidaVilao.Enabled  = true;
            pbVidaVilao.Location = new Point(75, 72);
            pbVidaVilao.Width    = 320;
            pbVidaVilao.Height   = 40;
            pbVidaVilao.Value    = 100;

            background.Frm.Controls.Add(pbVidaHeroi);
            pbVidaHeroi.Maximum  = 100;
            pbVidaHeroi.Minimum  = 0;
            pbVidaHeroi.Enabled  = true;
            pbVidaHeroi.Location = new Point(410, 360);
            pbVidaHeroi.Width    = 320;
            pbVidaHeroi.Height   = 40;
            pbVidaHeroi.Value    = 100;

            background.Frm.Controls.Add(lblContinha);
            lblContinha.Width     = 500;
            lblContinha.Text      = "[Enter] para comecar!";
            lblContinha.Location  = new Point((background.Frm.Width - lblContinha.Width) / 2, 470);
            lblContinha.ForeColor = Color.Black;
            lblContinha.BackColor = Color.White;
            lblContinha.TextAlign = ContentAlignment.MiddleCenter;
            lblContinha.Dock      = DockStyle.None;
            lblContinha.Font      = new Font(frmJogo.FONTE, 18);
            lblContinha.Height    = 50;

            background.Frm.Controls.Add(lblResultado);
            lblResultado.Height      = 70;
            lblResultado.Width       = 350;
            lblResultado.Location    = new Point((background.Frm.Width - lblResultado.Width) / 2, 530);
            lblResultado.Text        = "inicio";
            lblResultado.AutoSize    = false;
            lblResultado.TextAlign   = ContentAlignment.MiddleCenter;
            lblResultado.Dock        = DockStyle.None;
            lblResultado.BorderStyle = BorderStyle.FixedSingle;
            lblResultado.BackColor   = Color.White;
            lblResultado.ForeColor   = Color.Black;
            lblResultado.Font        = new Font(frmJogo.FONTE, 18);
            lblResultado.Visible     = false;

            background.Frm.Controls.Add(pbTempo);
            pbTempo.Width    = 730;
            pbTempo.Height   = 25;
            pbTempo.Location = new Point((background.Frm.Width - pbTempo.Width) / 2, 10);
            pbTempo.Maximum  = 100;
            pbTempo.Minimum  = 0;
            pbTempo.Value    = 100;
            pbTempo.Enabled  = true;
            ModifyProgressBarColor.SetState(pbTempo, 3);

            tmrBatalha          = new System.Windows.Forms.Timer();
            tmrBatalha.Interval = 140 / this.background.Dificuldade;
            tmrBatalha.Tick    += new EventHandler(batalha_tick);

            carregarImg(@"batalha1.png");

            contas = new Queue <string>();
        }
示例#10
0
        private async void copyToDesktop()
        {
            string _name     = (string)cbxGames.SelectedItem;
            string startPath = lGames.Find(x => x.name == _name).gamePath;
            string zipPath   = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), lGames.Find(x => x.name == _name).name.Replace(":", "_") + ".zip");

            if (Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)).Contains(zipPath))
            {
                lblStatus.Text = "Archive already existing!";
                return;
            }
            #region print Layout
            int index = Array.IndexOf(simultaniousZippings, 0);
            if (index == -1)
            {
                lblStatus.Text = "Please wait till the queue is empty.";
                return;
            }
            simultaniousZippings[index] = 1;
            if (index >= 5)
            {
                this.Height += 25;
                this.Refresh();
            }
            Label l = new Label();
            l.AutoSize  = true;
            l.Text      = cbxGames.Text;
            l.ForeColor = Color.White;
            ProgressBar p = new ProgressBar();
            p.Name = "pb" + index;
            ModifyProgressBarColor.SetState(p, 2);
            l.Location = new Point(110, 100 + (25 * index) + 10);
            p.Location = new Point(10, 100 + (25 * index) + 5);
            p.Show();
            p.Visible     = true;
            p.Value       = 0;
            p.MouseClick += new MouseEventHandler(cancelProgress);
            this.Controls.Add(p);
            this.Controls.Add(l);
            #endregion
            lblStatus.Text = "Creating Zip-File...";
            CancellationTokenSource cts = new CancellationTokenSource();
            if (lCancel.ContainsKey(p.Name))
            {
                lCancel[p.Name] = cts;
            }
            else
            {
                lCancel.Add(p.Name, cts);
            }
            await Task.Factory.StartNew(() => createZipArchive(startPath, zipPath, p, l, _name, cts.Token));

            lblStatus.Text = "Adding acf-File...";
            await Task.Factory.StartNew(() => addConfigToZipArchive(zipPath, _name, cts.Token));

            lblStatus.Text = lGames.Count + " Games found in " + steamPath;
            #region Recreate Layout
            if (index >= 5)
            {
                this.Height -= 25;
                this.Refresh();
            }
            this.Controls.Remove(p);
            this.Controls.Remove(l);
            #endregion
            simultaniousZippings[index] = 0;
            if (cts.IsCancellationRequested)
            {
                File.Delete(zipPath);
            }
        }
示例#11
0
 private void radioButton5_Click(object sender, EventArgs e)
 {
     ModifyProgressBarColor.SetState(pbSecond, 2);
 }
示例#12
0
        private void frmBattle_Load(object sender, EventArgs e)
        {
            resetButtons();
            playerTurn();                                                    // Make sure it's the player's turn, just in case. You always get to go first.

            lblNamePlayer.Text        = SaveGames.SaveSystem.name.ToUpper(); // Convert the user's saved name to uppercase and display it
            picPortraitEnemy.Location = new Point(437, 30);

            // Using a ResourceManager simplifies having to declare each image for each array value manually
            for (int i = 0; i < picHealingBeams.Length; i++)
            {
                picHealingBeams[i] = (Image)Properties.Resources.ResourceManager.GetObject("imgBeam" + i.ToString("D2"));
            }

            picHealingBeam.Size = new Size(255, 218);
            ModifyProgressBarColor.SetState(prgHealthEnemy, 1);
            tmrGameTicker.Start();
            prgHealthPlayer.Maximum = prgHealthPlayer.Value = 80;

            switch (LevelGen.difficulty)
            {
            case 1:
                prgHealthEnemy.Value   = prgHealthEnemy.Maximum = 80;
                picPortraitEnemy.Image = Properties.Resources.imgCultistAlive;
                enemyDamaged();
                lblNameEnemy.Text = "HOODED FIGURE";
                break;

            case 2:
                prgHealthEnemy.Value   = prgHealthEnemy.Maximum = 100;
                picPortraitEnemy.Image = Properties.Resources.imgRabbitAlive;
                enemyDamaged();
                lblNameEnemy.Text = "RABID RABBIT";
                break;

            case 3:
                prgHealthEnemy.Value   = prgHealthEnemy.Maximum = 120;
                picPortraitEnemy.Image = Properties.Resources.imgHammerAlive;
                enemyDamaged();
                lblNameEnemy.Text = "GHOSTLY HAMMER";
                break;

            case 4:
                prgHealthEnemy.Value   = prgHealthEnemy.Maximum = 150;
                picPortraitEnemy.Image = Properties.Resources.imgDoppelAlive;
                enemyDamaged();
                lblNameEnemy.Text = "DOPPELGANGER";
                break;

            case 5:
                prgHealthEnemy.Value   = prgHealthEnemy.Maximum = 200;
                picPortraitEnemy.Image = Properties.Resources.imgZeusAlive;
                enemyDamaged();
                lblNameEnemy.Text = "ZEUS";
                break;

            default:
                //
                break;
            }
        }
示例#13
0
 // Cheat, reducing enemy health to 10.
 private void btnBuddha_Click(object sender, EventArgs e)
 {
     prgHealthEnemy.Value = 10;
     lblHealthEnemy.Text  = "10 / " + prgHealthEnemy.Maximum;
     ModifyProgressBarColor.SetState(prgHealthEnemy, 2);
 }