Ejemplo n.º 1
0
    public void InitCards()
    {
        goDeck = Instantiate(prefabDeck, menuUi.levelDeckPosition);
        goDeck.transform.localPosition = Vector3.zero;

        for (int i = 0; i < leveldb.listLevels.Count; i++)
        {
            if (GameManager.Instance.PersistenceLoader.Pd.dicPersistenceLevels[leveldb.listLevels[i].id.ToString()] == true)
            {
                // Instanciation des cartes de level
                GameObject goCardLevel = Instantiate(prefabLevelCard, goDeck.transform);
                goCardLevel.transform.localPosition = Vector3.zero;
                goCardLevel.transform.localRotation = GoDeck.transform.GetChild(0).rotation;
                goCardLevel.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = Translater.LevelName(leveldb.listLevels[i].name);
                switch (leveldb.listLevels[i].difficulty)
                {
                case "Easy":
                    goCardLevel.transform.GetChild(0).GetChild(1).GetComponent <Image>().sprite = Translater.LevelDifficulty(1);
                    break;

                case "Medium":
                    goCardLevel.transform.GetChild(0).GetChild(1).GetComponent <Image>().sprite = Translater.LevelDifficulty(2);
                    break;

                case "Hard":
                    goCardLevel.transform.GetChild(0).GetChild(1).GetComponent <Image>().sprite = Translater.LevelDifficulty(3);
                    break;

                default:
                    goCardLevel.transform.GetChild(0).GetChild(1).GetComponent <Image>().sprite = Translater.LevelDifficulty(0);
                    break;
                }

                goCardLevel.transform.GetChild(0).GetChild(2).GetComponent <Text>().text = leveldb.listLevels[i].nbPawn;
                // TODO Maybe add description to level
                goCardLevel.GetComponent <CardLevel>().levelIndex = leveldb.listLevels[i].id;
                goCardLevel.SetActive(false);
                goCardsLevels.Add(goCardLevel);

                List <GameObject> cardChildren = new List <GameObject>();

                if (GameManager.Instance.PersistenceLoader.Pd.dicPersistenceDecks[leveldb.listLevels[i].deckId.ToString()] == true)
                {
                    QuestDeckData qdd = GameManager.Instance.QuestDeckDataBase.GetQuestDeckDataByID(leveldb.listLevels[i].deckId);

                    GameObject goQuestCard = Instantiate(prefabMainQuestCard, goCardLevel.transform);
                    goQuestCard.transform.localPosition = Vector3.zero;
                    //goQuestCard.GetComponentInChildren<Text>().text = "";/* GameManager.Instance.QuestDeckDataBase.GetDeckByID(leveldb.listLevels[i].deckId).DeckName;*/
                    goQuestCard.SetActive(false);
                    cardChildren.Add(goQuestCard);

                    for (int k = 0; k < qdd.secondaryQuests.Count; k++) // Instantiations des cartes de quete annexe
                    {
                        goQuestCard = Instantiate(prefabSideQuestCard, goCardLevel.transform);
                        goQuestCard.transform.localPosition = Vector3.zero;
                        /*          goQuestCard.GetComponentInChildren<Text>().text = ""/*qdd.secondaryQuests[k].idQuest; // TODO Add real name and description to quests*/
                        goQuestCard.SetActive(false);
                        cardChildren.Add(goQuestCard);
                    }

                    for (int l = 0; l < leveldb.listLevels[i].listEventsId.Count; l++)
                    {
                        if (GameManager.Instance.PersistenceLoader.Pd.dicPersistenceEvents[GameManager.Instance.EventDataBase.listEvents[l].id] == true)
                        {
                            GameObject goEventCard = Instantiate(prefabEventCard, goCardLevel.transform);
                            goEventCard.transform.localPosition = Vector3.zero;

                            /*    goEventCard.GetComponentInChildren<Text>().text = ""*//*GameManager.Instance.EventDataBase.GetEventById(leveldb.listLevels[i].listEventsId[l]).id + "\n" +
                             *                                                      GameManager.Instance.EventDataBase.GetEventById(leveldb.listLevels[i].listEventsId[l]).description;*/
                            goEventCard.SetActive(false);
                            cardChildren.Add(goEventCard);
                        }
                    }
                }
                GoCardChildren.Add(cardChildren);
            }
        }
    }