示例#1
0
        public virtual void Draw(SpriteBatch batch)
        {
            float     s   = (float)_age / (float)_maxAge;
            Color     c   = new Color((byte)MathHelper.Lerp(_startCol.R, _endCol.R, s), (byte)MathHelper.Lerp(_startCol.B, _endCol.B, s), (byte)MathHelper.Lerp(_startCol.G, _endCol.G, s), (byte)MathHelper.Lerp(_startCol.A, _endCol.A, s));
            cCamera2D cam = PrimalDevistation.Instance.Camera;

            batch.Draw(_texture, cam.GetScreenPos(ref _position), null, c, 0, _origin, cam.Zoom, SpriteEffects.None, 0);
        }
示例#2
0
 public virtual void Draw(SpriteBatch batch)
 {
     if (_texture != null)
     {
         cCamera2D cam = PrimalDevistation.Instance.Camera;
         batch.Draw(_texture, cam.GetScreenPos(ref _position), null, Color.White, _rotation, _origin, cam.Zoom, SpriteEffects.None, 0);
     }
 }
示例#3
0
        public override void Update(GameTime gameTime, Vector4[] forces)
        {
            base.Update(gameTime, forces);

            if (_grappleStuck)
            {
                Vector2 v = _attTo.Position - _position;
                _rotation = (float)Math.Atan2(-v.Y, -v.X);

                float lsq = v.LengthSquared();

                if (lsq > _ropeIdealLength * _ropeIdealLength)
                {
                    cMath.newLength(ref v, _ropeIdealLength);

                    v += _position;

                    Vector2 v2 = v - _attTo.Position;

                    float lenSqr = v2.LengthSquared();
                    if (lenSqr > _ropeStrength * _ropeStrength)
                    {
                        v2.Normalize();
                        v2.X *= _ropeStrength;
                        v2.Y *= _ropeStrength;
                    }

                    _attTo.Velocity = _attTo.Velocity + v2;
                }


                _attTo.OnGround = false;

                //if (!LieroXNA.Instance.CurrentLevel.CollisionMap.CheckCollision((int)(_position.X), (int)(_position.Y)))
                //{
                //    _grappleStuck = false;
                //}
            }

            cCamera2D cam = PrimalDevistation.Instance.Camera;
            Vector2   vec = _attTo.Position; vec.Y -= 8;

            _rope = new Line(cam.GetScreenPos(ref vec), cam.GetScreenPos(ref _position));
        }
示例#4
0
        public void RenderUI(SpriteBatch batch)
        {
            Texture2D frame = _charBase;
            cCamera2D cam   = PrimalDevistation.Instance.Camera;
            Vector2   v     = cam.GetScreenPos(ref _position);

            // Draw health bar
            float ratio = (float)_healthBarWidth / _maxHitPoints;
            int   len   = (int)(ratio * _hitPoints);

            batch.Draw(_flatTex, new Rectangle((int)v.X - (len / 2), (int)v.Y - frame.Height - 10, len, 6), _primaryColor);

            // Draw Ammo Bar
            if (_currentAmmoLevels[_currentWeaponIndex, 4] <= _currentAmmoLevels[_currentWeaponIndex, 5])
            {
                ratio = (float)_healthBarWidth / _currentAmmoLevels[_currentWeaponIndex, 5];
                len   = (int)(ratio * _currentAmmoLevels[_currentWeaponIndex, 4]);
            }
            else
            {
                ratio = (float)_healthBarWidth / _currentAmmoLevels[_currentWeaponIndex, 1];
                len   = (int)(ratio * _currentAmmoLevels[_currentWeaponIndex, 0]);
            }

            batch.Draw(_flatTex, new Rectangle((int)v.X - (_healthBarWidth / 2), (int)v.Y - frame.Height - 18, _healthBarWidth, 6), new Color(255, 255, 0, 128));
            batch.Draw(_flatTex, new Rectangle((int)v.X - (len / 2), (int)v.Y - frame.Height - 18, len, 6), new Color(255, 255, 0, 255));

            // Draw crosshair
            v = new Vector2(_position.X + ((float)Math.Cos(_reticuleAngle) * 60) - (_origin.X / 2f), _position.Y + ((float)Math.Sin(_reticuleAngle) * 60) - (_origin.Y / 2f));
            v = cam.GetScreenPos(ref v);
            batch.Draw(_crosshair, v, null, Color.White, 0, new Vector2(-_crosshair.Width / 2, -_crosshair.Height / 2), cam.Zoom, SpriteEffects.None, 0);


            // Draw the current weapon
            if (_weaponSwitching)
            {
                Texture2D wep = PrimalDevistation.Instance.Weapons.WeaponBlueprints[_currentWeaponIndex].Texture;
                v = new Vector2(_position.X - (wep.Width / 2f), _position.Y - frame.Height - 20 - wep.Height);
                batch.Draw(wep, cam.GetScreenPos(ref v), null, new Color(255, 255, 255, 255), 0, Vector2.Zero, 1.5f, SpriteEffects.None, 0);
            }
        }
示例#5
0
        public void Draw(SpriteBatch batch)
        {
            //Texture2D frame = _sprite.CurrentFrame;
            Texture2D frame = _charBase;

            if (frame != null)
            {
                // Draw the player
                cCamera2D cam = PrimalDevistation.Instance.Camera;
                Vector2   v   = cam.GetScreenPos(ref _position);
                //batch.Draw(frame, v, null, Color.White, _rotation, _origin, cam.Zoom, _spriteEffects, 0);
                batch.Draw(frame, v, null, Color.White, _rotation, _origin, cam.Zoom, SpriteEffects.None, 0);
                Vector2 orig = new Vector2((_charTurret.Width / 2f) - 1, (_charTurret.Height / 2f) + 8);

                batch.Draw(_charTurret, v, null, Color.White, (float)(_reticuleAngle + Math.PI / 2), orig, cam.Zoom, SpriteEffects.None, 0);

                if (_bubbles)
                {
                    orig = new Vector2((_bubble.Width / 2f), (_bubble.Height / 2f));
                    batch.Draw(_bubble, v, null, new Color(255, 255, 255, 100), 0, orig, cam.Zoom, SpriteEffects.None, 0);
                }
            }
        }