Beispiel #1
0
        //public Player()
        //{
        //    type = PlayerType.Player;
        //    cards = new List<Card>();

        //    //temporary for loop for testing later wont be needed
        //    for (int i = 0; i < 30; i++)
        //    {
        //        cards.Add(new Card());
        //    }
        //    cards.shuffle();
        //    Health = 30;
        //}

        //will be called every time match is started
        public Player(PlayerType playerType)
        {
            PlayerType = playerType;
            activeDeck = new Deck();
            hand       = new List <Card>();
            graveYard  = new List <Card>();
            decks      = new List <Deck>();
            Boolean temp  = true;
            int     tempI = 0;

            if (playerType == PlayerType.Player)
            {
                boundingBox = new RectangleShape(new Vector2f(2000, Card.height + 200))
                {
                    OutlineColor = Color.White, FillColor = Color.Transparent, OutlineThickness = 2, Position = new Vector2f(-300, Game.ScreenHeight - 150)
                };
            }
            else
            {
                boundingBox = new RectangleShape(new Vector2f(2000, Card.height + 200))
                {
                    OutlineColor = Color.White, FillColor = Color.Transparent, OutlineThickness = 2, Position = new Vector2f(-300, -20)
                };
            }
            //temporary for loop for testing later wont be needed because it will load in the players cards
            for (int i = 0; i < 30; i++)
            {
                if (i % 2 == 0)
                {
                    if (tempI == 0)
                    {
                        var card = new SpellCard(ObjectId.GenerateNewId().ToString());

                        card.cardName.DisplayedString = $"{i}";
                        activeDeck.cards.Enqueue(card);
                        tempI = 1;
                    }
                    else
                    {
                        var card = new SpellCard(ObjectId.GenerateNewId().ToString());
                        card.SetEffect(Effect.OverloadCardMana(2, card));
                        card.cardName.DisplayedString = $"Overload Mana";
                        activeDeck.cards.Enqueue(card);
                        tempI = 0;
                    }
                }
                else
                {
                    if (i == 3)
                    {
                        var card = new EffectMonster(ObjectId.GenerateNewId().ToString())
                        {
                            MaxMana = 2
                        };
                        var effects = new Effect[2];
                        effects[0] = Effect.HealPlayer(5, card, 1, 2);
                        effects[1] = Effect.OverloadCardMana(1, card, 2, 0, true);

                        //card.SetEffect(Effect.HealPlayer(5, card), 2);
                        card.SetEffects(effects);
                        card.cardName.DisplayedString = $"{i}";

                        card.Attack = 12;

                        activeDeck.cards.Enqueue(card);
                    }
                    else
                    {
                        var card = new MonsterCard(ObjectId.GenerateNewId().ToString());
                        card.cardName.DisplayedString = $"{i}";
                        //if ( && temp)//temporary for testing
                        //{
                        card.Attack = 13;

                        temp = false;
                        //}
                        activeDeck.cards.Enqueue(card);
                    }
                }
            }
            //cards = cards.Shuffle();



            if (playerType == PlayerType.Player)
            {
                healthText = HelperFunctions.NewText($"Health: ", 15, new Vector2f {
                    X = 80f, Y = Game.ScreenHeight - 140f
                }, Color.Red);
                crystalsText = HelperFunctions.NewText($"Crystals: ", 15, new Vector2f {
                    X = 180f, Y = Game.ScreenHeight - 140f
                }, Color.Blue);
            }
            else
            {
                healthText = HelperFunctions.NewText($"Health: ", 15, new Vector2f {
                    X = 80f, Y = 120f
                }, Color.Red);
                crystalsText = HelperFunctions.NewText($"Crystals: ", 15, new Vector2f {
                    X = 180f, Y = 120f
                }, Color.Blue);
            }

            Health = 30;

            MaxCrystals   = 4;
            Crystals      = MaxCrystals;
            CrystalsToAdd = 0;
        }
