Пример #1
0
 /// <summary>
 /// Create a TrashCan GameItem with no bonus item
 /// </summary>
 /// <param name="inLevel"></param>
 /// <param name="startPos"></param>
 public TrashCan(Level inLevel, Vector2 startPos)
     : base(startPos, inLevel, null)
 {
     this.Sprite    = TextureManager.GetTexure("TrashCanNormal");
     this.SpriteHit = TextureManager.GetTexure("TrashCanHit");
     this.InitSpriteFrames(this.Sprite.Width, this.Sprite.Height);
     this.SetOriginPosition("bottom");
     this.HitArea = this.DrawWidth / 2;
     this.GetLayerDepth(this.Position.Y);
     this.BonusItem = null;
     this.State     = TrashCanState.Normal;
 }
    /// <summary>
    /// Create a TrashCan GameItem containing an item that will NOT drop anything
    /// </summary>
    /// <param name="inLevel"></param>
    /// <param name="startPos"></param>
    public TrashCan(Level inLevel, Vector2 startPos)
    {
        this.InLevel  = inLevel;
        this.state    = TrashCanState.Normal;
        this.texture  = Game1.SprTrashCanNormal;
        this.Position = startPos;
        this.speed    = Vector2.Zero;
        this.origin   = new Vector2(texture.Width / 2, texture.Height); // Lower Center
        this.HitArea  = Game1.SprTrashCanNormal.Width / 2;

        this.GetLayerDepth(this.Position.Y);

        this.dropItem = null;
    }
    public override void TakeHit(DirectionTarget cameFrom)
    {
        // Set speed and texture
        this.state   = TrashCanState.Hit;
        this.texture = Game1.SprTrashCanHit;

        // Set speed based off hitDirection
        if (cameFrom == DirectionTarget.Left)
        {
            this.speed = new Vector2(-baseHitSpeed.X, baseHitSpeed.Y);
        }
        else
        {
            this.speed = baseHitSpeed;
        }

        SoundManager.PlaySound("CrashGlass");
        SoundManager.PlaySound("MetalSound2");
    }