public virtual bool Collide(ICollidable other) { lock (disposalLock) { if (!isDisposed) { if (ActiveSprite.Collide(other.ActiveSprite)) { if (other is Player.PlayerObject) { return(true); } if (other is Bullet) { if ((other as Bullet).IsPlayerBullet) { health -= (other as Bullet).Damage; shouldRemove = health <= 0; hitPercent = 1.0f; (other as Bullet).ShouldRemove = true; return(true); } } } } } return(false); }
public virtual void Draw(SpriteBatch spriteBatch) { if (ActiveSprite != null && !isDisposed) { ActiveSprite.Draw(spriteBatch); } }
public bool Collide(ICollidable other) { if (!Invulnerable) { if (other is Bullet) { if (!(other as Bullet).IsPlayerBullet) { if (ActiveSprite.Collide(other.ActiveSprite)) { incomingDamage += (other as Bullet).Damage; (other as Bullet).ShouldRemove = true; invulnerable = true; invulnerableTime = 1000; return(true); } } } if (other is Enemy) { if (ActiveSprite.Collide(other.ActiveSprite)) { incomingDamage += (other as Enemy).Health / 4.0f; (other as Enemy).TakeDamage((other as Enemy).Health); (other as Enemy).ShouldRemove = true; invulnerable = true; invulnerableTime = 1000; return(true); } } } return(false); }
// Use this for initialization void Start() { renderPosition = playerRenderer.transform.localPosition; rigidbody = GetComponent <Rigidbody2D>(); armPosition = arm.transform.localPosition; armActiveSprite = arm.GetComponentInChildren <ActiveSprite>(); SetWeapon(Weapons.Weapon.lugger); }
public override void Update(float elapsedTime) { activeRunTime += elapsedTime; currentTime += elapsedTime; if (currentCurve < bezierCurves.Count) { float t = activeRunTime / runTimes[currentCurve]; if (t <= 1.0) { var nextPos = ChaosDriveMath.CalculateBezierCurveLocation(bezierCurves[currentCurve], t); velocity = nextPos - position; position = nextPos; } else { activeRunTime -= runTimes[currentCurve]; currentCurve++; if (currentCurve < bezierCurves.Count) { t = activeRunTime / runTimes[currentCurve]; var nextPos = ChaosDriveMath.CalculateBezierCurveLocation(bezierCurves[currentCurve], t); velocity = nextPos - position; position = nextPos; } } } else { position += velocity; } if (bullets.Count > 0) { if (bullets.Any(b => b.LaunchTime < currentTime)) { OnShotsFired(); } } UpdateHitEffect(elapsedTime); ActiveSprite.Update(elapsedTime); ActiveSprite.Position = position; if (health <= 0) { shouldRemove = true; } if (currentCurve >= bezierCurves.Count && activeRunTime >= runTimes.Last() && !ActiveSprite.Bounds.Intersects(bounds)) { shouldRemove = true; } }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { foreach (var controller in controllers) { controller.Update(); } ActiveSprite?.Update(); base.Update(gameTime); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); ActiveSprite?.Draw(spriteBatch); staticTextSprite.Draw(spriteBatch); spriteBatch.End(); base.Draw(gameTime); }
public virtual void DisposeObjects() { lock (disposalLock) { EnemyController = null; if (ActiveSprite != null) { ActiveSprite.Dispose(); } isDisposed = true; } }
public void Update(float elapsedTime) { ActiveSprite.Update(elapsedTime); #region Move the player according to the state Move(elapsedTime); #endregion if (incomingDamage > 0) { var toRemove = 25.0f / (elapsedTime); toRemove = Math.Min(incomingDamage, toRemove); health -= toRemove; incomingDamage -= toRemove; } if (health < 1) { health = 0; } if (invulnerableTime > 0) { invulnerableTime = Math.Max(0f, invulnerableTime - elapsedTime); invulnerable = invulnerableTime > 0; } if (gunReloadTime > 0) { gunReloadTime -= elapsedTime; } if (driveReloadTime > 0) { driveReloadTime -= elapsedTime; } if (chaosDriveFuel < 100 && timeAdjustment == 1.0f) { chaosDriveFuel = Math.Min((chaosDriveFuel + (10.0f * elapsedTime / 1000.0f)), 100); } if (timeAdjustment != 1.0f) { chaosDriveFuel = Math.Max(chaosDriveFuel - (10.0f * elapsedTime / 1000.0f / timeAdjustment), 0.0f); if (chaosDriveFuel == 0.0f) { driveReloadTime = 4000.0f; } } }
private void simpleButton5_Click(object sender, EventArgs e) { Node.SetValue(0, textEdit1.Text); ActiveSprite.Name = textEdit1.Text; ActiveSprite.OriginX = int.Parse(calcEdit1.Text); ActiveSprite.OriginY = int.Parse(calcEdit2.Text); if (Changed) { ActiveSprite.Height = NewHeight; ActiveSprite.Width = NewWidth; ActiveSprite.SetImages(Bitmaps, true); Node.TreeList.Refresh(); } this.Close(); }
public virtual void Update(float elapsedTime) { if (!isDisposed && ActiveSprite != null) { UpdateHitEffect(elapsedTime); } if (!isDisposed && ActiveSprite != null) { ActiveSprite.Update(elapsedTime); } if (!isDisposed && ActiveSprite != null) { ActiveSprite.Position = position; } if (health <= 0 || !ActiveSprite.Bounds.Intersects(bounds)) { shouldRemove = true; } }
private void frmSprites_Load(object sender, EventArgs e) { textEdit1.Text = ActiveSprite.Name; calcEdit1.EditValue = ActiveSprite.OriginX; calcEdit2.EditValue = ActiveSprite.OriginY; labelControl2.Text = "Width: " + ActiveSprite.Width; labelControl3.Text = "Height: " + ActiveSprite.Height; NewWidth = ActiveSprite.Width; NewHeight = ActiveSprite.Height; Bitmaps = ActiveSprite.GetImages(); if (Bitmaps.Count > 0) { pictureEdit1.Image = Bitmaps[0]; } else { pictureEdit1.Image = null; } pictureEdit1.Size = new Size(NewWidth, NewHeight); }
public void Draw(SpriteBatch spriteBatch) { ActiveSprite.Draw(spriteBatch); }