示例#1
0
    void Start()
    {
        deck = GetComponentInChildren <DeckCards>();
        print("Screen width = " + Screen.width.ToString());
        hand  = GetComponentsInChildren <CardCollection>()[0];
        board = GetComponentsInChildren <CardCollection>()[1];

        print("PAAAAAAAAAREZZA" + hand.transform.parent.gameObject.tag);
        print("asjkdfasd 319" + board.transform.parent.gameObject.tag);


        hand.transform.position = new Vector3(-1.0f * Screen.width / 200, transform.position.y, 0);
        print("Card collectio" + GetComponentInChildren <CardCollection>().transform.position.ToString());
        hand.w = 1.0f * Screen.width / 100;
        hand.ForceStart();
        for (int i = 0; i < number_of_starting_cards; i++)
        {
            hand.AddCard(deck.NextCard());
        }

        board.transform.position = new Vector3(hand.transform.position.x, hand.transform.position.y + board_hand_buf, 0);
        board.w = hand.w;
        board.ForceStart();

        var game = GameObject.FindGameObjectWithTag("game").GetComponent <Game>();

        transform.parent.GetComponentInChildren <EndTurn>().Activate(game.player_turn);
        transform.parent.GetComponentInChildren <EndTurn>().Deactivate((game.player_turn + 1) % 2);
    }
示例#2
0
    public void BuildDistrict()
    {
        CardVisual selectedCard = gameManager.gameGUI.selectedCard;

        if (selectedCard != null)
        {
            //TODO: make sure district is not already built
            //TODO: check build district bug, kept card after building district
            if (coins >= selectedCard.card.cost)
            {
                districtstoBuild--;
                AdjustCoins(-selectedCard.card.cost);
                Card c = hand.RemoveCardWithID(selectedCard.card.id);
                gameManager.gameGUI.RemoveCard(c);
                builtDistricts.AddCard(c);
                gameManager.gameGUI.RecalculateCardPositions();
                gameManager.gameGUI.AddDistrict(c, builtDistricts.collection.Count - 1);

                if (districtstoBuild == 0)
                {
                    gameManager.gameGUI.turnButtons[0].interactable = false;
                }

                Hashtable table = new Hashtable();
                table[(byte)1] = myID;
                table[(byte)2] = c.id;
                gameManager.gameClient.SendEvent(11, table, true, false);
            }
        }
    }
    public void CreateCollection()
    {
        CardCollection collection = ScriptableObject.CreateInstance <CardCollection>();

        collection.name = cardsJson.name;

        bool cancelled = EditorUtility.DisplayCancelableProgressBar("Creating collection", "Creating new collection from current JSON file", 0f);

        for (int i = 0; i < allCards.Count; i++)
        {
            cancelled = EditorUtility.DisplayCancelableProgressBar("Creating collection", $"Adding {allCards[i].name}", (float)i / allCards.Count);
            if (cancelled)
            {
                Debug.LogWarning($"Creation of collection cancelled by user after {i} of {allCards.Count} cards. Asset will not be created.");
                EditorUtility.ClearProgressBar();
                return;
            }
            // Debug.Log($"Trying to add card {allCards[i].name} to collection");

            collection.AddCard(allCardsUnity.Find(cu => cu.cardName == allCards[i].name));
        }

        EditorUtility.ClearProgressBar();

        UnityEditor.AssetDatabase.CreateAsset(collection, $"Assets/Resources/Collections/{collection.name}_collection.asset");
    }