Пример #1
0
        public void Draw(SpriteBatch spriteBatch)
        {
            Vector2 deckPosition = new Vector2(drawZone.X + 12, drawZone.Y + drawZone.Height * 0.5f - deckTexture.Height * 0.5f);

            // Background
            {
                Color color = new Color(25, 25, 45, 160);
                DrawSeparation(spriteBatch, new Vector2(drawZone.X + 6, drawZone.Y), 6, color);
                DrawSeparation(spriteBatch, new Vector2(drawZone.X + deckTexture.Width + 12, drawZone.Y), 6, color);
                DrawSeparation(spriteBatch, new Vector2(drawZone.X + drawZone.Width - 12, drawZone.Y), 6, color);

                DrawPanel(spriteBatch, backgroundTexture, new Color(25, 25, 60, 140));
                DrawPanel(spriteBatch, borderTexture, new Color(25, 25, 45, 160));

                spriteBatch.Draw(deckTexture, new Vector2(deckPosition.X, deckPosition.Y) + deckTexture.Size() * 0.5f, null, Color.White, 0f, deckTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0f);
            }

            // Cards and Info
            {
                Player          player       = Main.player[Main.myPlayer];
                OrchidModPlayer orchidPlayer = player.GetModPlayer <OrchidModPlayer>();

                if (!player.dead)
                {
                    int[] nbCards = new int[20];
                    for (int i = 0; i < 20; i++)
                    {
                        nbCards[i] = 0;
                    }

                    int maxReq        = 0;
                    int playerNbCards = OrchidModGamblerHelper.getNbGamblerCards(player, orchidPlayer);

                    for (int i = 0; i < playerNbCards; i++)
                    {
                        Item currentItem = orchidPlayer.gamblerCardsItem[i];
                        if (currentItem.type != ItemID.None)
                        {
                            OrchidModGlobalItem orchidItem = currentItem.GetGlobalItem <OrchidModGlobalItem>();
                            int cardReq = orchidItem.gamblerCardRequirement;
                            nbCards[cardReq]++;
                            maxReq = cardReq > maxReq ? cardReq : maxReq;
                        }
                    }

                    for (int i = 0; i < playerNbCards; i++)
                    {
                        Item currentItem = orchidPlayer.gamblerCardsItem[i];
                        if (currentItem.type != ItemID.None)
                        {
                            OrchidModGlobalItem orchidItem = currentItem.GetGlobalItem <OrchidModGlobalItem>();
                            int  cardReq   = orchidItem.gamblerCardRequirement;
                            bool canRemove = (playerNbCards > maxReq + 1) || (cardReq == maxReq);

                            DrawCard(currentItem, spriteBatch, new Vector2(deckPosition.X + 8 + (i % 5 * 26), deckPosition.Y + 8 + (i == 0 ? 0 : i / 5) * 32), player, orchidPlayer, maxReq, canRemove);
                        }
                    }
                }
            }
        }
Пример #2
0
        public override void GamblerShoot(Player player, Vector2 position, float speedX, float speedY, int type, int damage, float knockBack, bool dummy = false)
        {
            OrchidModPlayer modPlayer   = player.GetModPlayer <OrchidModPlayer>();
            int             projType    = ProjectileType <Gambler.Projectiles.ShuffleCardProj>();
            float           aiType      = Main.rand.Next(4);
            int             count       = 0;
            int             damageCount = damage + (int)(OrchidModGamblerHelper.getNbGamblerCards(player, modPlayer) * 1.2f);

            for (int l = 0; l < Main.projectile.Length; l++)
            {
                Projectile proj = Main.projectile[l];
                if (player.whoAmI == proj.owner && proj.active && proj.ai[1] != 6f && proj.type == projType)
                {
                    aiType = proj.ai[0];
                    count++;
                    damageCount    = damage * (count + 1);
                    proj.damage    = damageCount;
                    proj.netUpdate = true;
                }
            }
            if (count < 5)
            {
                int        newProjInt = OrchidModGamblerHelper.DummyProjectile(Projectile.NewProjectile(position.X, position.Y, 0f, 0f, projType, damageCount, knockBack, player.whoAmI), dummy);
                Projectile newProj    = Main.projectile[newProjInt];
                newProj.ai[1]     = (float)(count + 1);
                newProj.ai[0]     = (float)aiType;
                newProj.netUpdate = true;
                Main.PlaySound(2, (int)player.Center.X, (int)player.Center.Y - 200, count == 4 ? 35 : 1);
            }
            else
            {
                Main.PlaySound(2, (int)player.Center.X, (int)player.Center.Y - 200, 7);
            }
        }
