コード例 #1
0
ファイル: Tower.cs プロジェクト: andreivettor/Operation-Mars
        public Tower(ContentManager content, int groundLevel, int basePosition) : base(content)
        {
            SetTexture("tower1");
            Width      = texture.Width;
            Height     = texture.Height;
            X          = basePosition + 200;
            Y          = groundLevel - Height;
            laserGun   = new LaserGun(content, (int)X + 15, (int)Y + 15, 30, this);
            layerDepth = LayerManager.GetLayerDepth(Layer.Buildings);

            layerDepth += .01f;
        }
コード例 #2
0
ファイル: Turret.cs プロジェクト: andreivettor/Operation-Mars
        public Turret(ContentManager content, int groundLevel, Enemy.EnemyDirection enemyDirection) : base(content, groundLevel)
        {
            SetTexture("turret1");

            Y = groundLevel - Height;
            this.groundLevel = groundLevel;


            if (enemyDirection == Enemy.EnemyDirection.ToLeft)
            {
                X    = Game.GAME_WIDTH / 2 - Width / 2 + 290;
                view = new Rectangle((int)X + Width, 0, Game.GAME_WIDTH - (int)X - Width, (int)Y + Height);
            }
            else
            {
                X             = Game.GAME_WIDTH / 2 - Width / 2 - 290;
                view          = new Rectangle(0, 0, (int)X, (int)Y + Height);
                spriteEffects = SpriteEffects.FlipHorizontally;
            }

            int gunX;

            if (spriteEffects == SpriteEffects.FlipHorizontally)
            {
                gunX = (int)X;
            }
            else
            {
                gunX = (int)X + 8;
            }
            int gunY = (int)Y + 8;

            laserGun = new LaserGun(content, gunX, gunY, 10, this);

            if (enemyDirection == Enemy.EnemyDirection.ToRight)
            {
                laserGun.PointAt(0, (int)laserGun.Y + laserGun.Height / 2);
            }

            healthBar.Height /= 2;
            healthBar.Width  /= 2;

            layerDepth += .01f;

            HealthLevel = 1;

            Alive = false;
        }