示例#1
0
        public VariatingSprite GetSprite(ulong id, int variation, VSType t)
        {
            VariatingSprite variatingSprite1 = this._eggSprites.FirstOrDefault <VariatingSprite>((Func <VariatingSprite, bool>)(x => (long)x.id == (long)id && x.variation == variation && x.type == t));

            if (variatingSprite1 != null)
            {
                return(variatingSprite1);
            }
            VariatingSprite variatingSprite2 = new VariatingSprite();

            variatingSprite2.variation = variation;
            variatingSprite2.id        = id;
            variatingSprite2.type      = t;
            if (t == VSType.Egg)
            {
                variatingSprite2.sprite = Profile.GetEggSprite(variation, id);
            }
            else if (t == VSType.Portrait)
            {
                variatingSprite2.sprite = Profile.GetPaintingSprite(variation, id);
            }
            this._eggSprites.Add(variatingSprite2);
            return((VariatingSprite)null);
        }
示例#2
0
        public void Draw(
            Vec2 pos,
            Depth depth,
            int variation    = 0,
            ulong seed       = 0,
            bool affectScale = false,
            bool halfscale   = false,
            float angle      = 0.0f)
        {
            if (seed == 0UL && Profiles.experienceProfile != null)
            {
                seed = Profiles.experienceProfile.steamID;
            }
            SpriteMap spriteMap = this.sprite;

            if (this.icon != null)
            {
                spriteMap = this.icon;
            }
            if (spriteMap != null && this.neverFlip)
            {
                spriteMap.flipH = false;
            }
            if (this.name == "EGG")
            {
                VariatingSprite sprite = this.GetSprite(seed, variation, VSType.Egg);
                if (sprite != null)
                {
                    if (sprite.sprite.texture != null)
                    {
                        sprite.sprite.depth = depth + 6;
                        sprite.sprite.scale = this.sprite.scale;
                        DuckGame.Graphics.Draw(sprite.sprite, pos.x - 8f * sprite.sprite.xscale, pos.y - 12f * sprite.sprite.yscale);
                        spriteMap.frame = 0;
                    }
                    if ((sprite.sprite.renderTexture.nativeObject as Microsoft.Xna.Framework.Graphics.RenderTarget2D).IsContentLost)
                    {
                        this._eggSprites.Remove(sprite);
                    }
                }
            }
            else if (this.name == "PHOTO")
            {
                if (this._photoSprite == null)
                {
                    this._photoSprite = new SpriteMap("littleMan", 16, 16);
                }
                this._photoSprite.frame = UILevelBox.LittleManFrame(variation, 7, seed);
                this._photoSprite.depth = depth + 6;
                this._photoSprite.scale = this.sprite.scale;
                DuckGame.Graphics.Draw((Sprite)this._photoSprite, pos.x - 6f * this._photoSprite.xscale, pos.y - 4f * this._photoSprite.yscale, new Rectangle(2f, 0.0f, 12f, 10f));
                DuckGame.Graphics.DrawRect(pos + new Vec2(-6f * this._photoSprite.xscale, -6f * this._photoSprite.yscale), pos + new Vec2(6f * this._photoSprite.xscale, 6f * this._photoSprite.yscale), Colors.DGBlue, depth - 4);
                spriteMap.frame = 0;
            }
            else if (this.name == "EASEL")
            {
                VariatingSprite sprite = this.GetSprite(seed, variation, VSType.Portrait);
                if (sprite != null)
                {
                    sprite.sprite.depth = depth + 6;
                    sprite.sprite.scale = this.sprite.scale;
                    DuckGame.Graphics.Draw(sprite.sprite, pos.x - 9f * sprite.sprite.xscale, pos.y - 8f * sprite.sprite.yscale);
                    spriteMap.frame = 0;
                    if ((sprite.sprite.renderTexture.nativeObject as Microsoft.Xna.Framework.Graphics.RenderTarget2D).IsContentLost)
                    {
                        this._eggSprites.Remove(sprite);
                    }
                }
            }
            else
            {
                spriteMap.frame = variation;
            }
            if (this.font != null && this.sprite == null)
            {
                this.font.scale = new Vec2(1f, 1f);
                this.font.Draw("F", pos + new Vec2(-3.5f, -3f), Color.Black, depth + 8);
            }
            if (affectScale)
            {
                if (halfscale && (spriteMap.width > 30 || spriteMap.height > 30))
                {
                    spriteMap.scale = new Vec2(0.5f);
                }
                else
                {
                    spriteMap.scale = new Vec2(1f);
                }
            }
            spriteMap.depth = depth;
            spriteMap.angle = angle;
            DuckGame.Graphics.Draw((Sprite)spriteMap, pos.x, pos.y);
        }