public TanksGame(MainMenuForm mainMenu)
        {
            InitializeComponent();

            buttons.Add(level1Button);
            buttons.Add(level2Button);
            buttons.Add(level3Button);
            buttons.Add(level4Button);
            this.mainMenu = mainMenu;

            gameStatus = GAME_STATUS.LEVEL_SELECT;
            Size       = new Size(350, 150);

            TanksGame.gameRef = this;
        }
Esempio n. 2
0
        public Bullet(BULLET_TYPE bulletType, DIRECTION direction, Point location)
        {
            InitializeComponent();
            SetTopLevel(false);

            this.direction  = direction;
            this.game       = TanksGame.gameRef;
            this.bulletType = bulletType;

            Location = location;
            Size     = new Size(TanksGame.bulletWidth, TanksGame.bulletHeight);

            step      = 15;
            stepTimer = 150;

            move();
        }
Esempio n. 3
0
        private int stepTimer; // ms

        public CompTank(TANK_TYPE type, SPEED_LEVEL speedLevel, Point spot)
        {
            InitializeComponent();
            SetTopLevel(false);
            AutoSize = false;

            this.type       = type;
            this.speedLevel = speedLevel;
            this.game       = TanksGame.gameRef;

            speedInit();
            shape();

            Location = spot;
            Size     = new Size(TanksGame.tankWidth, TanksGame.tankHeight);

            walkAndAttackWorker.RunWorkerAsync();
        }
        private int step; // pxl

        public UserTank(TANK_TYPE type, SPEED_LEVEL speedLevel, Point spot)
        {
            InitializeComponent();
            SetTopLevel(false);
            AutoSize = false;
            Enabled  = true;

            this.type       = type;
            this.speedLevel = speedLevel;
            this.game       = TanksGame.gameRef;

            step      = 20;
            direction = DIRECTION.U;

            shape();
            Location = spot;
            Size     = new Size(TanksGame.tankWidth, TanksGame.tankHeight);
        }
Esempio n. 5
0
 private void tanksGameButton_Click(object sender, EventArgs e)
 {
     tanks.TanksGame tanks = new tanks.TanksGame(this);
     tanks.Show();
     Hide();
 }
Esempio n. 6
0
        private void walkAndAttackWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            Random rnd = new Random();

            while (true)
            {
                direction = (DIRECTION)(rnd.Next() % 4);
                int isNeedShot = rnd.Next() % 3000;

                if (isNeedShot < 1000)
                {
                    TanksGame.ShootKeyDown(Keys.B);
                }

                switch (direction)
                {
                case DIRECTION.U:
                    BackgroundImage = Properties.Resources.light_ctank_u;

                    Point newUpLoc = new Point(Location.X, Location.Y - step);
                    if (newUpLoc.Y <= 0)
                    {
                        break;
                    }

                    Location = newUpLoc;
                    break;

                case DIRECTION.D:
                    BackgroundImage = Properties.Resources.light_ctank_d;

                    Point newDownLoc = new Point(Location.X, Location.Y + step);
                    if (newDownLoc.Y >= 600)
                    {
                        break;
                    }

                    Location = newDownLoc;
                    break;

                case DIRECTION.L:
                    BackgroundImage = Properties.Resources.light_ctank_l;

                    Point newLeftLoc = new Point(Location.X - step, Location.Y);
                    if (newLeftLoc.X <= 0)
                    {
                        break;
                    }

                    Location = newLeftLoc;
                    break;

                case DIRECTION.R:
                    BackgroundImage = Properties.Resources.light_ctank_r;

                    Point newRightLoc = new Point(Location.X + step, Location.Y);
                    if (newRightLoc.X >= 1200)
                    {
                        break;
                    }

                    Location = newRightLoc;
                    break;
                }

                Thread.Sleep(stepTimer);
            }
        }
Esempio n. 7
0
        private void CompTanksAction_Tick(object sender, EventArgs e)
        {
            Random rnd = new Random();

            foreach (var tank in compTanks)
            {
                if (tank.IsDisposed)
                {
                    break;
                }

                tank.direction = (DIRECTION)(rnd.Next() % 4);
                int isNeedShot = rnd.Next() % 5000;

                if (isNeedShot < 2500 && isCompReadyToShoot == true)
                {
                    isCompReadyToShoot = false;
                    TanksGame.ShootKeyDown(Keys.B);
                }

                switch (tank.direction)
                {
                case DIRECTION.U:
                    tank.BackgroundImage = Properties.Resources.light_ctank_u;

                    Point newUpLoc = new Point(tank.Location.X, tank.Location.Y - compTankStep);
                    if (newUpLoc.Y <= 0)
                    {
                        break;
                    }

                    tank.Location = newUpLoc;
                    break;

                case DIRECTION.D:
                    tank.BackgroundImage = Properties.Resources.light_ctank_d;

                    Point newDownLoc = new Point(tank.Location.X, tank.Location.Y + compTankStep);
                    if (newDownLoc.Y >= 600)
                    {
                        break;
                    }

                    tank.Location = newDownLoc;
                    break;

                case DIRECTION.L:
                    tank.BackgroundImage = Properties.Resources.light_ctank_l;

                    Point newLeftLoc = new Point(tank.Location.X - compTankStep, tank.Location.Y);
                    if (newLeftLoc.X <= 0)
                    {
                        break;
                    }

                    tank.Location = newLeftLoc;
                    break;

                case DIRECTION.R:
                    tank.BackgroundImage = Properties.Resources.light_ctank_r;

                    Point newRightLoc = new Point(tank.Location.X + compTankStep, tank.Location.Y);
                    if (newRightLoc.X >= 1200)
                    {
                        break;
                    }

                    tank.Location = newRightLoc;
                    break;
                }
            }
        }