Exemple #1
0
        public static void Place(Form form)
        {
            System.Drawing.Point newPos = new System.Drawing.Point();

            if (curControl.Visible)
            {
                System.Drawing.Point mousePos = form.PointToClient(Cursor.Position);

                newPos.X = (mousePos.X / 32) * 32;
                newPos.Y = (mousePos.Y / 32) * 32;

                curControl.Location = newPos;
                curControl.BringToFront();

                if (curControl.Location.X < 32 * 32 && curControl.Location.Y < (16 * 32))
                {
                    for (int i = 0; i < Terrain.numRoadTiles - 1; i++)
                    {
                        if (i == 1)
                        {
                            continue;
                        }

                        var a = form.Controls.Find("Road" + i.ToString(), false)[0].Location;

                        if (form.Controls.Find("Road" + i, false)[0].Location == curControl.Location)
                        {
                            return;
                        }
                    }

                    foreach (Turrets turret in form.Controls.Find("Tower", false))
                    {
                        if (turret.Location == curControl.Location)
                        {
                            return;
                        }
                    }

                    Turrets newTurret = new Turrets(curControlCount);
                    newTurret.ShootingTimer = new Stopwatch();
                    newTurret.ShootingTimer.Start();

                    newTurret.Location = newPos;

                    form.Controls.Add(newTurret);
                    newTurret.BringToFront();

                    curControl.Enabled = false;
                    curControl.Visible = false;
                }
            }
        }
Exemple #2
0
        private void btnUpgradeTower1_Click(object sender, EventArgs e)
        {
            btnUpgradeTower1.Enabled = false;

            Player.Gold = Player.Gold - upgrade1;
            upgrade1   += 200;
            this.Controls["btnUpgradeTower1"].Text = "Tier " + count1 + " Upgrade " + upgrade1 + "gp";
            Turrets.UpdateUpgrade(this, 1, 10);

            count1++;
            if (count1 == 6)
            {
                btnUpgradeTower1.Text = "Fully upgraded!";
            }
        }
Exemple #3
0
        private void btnUpgradeTower4_Click(object sender, EventArgs e)
        {
            btnUpgradeTower4.Enabled = false;


            Player.Gold = Player.Gold - upgrade2;
            upgrade4   += 800;
            this.Controls["btnUpgradeTower4"].Text = "Tier " + count4 + " Upgrade " + upgrade4 + "gp";
            Turrets.UpdateUpgrade(this, 4, 30);

            count4++;
            if (count4 == 6)
            {
                btnUpgradeTower4.Text = "Fully upgraded!";
            }
        }
Exemple #4
0
        private void btnUpgradeTower3_Click(object sender, EventArgs e)
        {
            btnUpgradeTower3.Enabled = false;


            Player.Gold = Player.Gold - upgrade2;
            upgrade3   += 600;
            this.Controls["btnUpgradeTower3"].Text = "Tier " + count3 + " Upgrade " + upgrade3 + "gp";
            Turrets.UpdateUpgrade(this, 3, 64);

            count3++;
            if (count3 == 6)
            {
                btnUpgradeTower3.Text = "Fully upgraded!";
            }
        }
Exemple #5
0
        private void btnUpgradeTower2_Click(object sender, EventArgs e)
        {
            btnUpgradeTower2.Enabled = false;


            Player.Gold = Player.Gold - upgrade2;
            upgrade2   += 400;
            this.Controls["btnUpgradeTower2"].Text = "Tier " + count2 + " Upgrade " + upgrade2 + "gp";
            Turrets.UpdateUpgrade(this, 2, 40);

            count2++;
            if (count2 == 6)
            {
                btnUpgradeTower2.Text = "Fully upgraded!";
            }
        }
Exemple #6
0
        public static void CreateProjectile(Form form, Monster enemy, Turrets turret)
        {
            Projectile projectile = new Projectile();

            projectile.Location      = turret.Location;
            projectile.targetMonster = enemy;
            projectile.Damage        = turret.Damage;
            projectile.targetPoint   = projectile.CalcTargetPoint(form);

            form.Controls.Add(projectile);

            projectile.BringToFront();

            Projectiles.Add(projectile);

            turret.ShootingTimer.Start();
        }
Exemple #7
0
        public static void Buy(Form form, string controlName)
        {
            var money = form.Controls[controlName + "Price"].Text;

            if (Int32.Parse(money.Substring(0, 3)) <= Player.Gold)
            {
                curControl = form.Controls["BoughtTurret"] as Turrets;

                Player.Gold -= Int32.Parse(money.Substring(0, 3));

                curControl.Image = (form.Controls[controlName] as PictureBox).Image;
                curControl.Show();
                curControl.Enabled = true;

                curControlCount = (int)Char.GetNumericValue(controlName[11]);
            }
        }