Beispiel #1
0
        int shootInterval;                                            //интервал между выстрелами вражеских танков

        public EnemyTank(int x, int y, int dx, int dy, moveDirectionEnum dir, tankTeam team)
            : base(x, y, dx, dy, dir, team)
        {
            if (team == tankTeam.enemy_rap || team == tankTeam.enemy_imba)
            {
                Speed = 4;
            }
            else
            {
                Speed = 2;
            }
            if (team == tankTeam.enemy_arm || team == tankTeam.enemy_imba)
            {
                hp = 3;
            }
            else
            {
                hp = 1;
            }
            if (team == tankTeam.enemy_rf || team == tankTeam.enemy_imba)
            {
                shootInterval = 15;
            }
            else
            {
                shootInterval = 40;
            }
            shootIter = 0;
            iterChDir = 0;
            #region выбор картинки
            switch (team)
            {
            case tankTeam.enemy_norm:
                TBIT = enemyNormBit;
                TBIT.RotateFlip(RotateFlipType.RotateNoneFlipY);
                break;

            case tankTeam.enemy_rap:
                TBIT = enemyRapBit;
                TBIT.RotateFlip(RotateFlipType.RotateNoneFlipY);
                break;

            case tankTeam.enemy_arm:
                TBIT = enemyArmBit;
                TBIT.RotateFlip(RotateFlipType.RotateNoneFlipY);
                break;

            case tankTeam.enemy_rf:
                TBIT = enemyRFBit;
                TBIT.RotateFlip(RotateFlipType.RotateNoneFlipY);
                break;

            case tankTeam.enemy_imba:
                TBIT = enemyImbBit;
                TBIT.RotateFlip(RotateFlipType.RotateNoneFlipY);
                break;
            }
            #endregion
        }
Beispiel #2
0
        public bool immob;                                     //может ли свой танк двигаться

        public MyTank(int x, int y, int dx, int dy, moveDirectionEnum dir, tankTeam team)
            : base(x, y, dx, dy, dir, team)
        {
            Speed = 2;
            hp    = 3;
            shot  = true;
            TBIT  = MyTankBit;
        }
Beispiel #3
0
    public void Fire(float damage, tankTeam team)
    {
        GameObject boolet = Instantiate(bullet, firePoint.transform.position, firePoint.transform.rotation);

        boolet.GetComponent <bulletInteract>().damage = (int)damage;
        boolet.GetComponent <bulletInteract>().team   = team;
        Rigidbody2D rb = boolet.GetComponent <Rigidbody2D>();

        rb.AddForce(firePoint.transform.up * bulletforce, ForceMode2D.Impulse);
    }
Beispiel #4
0
 public Tank(int x, int y, int dx, int dy, moveDirectionEnum dir, tankTeam team)
 {
     this.x      = x;
     this.y      = y;
     this.dx     = dx;
     this.dy     = dy;
     ice         = false;
     this.dir    = dir;
     changeDir   = false;
     previousDir = dir;
     this.team   = team;
     removed     = false;
     checkVar    = checkVarEnum.barNo;
 }
Beispiel #5
0
        private void CreateTanks() //создание вражеских танков. возможно, стоит перенести в Tank.cs
        {
            Random rand      = new Random((int)DateTime.Now.Ticks & 0x0000FFFF);
            int    respPoint = rand.Next(4); //рандомная точка респауна
            int    randTeam;                 //рандомный тип танка

            do
            {
                randTeam = rand.Next(5);
            }while (Tank.TankQuantityArr[randTeam] == 0);                                                                   //если танков это типа не осталось, повторяем заново
            Tank.TankQuantityArr[randTeam]--;                                                                               //уменьшение количества танков выбранного типа
            tankTeam team = (tankTeam)(randTeam + 1);                                                                       //получение константы из перечисления по значению

            RespawnList.Add(new Respawn(team, respawnArr[respPoint, 0] * 16, respawnArr[respPoint, 1] * 16, 32, 32, 0, 1)); //создание нового респауна и добавление его в массив
        }
Beispiel #6
0
    public GameObject NearTarg(tankTeam team)
    {
        GameObject currentClosest = null;

        if (team == tankTeam.red)
        {
            for (int i = 0; i < teams.blue.Length; i++)
            {
                if (teams.blue[i] != null)
                {
                    if (i == 0)
                    {
                        currentClosest = teams.blue[0];
                    }
                    else if (Vector2.Distance(teams.blue[i].transform.position, transform.position) < Vector2.Distance(teams.blue[i - 1].transform.position, transform.position))
                    {
                        currentClosest = teams.blue[i];
                    }
                }
            }
        }
        else if (team == tankTeam.blue)
        {
            for (int i = 0; i < teams.red.Length; i++)
            {
                if (teams.red[i] != null)
                {
                    if (i == 0)
                    {
                        currentClosest = teams.red[0];
                    }
                    else if (Vector2.Distance(teams.red[i].transform.position, transform.position) < Vector2.Distance(teams.red[i - 1].transform.position, transform.position))
                    {
                        currentClosest = teams.red[i];
                    }
                }
            }
        }

        return(currentClosest);
    }
Beispiel #7
0
        public Rectangle toRect;   //прямоугольник, в котором нужно нарисовать взрыв на карте

        public Respawn(tankTeam team, int x, int y, int dx, int dy, byte iter, byte typeIndex)
        {
            this.team = team;
            this.x    = x;
            this.y    = y;
            this.dx   = dx;
            this.dy   = dy;
            Iter      = iter;
            IterIncr  = 0;
            removed   = false;
            fromRect  = new Rectangle(0, 0, 32, 32);
            toRect    = new Rectangle(x, y, dx, dy);
            //выбор картинки в зависимости от типа респауна
            if (typeIndex == 1)
            {
                RBIT = EnRespBit;
            }
            if (typeIndex == 2)
            {
                RBIT = MyRespBit;
            }
        }