Ejemplo n.º 1
0
        public Bullet(Texture2D sprite, string direction, Vector2 tankCenterPosition, BulletType type, BulletSpeed bulletSpeed,
                      BulletPower bulletPower, int tankNumber)
        {
            this.sprite      = sprite;
            this.direction   = direction;
            this.type        = type;
            this.bulletPower = bulletPower;
            this.tankNumber  = tankNumber;

            speed = (bulletSpeed == BulletSpeed.Fast) ? GameConstants.BULLET_SPEED_FAST : GameConstants.BULLET_SPEED;

            switch (direction)
            {
            case "Left":
                sourceRectangle = new Rectangle(GameConstants.TILE_WIDTH * 4, 0,
                                                GameConstants.BULLET_HEIGHT, GameConstants.BULLET_WIDTH);
                drawRectangle = new Rectangle(
                    (int)tankCenterPosition.X - GameConstants.TILE_WIDTH / 2,
                    (int)tankCenterPosition.Y - GameConstants.BULLET_WIDTH / 2,
                    GameConstants.BULLET_HEIGHT, GameConstants.BULLET_WIDTH
                    );
                break;

            case "Right":

                sourceRectangle = new Rectangle(GameConstants.TILE_WIDTH * 4 + GameConstants.BULLET_HEIGHT, 0,
                                                GameConstants.BULLET_HEIGHT, GameConstants.BULLET_WIDTH);
                drawRectangle = new Rectangle(
                    (int)tankCenterPosition.X + GameConstants.TILE_WIDTH / 2 - GameConstants.BULLET_HEIGHT,
                    (int)tankCenterPosition.Y - GameConstants.BULLET_WIDTH / 2,
                    GameConstants.BULLET_HEIGHT, GameConstants.BULLET_WIDTH
                    );
                break;

            case "Up":

                sourceRectangle = new Rectangle(GameConstants.TILE_WIDTH * 4 + GameConstants.BULLET_HEIGHT * 2, 0,
                                                GameConstants.BULLET_WIDTH, GameConstants.BULLET_HEIGHT);
                drawRectangle = new Rectangle(
                    (int)tankCenterPosition.X - GameConstants.BULLET_WIDTH / 2,
                    (int)tankCenterPosition.Y - GameConstants.TILE_WIDTH / 2,
                    GameConstants.BULLET_WIDTH, GameConstants.BULLET_HEIGHT
                    );
                break;

            case "Down":

                sourceRectangle = new Rectangle(GameConstants.TILE_WIDTH * 4 + GameConstants.BULLET_HEIGHT * 2 + GameConstants.BULLET_WIDTH, 0,
                                                GameConstants.BULLET_WIDTH, GameConstants.BULLET_HEIGHT);
                drawRectangle = new Rectangle(
                    (int)tankCenterPosition.X - GameConstants.BULLET_WIDTH / 2,
                    (int)tankCenterPosition.Y + GameConstants.TILE_WIDTH / 2 - GameConstants.BULLET_HEIGHT,
                    GameConstants.BULLET_WIDTH, GameConstants.BULLET_HEIGHT
                    );
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
 public SpaceShuttle(Point pos, Size size, Image img) : base(pos, size)
 {
     img_src           = img;
     base.Power        = 48;
     clip              = new Stack <Bullet>();
     bulletsPower      = BulletPower.PowerFull;
     bulletsSpeed      = BulletSpeed.Fast;
     Energy            = 100;
     Health            = 100;
     energyRegenration = 15;
 }
    public void Shoot(Vector3 direction, Vector3 position, int damage, BulletPower power, BulletPower childBulletPower, float childBulletPowerRate, float childBulletSpeed)
    {
        GameObject enemyBullet = GetBullet();
        if (enemyBullet == null)
        {
            enemyBullet = MakeBullet();
        }
        enemyBullet.SetActive(true);
        enemyBullet.transform.position = position;
        EnemyBullet bulletScript = enemyBullet.GetComponent<EnemyBullet>();
        bulletScript.BecomeAlive();
        bulletScript.direction = direction;
        bulletScript.bulletPower = power;
        bulletScript.damage = damage;
        bulletScript.speed = childBulletSpeed;
        bulletScript.powerRate = childBulletPowerRate;
        bulletScript.childBulletPower = childBulletPower;
        //bulletScript.
        shootCooldown = 0;


    }
Ejemplo n.º 4
0
 internal void ChangePowerSpeed(BulletSpeed bulletSpeed, BulletPower bulletPower)
 {
     ChangeSpeed(bulletSpeed);
     ChangePower(bulletPower);
 }
Ejemplo n.º 5
0
 internal void ChangePower(BulletPower bulletPower)
 {
     this.Power = (int)bulletPower;
 }
Ejemplo n.º 6
0
 public Bullet(Point pos, BulletSpeed bulletSpeed, BulletPower bulletPower, Size size) : base(pos, size)
 {
     this.speed = (int)bulletSpeed;
     this.Power = (int)bulletPower;
 }
Ejemplo n.º 7
0
 void FireBullet(Vector3 direction, Vector3 position, BulletPower power,float speed, float powerRate)
 {
     GameObject bullet = GetBullet();
     if (bullet == null)
     {
         bullet = MakeBullet();
     }
     bullet.transform.position = position;
     EnemyBullet bulletScript = bullet.GetComponent<EnemyBullet>();
     bulletScript.BecomeAlive();
     bulletScript.direction = direction;
     bulletScript.bulletPower = power;
     bulletScript.speed = speed;
     bulletScript.powerRate = powerRate;
     //  bulletScript.direction = Vector3.Normalize(Vector3.RotateTowards(Vector3.down, Vector3.left, .4f, 1));
 }
Ejemplo n.º 8
0
 void Pop(BulletPower power,float speed, float powerRate)
 {
     bulletPower = BulletPower.normal;
     FireBullet(Vector3.Normalize(Vector3.down + Vector3.right), this.transform.position,power,speed,powerRate);
     FireBullet(Vector3.Normalize(Vector3.right), this.transform.position, power,speed,powerRate);
     FireBullet(Vector3.Normalize(Vector3.right + Vector3.up), this.transform.position, power,speed,powerRate);
     FireBullet(Vector3.Normalize(Vector3.up), this.transform.position, power,speed,powerRate);
     FireBullet(Vector3.Normalize(Vector3.left + Vector3.up), this.transform.position, power,speed,powerRate);
     FireBullet(Vector3.Normalize(Vector3.left), this.transform.position, power,speed,powerRate);
     FireBullet(Vector3.Normalize(Vector3.down + Vector3.left), this.transform.position, power,speed,powerRate);
 }
Ejemplo n.º 9
0
 void Pop()
 {
     bulletPower = BulletPower.normal;
     FireBullet(Vector3.Normalize(Vector3.down + Vector3.right), this.transform.position, BulletPower.normal);
     FireBullet(Vector3.Normalize(Vector3.right), this.transform.position, BulletPower.normal);
     FireBullet(Vector3.Normalize(Vector3.right + Vector3.up), this.transform.position, BulletPower.normal);
     FireBullet(Vector3.Normalize(Vector3.up), this.transform.position, BulletPower.normal);
     FireBullet(Vector3.Normalize(Vector3.left + Vector3.up), this.transform.position, BulletPower.normal);
     FireBullet(Vector3.Normalize(Vector3.left), this.transform.position, BulletPower.normal);
     FireBullet(Vector3.Normalize(Vector3.down + Vector3.left), this.transform.position, BulletPower.normal);
 }