Пример #3
0
        public void OnCardClick(Item item, Player player, OrchidModPlayer orchidPlayer)
        {
            player.QuickSpawnItem(item.type, 1);
            OrchidModGamblerHelper.removeGamblerCard(item, player, orchidPlayer);

            if (OrchidModGamblerHelper.getNbGamblerCards(player, orchidPlayer) > 0)
            {
                OrchidModGamblerHelper.clearGamblerCardCurrent(player, orchidPlayer);
                OrchidModGamblerHelper.clearGamblerCardsNext(player, orchidPlayer);
                orchidPlayer.gamblerShuffleCooldown = 0;
                orchidPlayer.gamblerRedraws         = 0;
                OrchidModGamblerHelper.drawGamblerCard(player, orchidPlayer);
            }
            else
            {
                OrchidModGamblerHelper.onRespawnGambler(player, orchidPlayer);
            }
        }
Пример #4
0
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            Player          player    = Main.player[Main.myPlayer];
            OrchidModPlayer modPlayer = player.GetModPlayer <OrchidModPlayer>();

            Vector2 vector = new Vector2((float)((int)(Main.LocalPlayer.position.X - Main.screenPosition.X) - Main.GameViewMatrix.Translation.X - (float)(Main.LocalPlayer.bodyFrame.Width / 2) + (float)(Main.LocalPlayer.width / 2)), (float)((int)(Main.LocalPlayer.position.Y - Main.screenPosition.Y) - Main.GameViewMatrix.Translation.Y + (float)Main.LocalPlayer.height - (float)Main.LocalPlayer.bodyFrame.Height + 12f + player.gfxOffY)) + Main.LocalPlayer.bodyPosition + new Vector2((float)(Main.LocalPlayer.bodyFrame.Width / 2));

            vector *= Main.GameViewMatrix.Zoom;
            vector /= Main.UIScale;

            this.Left.Set(vector.X + 30f, 0f);
            this.Top.Set(vector.Y - 50f, 0f);

            CalculatedStyle dimensions = GetDimensions();
            Point           point      = new Point((int)dimensions.X, (int)dimensions.Y - 100);
            int             width      = (int)Math.Ceiling(dimensions.Width);
            int             height     = (int)Math.Ceiling(dimensions.Height);

            if (!player.dead)
            {
                if (modPlayer.gamblerUIChipSpinDisplay)
                {
                    int     widthArrow  = chipDirection.Width;
                    int     heightArrow = chipDirection.Height;
                    Vector2 position    = new Vector2(point.X - 30, point.Y + 150);
                    float   angle       = MathHelper.ToRadians(modPlayer.gamblerChipSpin);
                    //	new Rectangle(point.X - 30, point.Y + 50, widthArrow, heightArrow);
                    spriteBatch.Draw(chipDirection, position, null, backgroundColor, angle, chipDirection.Size() * 0.5f, 1f, SpriteEffects.None, 0f);
                    //spriteBatch.Draw(texture, position, null, color, projectile.rotation, texture.Size() * 0.5f, projectile.scale, effect, 0f);
                }

                if (modPlayer.gamblerUIDeckDisplay)
                {
                    if (player.talkNPC != -1)
                    {
                        spriteBatch.Draw(UIDeckbuilding, new Rectangle(point.X - 100, point.Y - 60, 140, 138), backgroundColor);
                        int    offSetX       = 0;
                        int    offSetY       = 0;
                        string msg           = "";
                        string msg2          = "";
                        string msg3          = "";
                        int[]  nbCards       = new int[20];
                        int    maxReq        = 0;
                        int    playerNbCards = OrchidModGamblerHelper.getNbGamblerCards(player, modPlayer);
                        for (int i = 0; i < 20; i++)
                        {
                            nbCards[i] = 0;
                        }
                        for (int i = 0; i < playerNbCards; i++)
                        {
                            Item      currentItem      = modPlayer.gamblerCardsItem[i];
                            Texture2D currentTexture   = Main.itemTexture[currentItem.type];
                            Rectangle currentRectangle = new Rectangle(point.X - 92 + offSetX, point.Y - 52 + offSetY, 20, 26);
                            spriteBatch.Draw(currentTexture, currentRectangle, backgroundColor);
                            offSetX += 26;
                            if ((i - 4) % 5 == 0)
                            {
                                offSetX  = 0;
                                offSetY += 32;
                            }
                            if (currentItem.type != 0)
                            {
                                OrchidModGlobalItem orchidItem = currentItem.GetGlobalItem <OrchidModGlobalItem>();
                                int cardReq = orchidItem.gamblerCardRequirement;
                                nbCards[cardReq]++;
                                maxReq = cardReq > maxReq ? cardReq : maxReq;
                            }
                        }

                        offSetX = 0;
                        offSetY = 0;

                        for (int i = 0; i < playerNbCards; i++)
                        {
                            Item      currentItem      = modPlayer.gamblerCardsItem[i];
                            Rectangle currentRectangle = new Rectangle(point.X - 92 + offSetX, point.Y - 52 + offSetY, 20, 26);
                            offSetX += 26;
                            if ((i - 4) % 5 == 0)
                            {
                                offSetX  = 0;
                                offSetY += 32;
                            }
                            if (currentItem.type != 0)
                            {
                                OrchidModGlobalItem orchidItem = currentItem.GetGlobalItem <OrchidModGlobalItem>();
                                int  cardReq   = orchidItem.gamblerCardRequirement;
                                bool canRemove = (playerNbCards > maxReq + 1) || (cardReq == maxReq);
                                if (currentRectangle.Contains(new Point((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y)))
                                {
                                    if (((Main.mouseLeft && Main.mouseLeftRelease) || (Main.mouseRight && Main.mouseRightRelease)) && canRemove)
                                    {
                                        player.QuickSpawnItem(currentItem.type, 1);
                                        OrchidModGamblerHelper.removeGamblerCard(currentItem, player, modPlayer);
                                        if (OrchidModGamblerHelper.getNbGamblerCards(player, modPlayer) > 0)
                                        {
                                            OrchidModGamblerHelper.clearGamblerCardCurrent(player, modPlayer);
                                            OrchidModGamblerHelper.clearGamblerCardsNext(player, modPlayer);
                                            modPlayer.gamblerShuffleCooldown = 0;
                                            modPlayer.gamblerRedraws         = 0;
                                            OrchidModGamblerHelper.drawGamblerCard(player, modPlayer);
                                        }
                                        else
                                        {
                                            OrchidModGamblerHelper.onRespawnGambler(player, modPlayer);
                                        }
                                    }
                                    msg  = currentItem.Name;
                                    msg2 = canRemove ? "Can be removed" : "Cannot be removed";
                                    msg3 = canRemove ? "" : "Your highest cost card requires at least " + maxReq + " cards";
                                }
                                if (!canRemove)
                                {
                                    Rectangle blockRectangle = new Rectangle(currentRectangle.X - 2, currentRectangle.Y - 2, currentRectangle.Width + 4, currentRectangle.Height + 4);
                                    spriteBatch.Draw(UIDeckbuildingBlock, blockRectangle, backgroundColor);
                                }
                            }
                        }
                        if (msg != "")
                        {
                            ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontMouseText, msg, Main.MouseScreen + new Vector2(15f, 15f), new Color(Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor), 0f, Vector2.Zero, Vector2.One, -1f, 2f);
                        }
                        if (msg2 != "")
                        {
                            ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontMouseText, msg2, Main.MouseScreen + new Vector2(15f, 40f), new Color(Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor), 0f, Vector2.Zero, Vector2.One, -1f, 2f);
                        }
                        if (msg3 != "")
                        {
                            ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontMouseText, msg2, Main.MouseScreen + new Vector2(15f, 40f), new Color(Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor, Main.mouseTextColor), 0f, Vector2.Zero, Vector2.One, -1f, 2f);
                        }
                    }
                    else
                    {
                        modPlayer.gamblerUIDeckDisplay = false;
                    }
                }

                if ((modPlayer.gamblerUIDisplayTimer > 0 || modPlayer.gamblerChips > 0) && modPlayer.gamblerUIFightDisplay)
                {
                    if (modPlayer.gamblerCardCurrent.type != this.cardID)
                    {
                        UICard      = this.getUiCardTexture(modPlayer, 0);
                        this.cardID = modPlayer.gamblerCardCurrent.type;
                    }

                    if (modPlayer.gamblerCardNext[0].type != this.cardIDNext1)
                    {
                        UICardNext1      = this.getUiCardTexture(modPlayer, 1);
                        this.cardIDNext1 = modPlayer.gamblerCardNext[0].type;
                    }

                    if (modPlayer.gamblerCardNext[1].type != this.cardIDNext2)
                    {
                        UICardNext2      = this.getUiCardTexture(modPlayer, 2);
                        this.cardIDNext2 = modPlayer.gamblerCardNext[1].type;
                    }

                    if (modPlayer.gamblerCardNext[2].type != this.cardIDNext3)
                    {
                        UICardNext3      = this.getUiCardTexture(modPlayer, 3);
                        this.cardIDNext3 = modPlayer.gamblerCardNext[2].type;
                    }

                    int       drawHeight  = 70;
                    int       drawSide    = 0;
                    int       leftOffset  = 0;
                    int       leftOffset2 = 0;
                    Texture2D chip        = chip1;

                    spriteBatch.Draw(UIDeck, new Rectangle(point.X + 8, point.Y + 160, 26, 32), backgroundColor);
                    spriteBatch.Draw(UICard, new Rectangle(point.X + 8, point.Y + 160, 20, 26), backgroundColor);

                    if (modPlayer.gamblerSeeCards > 2)
                    {
                        spriteBatch.Draw(UICardNext3, new Rectangle(point.X + 40, point.Y + 194, 20, 26), backgroundColor);
                    }
                    if (modPlayer.gamblerSeeCards > 1)
                    {
                        spriteBatch.Draw(UICardNext2, new Rectangle(point.X + 24, point.Y + 194, 20, 26), backgroundColor);
                    }
                    if (modPlayer.gamblerSeeCards > 0)
                    {
                        spriteBatch.Draw(UICardNext1, new Rectangle(point.X + 8, point.Y + 194, 20, 26), backgroundColor);
                    }

                    for (int i = 0; i < modPlayer.gamblerRedraws; i++)
                    {
                        spriteBatch.Draw(UIRedraw, new Rectangle(point.X + 20 - drawSide, point.Y + 94, 14, 20), backgroundColor);
                        drawSide += 4;
                    }

                    int unit = (int)(modPlayer.gamblerShuffleCooldownMax / 34) + 1;
                    int val  = 0;
                    spriteBatch.Draw(ressourceBar, new Rectangle(point.X + 36, point.Y + 116, 12, 76), backgroundColor);
                    while (val < modPlayer.gamblerShuffleCooldown)
                    {
                        spriteBatch.Draw(ressourceBarFull, new Rectangle(point.X + 40, point.Y + 116 + drawHeight, 4, 2), backgroundColor);
                        drawHeight -= 2;
                        val        += unit;
                    }

                    if (val > 0)
                    {
                        drawHeight += 2;
                        spriteBatch.Draw(ressourceBarTop, new Rectangle(point.X + 40, point.Y + 116 + drawHeight, 4, 2), backgroundColor);
                    }

                    if (modPlayer.gamblerDiceValue > 0)
                    {
                        Texture2D dice = dice1;
                        switch (modPlayer.gamblerDiceValue)
                        {
                        case 1:
                            dice = dice1;
                            break;

                        case 2:
                            dice = dice2;
                            break;

                        case 3:
                            dice = dice3;
                            break;

                        case 4:
                            dice = dice4;
                            break;

                        case 5:
                            dice = dice5;
                            break;

                        case 6:
                            dice = dice6;
                            break;

                        default:
                            break;
                        }
                        spriteBatch.Draw(dice, new Rectangle(point.X + 36, point.Y + 90, 24, 24), backgroundColor);

                        drawHeight = 70;
                        val        = 0;

                        spriteBatch.Draw(ressourceBar, new Rectangle(point.X + 50, point.Y + 116, 12, 76), backgroundColor);
                        while (val < modPlayer.gamblerDiceDuration)
                        {
                            spriteBatch.Draw(ressourceBarDiceFull, new Rectangle(point.X + 54, point.Y + 116 + drawHeight, 4, 2), backgroundColor);
                            drawHeight -= 2;
                            val        += 60;
                        }

                        if (val > 0)
                        {
                            spriteBatch.Draw(ressourceBarDiceTop, new Rectangle(point.X + 54, point.Y + 116 + drawHeight, 4, 2), backgroundColor);
                        }
                    }

                    drawHeight = 36;
                    for (int i = 1; i < modPlayer.gamblerChips + 1; i++)
                    {
                        spriteBatch.Draw(chip, new Rectangle(point.X + 18 - leftOffset - leftOffset2, point.Y + 116 + drawHeight, 14, 6), backgroundColor);

                        drawHeight -= 4;
                        if (i % 10 == 0)
                        {
                            drawHeight  = 36;
                            leftOffset2 = leftOffset2 == 4 ? 0 : 4;
                            switch (i)
                            {
                            case 10:
                                chip = chip2;
                                break;

                            case 20:
                                chip = chip3;
                                break;

                            case 30:
                                chip = chip4;
                                break;

                            case 40:
                                chip = chip5;
                                break;

                            default:
                                break;
                            }
                        }
                        leftOffset = leftOffset == 2 ? 0 : 2;
                    }
                }
            }
        }