예제 #1
0
        public static PedestalData Load(TagCompound tag)
        {
            PedestalData data = new PedestalData(tag.Get <Item>(nameof(item)), tag.Get <Vector2>(nameof(coordinates)));

            data.flipped = tag.GetBool(nameof(flipped));
            return(data);
        }
예제 #2
0
        public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex)
        {
            PedestalData data = ThisPedestalSpecific(new Vector2(i, j));

            if (data != null && data.item != null && data.item.type > ItemID.None && Main.rand.NextBool(79))
            {
                Texture2D itemTex     = Main.itemTexture[data.item.type];
                Rectangle itemTexRect = new Rectangle(0, 0, itemTex.Width, itemTex.Height);
                if (Main.itemAnimationsRegistered.Contains(data.item.type))
                {
                    int FrameCount    = Main.itemAnimations[data.item.type].FrameCount;
                    int TicksPerFrame = Main.itemAnimations[data.item.type].TicksPerFrame;
                    Update();
                    void Update()
                    {
                        if (++miscFrame[0] >= TicksPerFrame / 6)
                        {
                            miscFrame[0] = 0;
                            if (++miscFrame[1] >= FrameCount)
                            {
                                miscFrame[1] = 0;
                            }
                        }
                    }

                    itemTexRect = itemTex.Frame(1, FrameCount, 0, miscFrame[1]);
                }
                Dust dust = Dust.NewDustPerfect(new Vector2((i * 16) + Main.rand.Next(itemTexRect.Width / 2 * -1, itemTexRect.Width / 2), (j * 16) - CastledsContent.instance.pedestal[0] * 33.5f - Main.rand.Next(itemTexRect.Height / 4, itemTexRect.Height / 2)), DustID.SilverCoin, Vector2.Zero);
                dust.noGravity = true;
                dust.velocity  = Vector2.Zero;
            }
        }
예제 #3
0
        public override void KillMultiTile(int i, int j, int frameX, int frameY)
        {
            PedestalData data = ThisPedestal(new Vector2(i, j));

            Item.NewItem(i * 16, j * 16, 16, 48, ModContent.ItemType <Pedestal>());
            Main.LocalPlayer.QuickSpawnItem(data.item.Clone());
            CastledWorld.pedestals.Remove(data);
        }
예제 #4
0
        public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
        {
            PedestalData data = ThisPedestalSpecific(new Vector2(i, j));

            if (data != null && data.item != null && data.item.type > ItemID.None)
            {
                SpriteEffects effects = data.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
                Vector2       vector  = new Vector2(Main.offScreenRange, Main.offScreenRange);
                if (Main.drawToScreen)
                {
                    vector = Vector2.Zero;
                }
                Texture2D itemTex     = Main.itemTexture[data.item.type];
                Rectangle itemTexRect = new Rectangle(0, 0, itemTex.Width, itemTex.Height);
                Vector2   drawPos     = new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + vector;
                float     imgScale    = 1;
                imgScale *= (float)(Math.Sin((double)((Math.PI * 7.5) * CastledsContent.instance.pedestal[0] / 450f)) * 2.5f);
                if (Main.itemAnimationsRegistered.Contains(data.item.type))
                {
                    int FrameCount    = Main.itemAnimations[data.item.type].FrameCount;
                    int TicksPerFrame = Main.itemAnimations[data.item.type].TicksPerFrame;
                    Update();
                    void Update()
                    {
                        if (++FrameCounter >= TicksPerFrame / 6)
                        {
                            FrameCounter = 0;
                            if (++Frame >= FrameCount)
                            {
                                Frame = 0;
                            }
                        }
                    }

                    itemTexRect = itemTex.Frame(1, FrameCount, 0, Frame);
                }
                Vector2 position = new Vector2(((itemTexRect.Width + -115) / 2) + 50, ((itemTexRect.Height - 25 + (CastledsContent.instance.pedestal[0] * 33.5f)) / 2) + 50);
                if (!CastledsContent.instance.images[data.item.type].voiden)
                {
                    Main.spriteBatch.Draw(CastledsContent.instance.images[data.item.type].tex, drawPos, itemTexRect, AlphaColorBehind(), 0f, new Vector2(((itemTexRect.Width + (-115 + ((imgScale + 1) * 3.5f))) / 2) + 50, ((itemTexRect.Height - 25 + (CastledsContent.instance.pedestal[0] * 20f)) / 2) + 42.5f), (imgScale + 1) * 1.25f, effects, 0f);
                }
                Main.spriteBatch.Draw(itemTex, drawPos, itemTexRect, AlphaColor(), 0f, new Vector2(((itemTexRect.Width + (-115 + CastledsContent.instance.pedestal[3] * 6.25f)) / 2) + 50, ((itemTexRect.Height - 25 + (CastledsContent.instance.pedestal[0] * 33.5f)) / 2) + 50), 1f, effects, 0f);
                Main.spriteBatch.Draw(itemTex, drawPos, itemTexRect, AlphaColor(), 0f, new Vector2(((itemTexRect.Width + (-115 - CastledsContent.instance.pedestal[3] * 6.25f)) / 2) + 50, ((itemTexRect.Height - 25 + (CastledsContent.instance.pedestal[0] * 33.5f)) / 2) + 50), 1f, effects, 0f);
                Main.spriteBatch.Draw(itemTex, drawPos, itemTexRect, Lighting.GetColor(i, j) * 4.25f, 0f, position, 1f, effects, 0f);
                Color AlphaColor() => new Color(Color.Transparent.R + 75, Color.Transparent.G + 75, Color.Transparent.B + 75, 75);

                Color AlphaColorBehind()
                {
                    float a = CastledsContent.instance.pedestal[0] * 1.75f;

                    return(new Color(Color.Transparent.R + a, Color.Transparent.G + a, Color.Transparent.B + a, a));
                }
            }
        }
예제 #5
0
        public override bool NewRightClick(int i, int j)
        {
            Player       player = Main.LocalPlayer;
            PedestalData data   = ThisPedestal(new Vector2(i, j));

            if (ControlDown())
            {
                data.flipped = !data.flipped;
                Main.PlaySound(SoundID.Item1, TilePosition(i, j));
            }
            else
            {
                if (data.item == null || data.item.IsAir)
                {
                    Item item = InteractItem(player);
                    if (item != null && !item.IsAir)
                    {
                        data.item = item.Clone();
                        item.stack--;
                    }
                }
                else if (data.item != null && !data.item.IsAir)
                {
                    Item item = InteractItem(player);
                    player.QuickSpawnItem(data.item.Clone());
                    data.item = new Item();
                    if (item != null && !item.IsAir)
                    {
                        data.item = item.Clone();
                        item.stack--;
                    }
                }
            }
            //Main.player[Main.myPlayer].PickTile(i, j, 100);
            return(true);
        }
예제 #6
0
        public override void PlaceInWorld(int i, int j, Item item)
        {
            PedestalData data = new PedestalData(new Item(), new Vector2(i, j));

            CastledWorld.pedestals.Add(data);
        }