Beispiel #1
0
    private void updateCultureCardBook(MyEnum.cultCard newCard)
    {
        Transform hand = cultureCardPanel.transform;

        Debug.Log("Child count: " + hand.childCount);
        App    app         = UnityEngine.Object.FindObjectOfType <App>();
        Nation player      = State.getNations()[app.GetHumanIndex()];
        int    numberCards = player.getCultureCards().Count;

        placeCultureCardOnTable(newCard, numberCards);

        /* Transform hand = cultureCardPanel.transform;
         * Debug.Log("Child count: " + hand.childCount);
         * App app = UnityEngine.Object.FindObjectOfType<App>();
         * Nation player = State.getNations()[app.GetHumanIndex()];
         * int numberCards = player.getCultureCards().Count;
         * Debug.Log("Number of cards: " + numberCards);
         * int loopLimit = numberCards;
         *
         * for (int i = 0; i < loopLimit; ++i)
         * {
         *   Debug.Log(i.ToString());
         *   Image image = hand.GetChild(i).GetComponent<Image>();
         *   string name = player.getCultureCards()[i].getCardName().ToString();
         *   Debug.Log("Name of next card " + name);
         *   placeCultureCardOnTable(name, i+1);
         *
         * } */
    }
Beispiel #2
0
    /* private void buildNavy()
     * {
     *   App app = UnityEngine.Object.FindObjectOfType<App>();
     *   int playerIndex = app.GetHumanIndex();
     *   Nation player = State.getNations()[playerIndex];
     *   if (player.GetTechnologies().Contains("oil_powered_ships"))
     *   {
     *       PlayerPayer.PayDreadnought(player);
     *       player.seaForces.dreadnought.addUnit();
     *   }
     *
     *   else if (player.GetTechnologies().Contains("ironclad"))
     *   {
     *       PlayerPayer.PayIronClad(player);
     *       player.seaForces.ironclad.addUnit();
     *   }
     *   else
     *   {
     *       PlayerPayer.PayFrigate(player);
     *       player.seaForces.frigate.addUnit();
     *   }
     *   uiUpdater.updateUI();
     *
     * } */

    private void getCultureCards()
    {
        selfProvince.SetActive(false);
        otherProvince.SetActive(false);
        progressPanel.SetActive(false);
        coordinator.progressFlag = false;

        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.payForDevelopmentAction(player, 1);

        MyEnum.cultCard newCard = PlayerReceiver.collectCultureCard(player);

        uiUpdater.updateUI();

        Stack <CultureCard>   remainingCultCards = State.getCultureDeck();
        HashSet <CultureCard> cultDeckSet        = new HashSet <CultureCard>(remainingCultCards);

        List <MyEnum.cultCard> playerCultHand = new List <MyEnum.cultCard>(player.getCultureCards());
        HashSet <CultureCard>  playerCultSet  = new HashSet <CultureCard>(remainingCultCards);

        foreach (MyEnum.cultCard cardName in playerCultHand)
        {
            CultureCard card = State.getCultureCardByName(cardName);
            playerCultSet.Add(card);
        }

        updateCultureCardBook(newCard);
        showCultureHandPanel();
    }
