Exemplo n.º 1
0
        private GameCard InstantiateCard(Vector3 position)
        {
            GameVariables GV = MemoramaManager.Instance.GameVariables;

            GameObject newCard = Object.Instantiate(deck.CardPrefab, CanvasCenter);

            newCard.transform.localPosition = position;
            newCard.transform.localScale    = GetSetting(GV.GameMode).CardScale;

            if (newCard.GetComponent <GameCard>() == null)
            {
                newCard.AddComponent <GameCard>();
            }
            return(newCard.GetComponent <GameCard>());
        }
Exemplo n.º 2
0
        private void FixedUpdate()
        {
            switch (GameVariables.GamePhase)
            {
            case GamePhases.IN_GAME:
                GameVariables.ModifyGameTimeBy(-Time.fixedDeltaTime);
                MemoramaUI.Instance.UpdatePlayerUI(UIPlayerInfo.GAME_TIME, GameVariables.GameTime.ToString());
                if (GameTime.ConvertToSeconds(GameVariables.GameTime) <= 0f)
                {
                    EndGame();
                }
                return;

            default: return;
            }
        }
Exemplo n.º 3
0
        private GameCard SetRecycledCard(Vector3 position)
        {
            if (usable_cards == null || usable_cards.Count <= 0)
            {
                return(null);
            }

            GameVariables GV   = MemoramaManager.Instance.GameVariables;
            GameCard      card = usable_cards[0];

            usable_cards.RemoveAt(0);
            card.transform.localPosition = position;
            card.transform.localScale    = GetSetting(GV.GameMode).CardScale;

            return(card);
        }
Exemplo n.º 4
0
        public void ShuffleCards()
        {
            if (deck == null || deck.CardPrefab == null)
            {
                return;
            }
            if (cards_on_board == null)
            {
                CreateBoard();
            }

            GameVariables GV = MemoramaManager.Instance.GameVariables;

            int totalPairs = GameVariables.RequiredCardsToFlip;
            List <Vector2_Int> occupiedPosition = new List <Vector2_Int>();
            Vector2_Int        position         = Vector2_Int.zero;

            Card[] cards_to_play = deck.GetCards(GV.GameSuits.ToArray());
            Card[] cards_to_check;
            short  half_pairs = (short)(totalPairs / 2);

            for (int pairs = 0; pairs < totalPairs; ++pairs)
            {
                for (int suit = 0; suit < (int)GV.GameMode; ++suit)
                {
                    cards_to_check = Deck.GetCards(cards_to_play, GV.GameSuits[suit]);

                    for (int number = 0; number < (int)CardNumbers.counter; ++number)
                    {
                        if (pairs < half_pairs)
                        {
                            position = GetCardPosition(occupiedPosition, true);
                        }
                        else
                        {
                            position = GetCardPosition(occupiedPosition, false);
                        }

                        occupiedPosition.Add(position);
                        CardsSuit c_suit = GV.GameSuits[suit];
                        cards_on_board[position.x, position.y].SetCard(c_suit, (CardNumbers)number, Deck.GetCard(cards_to_check, (CardNumbers)number).Front);
                    }
                }
            }
        }