/// <summary> /// 删除指定精灵 /// </summary> /// /// <param name="sprite"></param> /// <returns></returns> public bool Remove(ISprite sprite) { if (sprite == null) { return(false); } if (sprites == null) { return(false); } bool removed = false; for (int i = size; i > 0; i--) { if (sprite.Equals(sprites[i - 1])) { removed = true; size--; sprites[i - 1] = sprites[size]; sprites[size] = null; if (size == 0) { sprites = new ISprite[0]; } else { CompressCapacity(2); } return(removed); } } return(removed); }
public void CheckHit(Bullet bullet, ISprite sprite) { if (sprite.Equals(Owner)) return; if (!(sprite is Living)) return; var livingSprite = sprite as Living; HandleHit(bullet, livingSprite); }
/// <summary> /// 检查指定精灵是否存在 /// </summary> /// /// <param name="sprite"></param> /// <returns></returns> public bool Contains(ISprite sprite) { if (sprite == null) { return(false); } if (sprites == null) { return(false); } for (int i = 0; i < size; i++) { if (sprites[i] != null && sprite.Equals(sprites[i])) { return(true); } } return(false); }
public override void Update() { timer -= GameObjectManager.Instance.CurrentGameTime.ElapsedGameTime.TotalSeconds; if (timer >= TimerUtil.Zero) { if (currentSprite.Equals(oldSprite)) { currentSprite = newSprite; } else { currentSprite = oldSprite; } } else { RemoveTransitionState(); } base.Update(); }