Beispiel #3
0
    private void placeCultureCardOnTable(MyEnum.cultCard cardName, int cardSlot)
    {
        Debug.Log(cardSlot);
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        Debug.Log(cardName.ToString());
        CultureCard newCard = State.getCultureCardByName(cardName);

        Transform  cardTransform = cardArea.transform.GetChild(cardSlot);
        GameObject card          = cardTransform.gameObject;

        card.SetActive(true);
        Image cardImage = card.GetComponent <Image>();

        cardImage.sprite  = Resources.Load("CultureCards/CultureCardSprites/" + newCard.getCardName(), typeof(Sprite)) as Sprite;
        cardImage.enabled = true;
        Debug.Log(card.name);
        //  Image border = card.GetComponentInChildren<Image>();
        Image border = card.transform.Find("border").GetComponentInChildren <Image>();

        border.name = cardName.ToString();
        Debug.Log(border.name);
        Text[] texts  = border.GetComponentsInChildren <Text>();
        Text   name   = texts[0];
        Text   era    = texts[1];
        Text   effect = texts[2];
        //Image CardType = border.GetComponentInParent<Image>();

        Image CardType = border.transform.Find("Type").GetComponentInChildren <Image>();

        card.name = newCard.getCardName().ToString();
        Debug.Log("Type: " + newCard.getCardType());
        border.sprite   = Resources.Load("CultureCards/CultureCardSprites/" + newCard.getCardType(), typeof(Sprite)) as Sprite;
        name.text       = newCard.getCardName().ToString();
        era.text        = newCard.getEra().ToString();
        effect.text     = newCard.getDescription();
        CardType.sprite = Resources.Load("CultureCards/CultureCardSprites/TypeSymbols/" + newCard.getCardType(), typeof(Sprite)) as Sprite;


        /*myNewInstance.transform.SetParent(hand.transform.GetChild(cardSlot), false);
         * //  MyEnum.cultCard cardType = (MyEnum.cultCard)Enum.Parse(typeof(MyEnum.cultCard), cardName, true);
         * CultureCard thisCard = State.getCultureCard(cardName);
         * if (thisCard.getOriginator() == player.getIndex())
         * {
         *
         *  Transform tempItem = hand.transform.GetChild(cardSlot);
         *  Transform grandChild = tempItem.GetChild(0);
         *  Image img = grandChild.GetComponent<Image>();
         *  Debug.Log(img.name);
         *  img.transform.SetParent(hand.transform.GetChild(cardSlot), false);
         *  img.enabled = true;
         *  img.transform.SetAsLastSibling();
         * }
         * //Debug.Log("The Parent is: " + hand.transform.GetChild(cardSlot).name);
         * myNewInstance.transform.localPosition = new Vector3(0, 20, 0);
         * myNewInstance.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); */
    }
Beispiel #4
0
    private void updateCultureCardBook(MyEnum.cultCard newCard)
    {
        Transform hand = cultureCardPanel.transform;

        Debug.Log("Child count: " + hand.childCount);
        App    app      = UnityEngine.Object.FindObjectOfType <App>();
        Nation player   = State.getNations()[app.GetHumanIndex()];
        int    cardSlot = player.getCultureCards().Count - 1;

        placeCultureCardOnTable(newCard, cardSlot);
    }
Beispiel #5
0
 public static CultureCard getCultureCard(MyEnum.cultCard card)
 {
     for (int i = 0; i < cultureCardTypes.Count; i++)
     {
         if (cultureCardTypes[i].getCardName() == card)
         {
             return(cultureCardTypes[i]);
         }
     }
     return(cultureCardTypes[0]);
 }
Beispiel #6
0
 public static CultureCard getCultureCardByName(MyEnum.cultCard cardName)
 {
     foreach (CultureCard card in cultureCardTypes)
     {
         if (cardName == card.getCardName())
         {
             return(card);
         }
     }
     Debug.Log("Something went wrong");
     return(cultureCardTypes[0]);
 }
Beispiel #7
0
    private void getCultureCards()
    {
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        PlayerPayer.payForCultureCard(player);
        MyEnum.cultCard newCard = PlayerReceiver.collectCultureCard(player);


        MyEnum.Era era = State.era;
        if (player.getNumberGood(MyEnum.Goods.paper) < 1 || player.getAP() < 1)
        {
            drawCultureCards.interactable = false;
        }
        if (era != MyEnum.Era.Late && player.getNumberResource(MyEnum.Resources.spice) < 1)
        {
            drawCultureCards.interactable = false;
        }
        if (era != MyEnum.Era.Early)
        {
            if (player.getNumberGood(MyEnum.Goods.clothing) < 1)
            {
                drawCultureCards.interactable = false;
            }
        }
        if (era == MyEnum.Era.Late && player.getNumberGood(MyEnum.Goods.telephone) < 1)
        {
            drawCultureCards.interactable = false;
        }
        Stack <CultureCard>   remainingCultCards = State.getCultureDeck();
        HashSet <CultureCard> cultDeckSet        = new HashSet <CultureCard>(remainingCultCards);

        List <MyEnum.cultCard> playerCultHand = new List <MyEnum.cultCard>(player.getCultureCards());
        HashSet <CultureCard>  playerCultSet  = new HashSet <CultureCard>(remainingCultCards);

        foreach (MyEnum.cultCard cardName in playerCultHand)
        {
            CultureCard card = State.getCultureCardByName(cardName);
            playerCultSet.Add(card);
        }


        if (cultDeckSet.IsSubsetOf(playerCultSet))
        {
            drawCultureCards.interactable = false;
        }
        AP.text = player.getAP().ToString();
        // numberCultureCards.text = player.getCultureCards().Count.ToString();
        cultureLevel.text = player.getCulureLevel().ToString();
        updateCultureCardBook(newCard);
        showCultureHandPanel();
    }
