/// <summary> /// Creates a Player with the given graphical parameters. /// </summary> /// <param name="texture">Its texture.</param> /// <param name="position">Its position. <br></br>If null, it will be <see cref="Vector2.Zero"/>.</param> /// <param name="sourceRectangle">Its source rectangle. <br></br>If null, the whole texture will be drawn.</param> /// <param name="layerDepth">Its layer depth. <br></br>It's 0 by default.</param> /// <param name="effect">Its sprite effect. <br></br>It's <see cref="SpriteEffects.None"/> by default.</param> public Player(Vector2?position = null) : base(texture: Globals.Content.Load <Texture2D>("Sprites/Playable Char/Herosheet_down"), position: position, sourceRectangle: new Rectangle(0, 0, 256, 256)) { timer = new McTimer(600, true); damageImunity = new McTimer(500, true); // The players current velocity per second. _velocity = Vector2.Zero; Health = 15; HealthMax = Health; speed = 400; // Set the initial animation. CurrentAnimation = _walkingAnimations[2]; // Initialize the walking sound effect. if (_walkingSound == null) { _walkingSound = Globals.Content.Load <SoundEffect>("Sounds/SoundEffect/Sound4").CreateInstance(); _walkingSound.Volume = Globals.sounds.sfxVolume * Globals.sounds.sfxToMusicRatio; _walkingSound.IsLooped = false; } }
public Flyboss(Vector2?position = null, float rotation = 0f, SpriteEffects effect = SpriteEffects.None) : base(texture: Globals.Content.Load <Texture2D>("Sprites/Enemies/Flyboss_wo_shadow"), position, sourceRectangle: new Rectangle(0, 0, 256, 256), rotation, effect) { Speed = 2f; Health = 5; HealthMax = Health; Scale = new Vector2(1f); AttackTimer = new McTimer(1500); SpawnTimer = new McTimer(3000); direction = Globals.DegreesToVector2(45); HitValue = 0; // Set the _shadowSprite. _shadowSprite.Scale = Scale; itemNum = rand.Next(1, 4 + 1); }
public Explosion(Vector2?position = null, float rotation = 0f, SpriteEffects effects = SpriteEffects.None) : base(texture: Globals.Content.Load <Texture2D>("Sprites/Effects/Explosionsheet"), position: position, origin: new Vector2(0.5f), sourceRectangle: new Rectangle(0, 0, 256, 256), scale: Tile.Size / new Vector2(256), rotation: rotation, layerDepth: 1.0f, effects: effects) { // Set the animation. CurrentAnimation = new Animation(animationSheet: Globals.Content.Load <Texture2D>("Sprites/Effects/Explosionsheet"), frameDimensions: new Vector2(256), frameDuration: TimeSpan.FromMilliseconds(100), repetitions: 0); // Restart the animation. CurrentAnimation.Restart(); // Set the layer. Layer = 0.9f - (Position.Y / 10e6f); OwnerID = 0; timer = new McTimer(300); SoundHasPlayed = false; }
public Bomb(Vector2?position = null, Rectangle?sourceRectangle = null, float rotation = 0f, SpriteEffects effects = SpriteEffects.None) : base(texture: Globals.Content.Load <Texture2D>("Sprites/Pickups/Bomb"), position: position, sourceRectangle: sourceRectangle, rotation: rotation, effects: effects) { timer = new McTimer(1500); }
public Screamer(Vector2?position = null, float rotation = 0f, SpriteEffects effect = SpriteEffects.None) : base(texture: Globals.Content.Load <Texture2D>("Sprites/Enemies/Screamersheet_down"), position, sourceRectangle: new Rectangle(0, 0, 256, 256), rotation, effect) { Speed = 2; timer = new McTimer(1000, true); HitValue = 1; Health = 3; }
public Projectile(Texture2D texture, Vector2?position = null, Rectangle?sourceRectangle = null, float rotation = 0f, SpriteEffects effects = SpriteEffects.None) : base(texture: texture, position: position, origin: new Vector2(0.5f), sourceRectangle: sourceRectangle, scale: Tile.Size / ((sourceRectangle != null) ? sourceRectangle.Value.Size.ToVector2() : texture.Bounds.Size.ToVector2()), rotation: rotation, effects: effects) { Speed = 10; Direction = Vector2.Zero; timer = new McTimer(1000); }
public Flybuddy(Vector2?position = null, /*Rectangle? sourceRectangle = null,*/ float rotation = 0f, SpriteEffects effects = SpriteEffects.None) : base(angle: 0f, texture: Globals.Content.Load <Texture2D>("Sprites/Enemies/Flysheet"), position: position, sourceRectangle: new Rectangle(0, 0, 256, 256) /*sourceRectangle*/, rotation: rotation, effects: effects) { // Calculate its initial angle towards the player. angle = Globals.Vector2ToDegrees(Position - Level.Player.Position); Speed = 250.0f; DistanceToPlayer = Globals.GetDistance(Position, Level.Player.Position); timer = new McTimer(1000); OwnerID = 1; HitValue = 1; isDestroyed = false; Scale = new Vector2(.1f, .1f); // Initialize _shadowSprite. _shadowSprite = new Sprite(texture: _shadow, position: position, origin: new Vector2(0.5f, 1f), scale: Scale, rotation: rotation, layerDepth: 0.9999999f, effects: effects); // Set the animation. CurrentAnimation = new Animation(animationSheet: Globals.Content.Load <Texture2D>("Sprites/Enemies/FLysheet"), frameDimensions: new Vector2(256), frameDuration: TimeSpan.FromSeconds(1f / 60f)); }
public BasicAttack(float angle, Vector2?position = null, Rectangle?sourceRectangle = null, float rotation = 0f, SpriteEffects effects = SpriteEffects.None) : base(texture: Globals.Content.Load <Texture2D>("Sprites/Misc/Playerattack"), position: position, angle: angle, sourceRectangle: sourceRectangle, rotation: rotation, effects: effects) { Speed = 250.0f; Scale = new Vector2(0.1f); timer = new McTimer(1000); HitValue = Level.Player.HitValue; }
public PlayerAttack(Texture2D texture, float angle, Vector2?position = null, Rectangle?sourceRectangle = null, float rotation = 0f, SpriteEffects effects = SpriteEffects.None) : base(texture: texture, position: position, sourceRectangle: sourceRectangle, rotation: rotation, effects: effects) { Speed = 250.0f; timer = new McTimer(1000); Direction = Globals.DegreesToVector2(angle); Direction.Normalize(); HitValue = Level.Player.HitValue; OwnerID = 1; }
public EnemyAttack(float angle, Vector2?position = null, Rectangle?sourceRectangle = null, float rotation = 0f, SpriteEffects effects = SpriteEffects.None) : base(texture: Globals.Content.Load <Texture2D>("Sprites/Misc/enemyattack"), position: position, sourceRectangle: sourceRectangle, rotation: rotation, effects: effects) { Speed = 250.0f; Direction = Globals.DegreesToVector2(angle); Direction.Normalize(); HitValue = 1; Scale = new Vector2(0.1f); timer = new McTimer(1000); OwnerID = 2; }