Beispiel #2
0
        public CardManager(RenderWindow renderWindow, Player player)
        {
            window       = renderWindow;
            title        = HelperFunctions.NewText("Card and Deck Manager", 40, new Vector2f(Game.ScreenWidth / 2, 20), new Color(101, 67, 33));
            title.Origin = new Vector2f(title.GetGlobalBounds().Width / 2, title.GetGlobalBounds().Height / 2);
            this.player  = player;

            Cardsview = new View(new FloatRect(0f, 0f, Game.ScreenWidth * 0.4f, Game.ScreenHeight));
            Cardsview.Zoom(2f);
            Cardsview.Viewport = new FloatRect(0.6f, 0.08f, 0.4f, 1f);
            Cardsview.Move(new Vector2f(Game.ScreenWidth * 0.4f / 2 - Card.width, Game.ScreenHeight / 2 - Card.height / 2 - 20));
            cardsViewCenter = Cardsview.Center;

            deckView = new View(new FloatRect(0f, 0f, Game.ScreenWidth * 0.4f, Game.ScreenHeight));
            deckView.Zoom(2f);
            deckView.Viewport = new FloatRect(0.2f, 0.08f, 0.4f, 1f);
            deckView.Move(new Vector2f(Game.ScreenWidth * 0.4f / 2 - Card.width, Game.ScreenHeight / 2 - Card.height / 2 - 20));

            deckBoundingBox = new RectangleShape(new Vector2f(Game.ScreenWidth * 0.4f - 1, Game.ScreenHeight - 1))
            {
                OutlineThickness = 2, OutlineColor = Color.Green, Position = new Vector2f(Game.ScreenWidth * 0.2f, 1), FillColor = Color.Transparent
            };
            cardsBoundingBox = new RectangleShape(new Vector2f(Game.ScreenWidth * 0.4f - 1, Game.ScreenHeight - 1))
            {
                OutlineThickness = 2, OutlineColor = Color.Red, Position = new Vector2f(Game.ScreenWidth * 0.6f, 1), FillColor = Color.Transparent
            };
            CardView = new View(new FloatRect(0f, 0f, Game.ScreenWidth / 4.8f, Game.ScreenHeight));
            CardView.Zoom(0.8f);
            CardView.Viewport = new FloatRect(0f, 0f, 0.2f, 1f);

            deckSelectButtons = new List <Button>();
            deckEditButtons   = new List <Button>();

            DeckEditView          = new View(new FloatRect(0f, 0f, Game.ScreenWidth * 0.8f, Game.ScreenHeight));
            DeckEditView.Viewport = new FloatRect(0.2f, 0f, 0.8f, 1f);



            InitiallizeShapes();
            InitiallizeDeckEditText();
            InitiallizeDeckSelectText();
            InitiallizeButtons();
            player.cards = new List <Card>();
            //Temporary

            int tempI = 0;

            //temporary for loop for testing later wont be needed because it will load in the players cards
            for (int i = 0; i < 61; i++)
            {
                if (i % 4 == 0)
                {
                    if (tempI == 0)
                    {
                        var card = new SpellCard(ObjectId.GenerateNewId().ToString());
                        card.cardName.DisplayedString = $"{i}";
                        card.State = CardState.Front;
                        player.cards.Add(card);
                        tempI = 1;
                        Database.AddCardToPlayerCards(player, card);
                    }
                    else
                    {
                        var card = new SpellCard(ObjectId.GenerateNewId().ToString());
                        card.SetEffect(Effect.OverloadCardMana(2, card));
                        card.cardName.DisplayedString = $"Overload Mana";
                        card.State = CardState.Front;
                        player.cards.Add(card);
                        tempI = 0;
                        Database.AddCardToPlayerCards(player, card);
                    }
                }
                else
                {
                    if (i % 3 == 0)
                    {
                        var card = new EffectMonster(ObjectId.GenerateNewId().ToString())
                        {
                            MaxMana = 2
                        };
                        var effects = new Effect[2];
                        effects[0] = Effect.HealPlayer(5, card, 1, 2);
                        effects[1] = Effect.OverloadCardMana(1, card, 2, 0, true);
                        //card.SetEffect(Effect.HealPlayer(5, card), 2);
                        card.SetEffects(effects);
                        card.cardName.DisplayedString = $"{i}";
                        card.State  = CardState.Front;
                        card.Attack = 110;
                        player.cards.Add(card);
                        Database.AddCardToPlayerCards(player, card);
                    }
                    else
                    {
                        var card = new MonsterCard(ObjectId.GenerateNewId().ToString());
                        card.cardName.DisplayedString = $"{i}";
                        card.State  = CardState.Front;
                        card.Attack = 110;
                        player.cards.Add(card);
                        Database.AddCardToPlayerCards(player, card);
                    }
                }
            }
            //not temp
            cards = player.CopyCards();
            OrganizeCards();
            SetCardPositions();
        }