Beispiel #8
0
    public CultureCard(MyEnum.cultCard cardName, MyEnum.cultCardType cultureType, MyEnum.cultMovement movement,
                       MyEnum.Era era, int prestigeBoost, int moraleBoost, int clothingQuality, int furnQuality, int happinessBoost)

    {
        this.cardName        = cardName;
        this.cultureType     = cultureType;
        this.movement        = movement;
        this.era             = era;
        this.prestigeBoost   = prestigeBoost;
        this.moraleBoost     = moraleBoost;
        this.clothingQuality = clothingQuality;
        this.furnQuality     = furnQuality;
        this.happinessBoost  = happinessBoost;
        this.originator      = -1;
        this.written         = cardName.ToString();
    }
Beispiel #9
0
    private void placeCultureCardOnTable(MyEnum.cultCard cardName, int cardSlot)
    {
        App    app    = UnityEngine.Object.FindObjectOfType <App>();
        Nation player = State.getNations()[app.GetHumanIndex()];

        Debug.Log(cardName.ToString());
        GameObject card          = Resources.Load <GameObject>("CultureCards/" + cardName.ToString()) as GameObject;
        GameObject myNewInstance = Instantiate(card);
        Transform  hand          = cultureCardPanel.transform;

        // Image[] images = cultureCardPanel.GetComponentsInChildren<Image>();
        // images[cardSlot].sprite = myNewInstance;
        myNewInstance.transform.SetParent(hand.transform.GetChild(cardSlot), false);
        //  MyEnum.cultCard cardType = (MyEnum.cultCard)Enum.Parse(typeof(MyEnum.cultCard), cardName, true);
        CultureCard thisCard = State.getCultureCard(cardName);

        if (thisCard.getOriginator() == player.getIndex())
        {
            /*  GameObject NewObj = new GameObject(); //Create the GameObject
             *  Image NewImage = NewObj.AddComponent<Image>(); //Add the Image Component script
             *   NewImage.sprite = Resources.Load<Sprite>("Sprites/MedalCulture") as Sprite; //Set the Sprite of the Image Component on the new GameObject
             *  NewObj.GetComponent<RectTransform>().SetParent(hand.transform.GetChild(cardSlot)); //Assign the newly created Image GameObject as a Child of the Parent Panel.
             *  NewObj.SetActive(true); //Activate the GameObject */

            Transform tempItem   = hand.transform.GetChild(cardSlot);
            Transform grandChild = tempItem.GetChild(0);
            Image     img        = grandChild.GetComponent <Image>();
            Debug.Log(img.name);
            img.transform.SetParent(hand.transform.GetChild(cardSlot), false);
            img.enabled = true;
            img.transform.SetAsLastSibling();
        }

        //Debug.Log("The Parent is: " + hand.transform.GetChild(cardSlot).name);
        myNewInstance.transform.localPosition = new Vector3(0, 20, 0);
        myNewInstance.transform.localScale    = new Vector3(0.5f, 0.5f, 0.5f);
    }
Beispiel #10
0
 public void removeCultureCard(MyEnum.cultCard card)
 {
     this.cultureCards.Remove(card);
 }
Beispiel #11
0
 public void addCultureCard(MyEnum.cultCard cardName)
 {
     this.cultureCards.Add(cardName);
 }