Beispiel #1
0
        public static void StoreItem(Profile p, Thing t)
        {
            if (Network.isActive && t is RagdollPart || t is TrappedDuck)
            {
                return;
            }
            if (t is WeightBall)
            {
                t = (Thing)(t as WeightBall).collar;
            }
            StoredItem storedItem = PurpleBlock.GetStoredItem(p);

            System.Type type = t.GetType();
            if (!(storedItem.type != type) && !(storedItem.type == typeof(RagdollPart)) && (!(t is TeamHat) || !(storedItem.thing is TeamHat) || (t as TeamHat).team == (storedItem.thing as TeamHat).team))
            {
                return;
            }
            Thing thing;

            if (t is RagdollPart)
            {
                if (storedItem.thing != null && storedItem.thing is SpriteThing && (storedItem.thing as SpriteThing).persona == (t as RagdollPart)._persona)
                {
                    return;
                }
                thing = (Thing) new SpriteThing(0.0f, 0.0f, (Sprite)(t as RagdollPart)._persona.defaultHead);
                (thing as SpriteThing).persona = (t as RagdollPart)._persona;
            }
            else
            {
                thing = Editor.CreateThing(type);
            }
            if (thing is TeamHat)
            {
                TeamHat teamHat1 = thing as TeamHat;
                TeamHat teamHat2 = t as TeamHat;
                teamHat1.sprite       = teamHat2.sprite.CloneMap();
                teamHat1.graphic      = (Sprite)teamHat1.sprite;
                teamHat1.pickupSprite = teamHat2.pickupSprite.Clone();
                teamHat1.team         = teamHat2.team;
            }
            else if (thing.graphic == null)
            {
                thing.graphic = t.graphic.Clone();
            }
            storedItem.sprite = thing.GetEditorImage(0, 0, true, (Effect)PurpleBlock._grayscaleEffect);
            storedItem.sprite.CenterOrigin();
            if (t is RagdollPart)
            {
                storedItem.sprite.centerx += 2f;
                storedItem.sprite.centery += 4f;
            }
            storedItem.type  = type;
            storedItem.thing = thing;
            SFX.Play("scanBeep");
        }
        public override void Draw(float x, float y, Depth depth)
        {
            if (this._team == null)
            {
                return;
            }
            y -= 9f;
            float x1 = x;
            float y1 = y + 8f;

            this._persona.sprite.depth = depth;
            this._persona.sprite.color = Color.White;
            DuckGame.Graphics.Draw(this._persona.sprite, 0, x1, y1);
            this._persona.armSprite.frame = this._persona.sprite.imageIndex;
            this._persona.armSprite.scale = new Vec2(1f, 1f);
            this._persona.armSprite.depth = depth + 4;
            DuckGame.Graphics.Draw((Sprite)this._persona.armSprite, x1 - 3f, y1 + 6f);
            Vec2 hatPoint = DuckRig.GetHatPoint(this._persona.sprite.imageIndex);

            this._team.hat.depth  = depth + 2;
            this._team.hat.center = new Vec2(16f, 16f) + this._team.hatOffset;
            DuckGame.Graphics.Draw(this._team.hat, this._team.hat.frame, x1 + hatPoint.x, y1 + hatPoint.y);
            if (this._team.hat.texture.textureName == "hats/devhat" && this._cape == null)
            {
                this._hat  = new TeamHat(x1 + hatPoint.x, (float)((double)y1 + (double)hatPoint.y + 5.0), Teams.GetTeam("CAPTAIN"));
                this._cape = new Cape(x1 + hatPoint.x, y1 + hatPoint.y, (PhysicsObject)this._hat);
            }
            if (this._team.hat.texture.textureName == "hats/moonwalker" && this._cape == null)
            {
                this._hat  = new TeamHat(x1 + hatPoint.x, (float)((double)y1 + (double)hatPoint.y + 5.0), Teams.GetTeam("MOONWALK"));
                this._cape = new Cape(x1 + hatPoint.x, y1 + hatPoint.y, (PhysicsObject)this._hat);
                this._cape.SetCapeTexture((Texture2D)Content.Load <Tex2D>("hats/moonCape"));
            }
            if (this._team.hat.texture.textureName == "hats/royalty" && this._cape == null)
            {
                this._hat  = new TeamHat(x1 + hatPoint.x, (float)((double)y1 + (double)hatPoint.y + 5.0), Teams.GetTeam("MAJESTY"));
                this._cape = new Cape(x1 + hatPoint.x, y1 + hatPoint.y, (PhysicsObject)this._hat);
                this._cape.SetCapeTexture((Texture2D)Content.Load <Tex2D>("hats/royalCape"));
            }
            if (this._cape == null)
            {
                return;
            }
            this._hat.position = new Vec2(x1 + hatPoint.x, (float)((double)y1 + (double)hatPoint.y + 5.0));
            this._cape.depth   = depth + 2;
            this._cape.Update();
            this._cape.Draw();
        }
Beispiel #3
0
 public override void SpawnItem()
 {
     base.SpawnItem();
     if (this.lastSpawnItem != null)
     {
         TeamHat lastSpawnItem = this.lastSpawnItem as TeamHat;
         TeamHat contextThing  = this._contextThing as TeamHat;
         if (lastSpawnItem != null && contextThing != null)
         {
             lastSpawnItem.sprite       = contextThing.sprite.CloneMap();
             lastSpawnItem.graphic      = (Sprite)lastSpawnItem.sprite;
             lastSpawnItem.team         = contextThing.team;
             lastSpawnItem.pickupSprite = contextThing.pickupSprite.Clone();
         }
     }
     this.lastSpawnItem = (PhysicsObject)null;
 }