/// <summary> /// Constructor of the <c>Weapon</c> class. /// </summary> /// <param name="name">Name of the object.</param> /// <param name="textureName">Name of the texture that represents the object.</param> /// <param name="position">Position in the inventory.</param> /// <param name="isEquipped">true if the element is equipped, false otherwise.</param> /// <param name="type">Type of the weapon.</param> /// /// <param name="power">Power of the weapon.</param> /// <param name="totalAmmo">Total amount of ammo.</param> public Weapon(string name, string textureName, int position, bool isEquipped, Gun.ShotType type, int power, int totalAmmo) : base(name, textureName, position, isEquipped) { _power = power; _type = type; _currentAmmo = totalAmmo; _totalAmmo = totalAmmo; }
/// <summary> /// Constructor of the <c>Shot</c> class. /// </summary> /// <param name="shotType">Type of the shot.</param> /// <param name="origin">Origin of the shot.</param> /// <param name="up">Up direction of the shot.</param> /// <param name="speed">Speed of the shot.</param> public Shot(Gun.ShotType shotType, Vector3 origin, Vector3 up, Vector3 speed) { _origin = origin; if (shotType == Gun.ShotType.Normal) { _up = up / 6f; _normal = Vector3.Backward; } else { _up = up / 16f; _normal = Vector3.Backward * 6; } _speed = speed; _shotType = shotType; _numberOfTiles = 2; _textureName = "ShotTiles"; if (_effect == null) { _effect = new AlphaTestEffect(EngineManager.GameGraphicsDevice); _effect.World = Matrix.Identity; } _left = Vector3.Cross(_normal, _up); _lowerLeft = _origin; _lowerLeft += -_left; _upperLeft = _lowerLeft + _up; _lowerRight = _lowerLeft + _left; _upperRight = _lowerRight + _up; _shotBBox = new BoundingBox( new Vector3(_lowerLeft.X, _lowerLeft.Y, _lowerLeft.Z - 0.1f), new Vector3(_upperRight.X, _upperRight.Y, _upperRight.Z + 0.1f)); _shotBSphere = new BoundingSphere(new Vector3( ((_upperRight.X - _lowerLeft.X) / 2f) + _lowerLeft.X, ((_upperRight.Y - _lowerLeft.Y) / 2f) + _lowerLeft.Y, ((_upperRight.Z - _lowerLeft.Z) / 2f) + _lowerLeft.Z), 0.2f); _vertices = new List <VertexPositionNormalTexture>(); _vertices.Add(new VertexPositionNormalTexture( _lowerRight, _normal, new Vector2((1.0f / _numberOfTiles) * ((_shotType == Gun.ShotType.Normal ? 1 : 2) - 1), 1))); _vertices.Add(new VertexPositionNormalTexture( _upperRight, _normal, new Vector2((1.0f / _numberOfTiles) * ((_shotType == Gun.ShotType.Normal ? 1 : 2) - 1), 0))); _vertices.Add(new VertexPositionNormalTexture( _lowerLeft, _normal, new Vector2((1.0f / _numberOfTiles) * (_shotType == Gun.ShotType.Normal ? 1 : 2), 1))); _vertices.Add(new VertexPositionNormalTexture( _upperRight, _normal, new Vector2((1.0f / _numberOfTiles) * ((_shotType == Gun.ShotType.Normal ? 1 : 2) - 1), 0))); _vertices.Add(new VertexPositionNormalTexture( _upperLeft, _normal, new Vector2((1.0f / _numberOfTiles) * (_shotType == Gun.ShotType.Normal ? 1 : 2), 0))); _vertices.Add(new VertexPositionNormalTexture( _lowerLeft, _normal, new Vector2((1.0f / _numberOfTiles) * (_shotType == Gun.ShotType.Normal ? 1 : 2), 1))); }