예제 #1
0
        /// <summary>
        /// Hide popups when enabled.
        /// </summary>
        /// ReSharper disable once UnusedMember.Local
        private void OnEnable()
        {
            MemoryGame.Current.IsBusy = true;
            CurrentScreenShoot        = 0;
            isGoingBack = false;
            progress    = 1;

            if (HidePopupObject != null)
            {
                HidePopupObject.SetActive(false);
            }

            controlRect = WorldToRect.GetRect(HelpFramePositions);

            scrollRect       = controlRect;
            scrollRect.x    += controlRect.width * 0.02f;
            scrollRect.y    += controlRect.height * 0.02f;
            scrollRect.width = controlRect.width * 0.9505f;

            imageWidth  = controlRect.width * 0.950f;
            imageHeight = scrollRect.height;

            scrollContentRect = new Rect(0, 0, scrollRect.width * (ScreenShoots.Length + 1), scrollRect.height - 50);

            float ratio = 800.0f / Screen.height;

            if (Initialize.IsWideScreen)
            {
                ratio = 780.0f / Screen.height;
            }

            float buttonWidth  = BackTexture.width / ratio;
            float buttonHeight = BackTexture.height / ratio;
            float height       = (imageHeight / 2.0f) - 50;
            float offsetX      = (controlRect.x * 1.34f) - (buttonWidth / 2.0f);

            if (Screen.height > 768)
            {
                if (!Initialize.IsWideScreen)
                {
                    offsetX = (controlRect.x * 1.34f) - (buttonWidth / 2.0f);
                }
                else
                {
                    offsetX = (controlRect.x * 1.1f) - (buttonWidth / 2.0f);
                }
            }

            backButtonRect  = new Rect(offsetX, controlRect.y + height, buttonWidth, buttonHeight);
            nextButtonRect  = new Rect(offsetX + (controlRect.width * 0.9572f), controlRect.y + height, buttonWidth, buttonHeight);
            closeButtonRect = new Rect(offsetX + (controlRect.width * 0.9572f), 0, buttonWidth, buttonHeight);
        }
예제 #2
0
        private void RenderSavePopup()
        {
            GUI.DrawTexture(WorldToRect.GetRect(SaveSetPositions), SaveSetTexture);
            GUI.DrawTexture(WorldToRect.GetRect(SaveButtonPositions), SaveTexture);
            GUI.DrawTexture(WorldToRect.GetRect(CancelButtonPositions), CancelTexture);

            GUI.skin.settings.cursorColor = Color.white;

            var style = new GUIStyle();

            style.fontSize          = Scale(18);
            style.clipping          = TextClipping.Clip;
            style.normal.background = null;
            style.normal.textColor  = Color.white;

            nameSet = GUI.TextField(WorldToRect.GetRect(StartSetInputObject, EndSetInputObject), nameSet, style);
        }
예제 #3
0
        private void MouseDown()
        {
            if (searchItems.Items.Count <= 0 || selectedCards.Count >= maxCards)
            {
                return;
            }

            Vector2 position = Input.mousePosition;

            position.y = Screen.height - position.y;

            bool isTapped = false;
            Rect rect     = WorldToRect.GetRect(SpawnStartLocation, SpawnEndLocation);

            if (rect.Contains(position))
            {
                position.x += searchScrollViewVector.x;
                position.y += searchScrollViewVector.y;
                position.x -= rect.x - Scale(14);
                position.y -= rect.y;

                Debug.Log(position);

                var item = searchItems.GetHitTestItem(position) as ImageViewWithFrame;
                if (item != null)
                {
                    var card = item.Tag as CardData;
                    if (card != null && selectedCards.All(c => c.Id != card.Id))
                    {
                        selectedCards.Add(card);
                        AddToSet(item);

                        if (selectedCards.Count >= maxCards && SaveSetObject != null)
                        {
                            ShowSavePopup();
                        }
                        else if (selectedCards.Count >= minCard)
                        {
                            StartSaveButton.SetActive(true);
                        }

                        isTapped = true;
                    }
                }
            }

            if (!isTapped)
            {
                var startPosition = Camera.main.WorldToScreenPoint(SpawnMyDeckStartLocation.transform.position);
                startPosition.y = Screen.height - startPosition.y;

                var endPosition = Camera.main.WorldToScreenPoint(SpawnMyDeckEndLocation.transform.position);
                endPosition.y = Screen.height - endPosition.y;

                position   = Input.mousePosition;
                position.y = Screen.height - position.y;

                rect = WorldToRect.GetRect(SpawnMyDeckStartLocation, SpawnMyDeckEndLocation);

                position.x += selectedCardsScrollViewVector.x;
                position.y += selectedCardsScrollViewVector.y;
                position.x -= rect.x - Scale(14);
                position.y -= rect.y;

                for (int i = 0; i < selectedCardsImages.Count; ++i)
                {
                    if (selectedCardsImages[i].Rect.Contains(position))
                    {
                        selectedCards.RemoveAt(i);
                        selectedCardsImages.RemoveAt(i);

                        if (selectedCards.Count < minCard)
                        {
                            StartSaveButton.SetActive(false);
                        }

                        RebuildSelectedCardsList();

                        isTapped = true;
                        break;
                    }
                }
            }
        }
예제 #4
0
    /// <summary>
    /// Use this for initialization.
    /// </summary>
    private void Start()
    {
        currentScoreText  = TextFormatting.AddSpacingBetweenCharacters(string.Format(scoreFormat, 0, 1));
        currentScoreText2 = TextFormatting.AddSpacingBetweenCharacters(string.Format(scoreFormat, 0, 2));

        game          = MemoryGame.Current;
        game.GameMode = GameMode;
        game.StartNewGame();

        PlayersPlaying = DataMessenger.NumberOfPlayers;
        game.Players   = PlayersPlaying;

        Score         = game.Scores;
        CurrentPlayer = game.CurrentPlayer;

        CardsLeft = 0;

        int numberOfCards = game.DifficultyToNumberOfCards(DataMessenger.Difficulty) / 2;
        var fieldSize     = DeckLayoutProvider.GetGridSize(numberOfCards * 2);

        if (IsDebuggingQuestionsEnabled)
        {
            DebugQuestionPopup();
        }

        List <CardData> cards;

        if (DataMessenger.SelectedDeck != null)
        {
            cards     = DataMessenger.SelectedDeck.Cards.OrderBy(a => Guid.NewGuid()).Take(numberOfCards).ToList();
            gameTitle = DataMessenger.SelectedDeck.ResourceName;
        }
        else
        {
            cards     = CardFactory.GetRandomDeck(numberOfCards);
            gameTitle = "Fossils";
        }

        gameTitle = TextFormatting.AddSpacingBetweenCharactersWithSmallSpace(gameTitle, (int)(Initialize.Scale * 14));

        while (cards.Count < numberOfCards)
        {
            cards.AddRange(cards);
        }

        if (cards.Count > numberOfCards)
        {
            cards = cards.Take(numberOfCards).ToList();
        }

        cards.AddRange(cards);
        cards = cards.OrderBy(c => Guid.NewGuid()).ToList();

        var field = WorldToRect.GetRect(SpawnLocation, SpawnEndLocation);

        field.x     = 20;
        field.width = Screen.width - field.x - field.x;
        var list = CalculateLayout.Calculate(
            (int)fieldSize.y,
            (int)fieldSize.x,
            field.width,
            field.height,
            field.x,
            field.y,
            10 * Initialize.Scale);
        float scale   = 1f;
        float offsetY = 0f;

        switch (DataMessenger.Difficulty)
        {
        case 0:
            scale = 1f;
            break;

        case 1:
            scale   = 0.8f;
            offsetY = 8f;
            break;

        case 2:
            scale   = 0.6f;
            offsetY = 12f;
            break;

        case 3:
            scale   = 0.5f;
            offsetY = 14f;
            break;

        case 4:
            scale   = 0.4f;
            offsetY = 20f;
            break;
        }

        if (CardObject != null && SpawnLocation != null)
        {
            int i = 0;
            for (int y = 0; y < fieldSize.y; ++y)
            {
                for (int x = 0; x < fieldSize.x; ++x)
                {
                    ++CardsLeft;
                    var card = (GameObject)Instantiate(CardObject);
                    card.SendMessage("SetCard", cards[i]);

                    Vector3 newPosition = Camera.main.ScreenToWorldPoint(
                        new Vector3(list[i].x + (list[i].width / 2.0f), list[i].y + (list[i].height / 3.0f) - offsetY));
                    newPosition.z = -2;

                    GameObject obj = new GameObject();
                    obj.transform.position   = newPosition;
                    obj.transform.parent     = SpawnLocation.transform;
                    obj.transform.localScale = new Vector3(scale, scale, 1);

                    card.transform.parent        = obj.transform;
                    card.transform.localPosition = new Vector3();

                    ++i;
                }
            }
        }
    }