Example #1
0
    void GetMonster()
    {
        var           enemPlaceholder = enemiesPlaceholders.GetComponentsInChildren <Image>();
        List <string> auxList         = new List <string>();

        auxList.AddRange(tiers);
        foreach (var item in enemPlaceholder)
        {
            if (item.name == monsterSelectedName || item.name == "Enemy")
            {
                item.name           = enemies[monsterIndex].name;
                item.sprite         = enemies[monsterIndex].GetComponent <SpriteRenderer>().sprite;
                item.preserveAspect = true;
                if (!order[item.name].ContainsKey(item.GetComponent <PlaceholderTier>().id))
                {
                    PlaceholderTier save = new PlaceholderTier();
                    //gets random tier for monster
                    var tierName = auxList[UnityEngine.Random.Range(0, auxList.Count)];
                    item.GetComponent <PlaceholderTier>().tierName = tierName;
                    save.tierName      = tierName;
                    save.id            = item.GetComponent <PlaceholderTier>().id;
                    save.monsterName   = item.name;
                    save.mostDifferent = false;
                    auxList.Remove(tierName);
                    //adds the monster to dic to save order
                    order[item.name].Add(item.GetComponent <PlaceholderTier>().id, save);
                }
                else
                {
                    item.GetComponent <PlaceholderTier>().tierName = order[item.name][item.GetComponent <PlaceholderTier>().id].tierName;
                    if (order[item.name][item.GetComponent <PlaceholderTier>().id].orderNumber != 0)
                    {
                        Mute(item.GetComponentInChildren <InputField>().onValueChanged);
                        item.GetComponentInChildren <InputField>().text   = order[item.name][item.GetComponent <PlaceholderTier>().id].orderNumber.ToString();
                        item.GetComponent <PlaceholderTier>().orderNumber = order[item.name][item.GetComponent <PlaceholderTier>().id].orderNumber;
                        Unmute(item.GetComponentInChildren <InputField>().onValueChanged);

                        if (order[item.name][item.GetComponent <PlaceholderTier>().id].mostDifferent)
                        {
                            Mute(item.GetComponentInChildren <Toggle>().onValueChanged);
                            item.GetComponent <PlaceholderTier>().mostDifferent = order[item.name][item.GetComponent <PlaceholderTier>().id].mostDifferent;
                            item.GetComponentInChildren <Toggle>().isOn         = order[item.name][item.GetComponent <PlaceholderTier>().id].mostDifferent;
                            Unmute(item.GetComponentInChildren <Toggle>().onValueChanged);
                        }
                    }
                }

                //logs
                if (!logs[item.name].logs.Contains(item.name))
                {
                    logs[item.name].logs.Add(item.name);
                }
            }
        }
        monsterSelectedName = enemies[monsterIndex].name;
    }
Example #2
0
    private void ReadOrders()
    {
        foreach (var order in _orders)
        {
            string[] fileContent = File.ReadAllLines(order);
            foreach (var str in fileContent)
            {
                try
                {
                    PlaceholderTier obj = JsonUtility.FromJson <PlaceholderTier>(str);
                    if (!_finalData.ContainsKey(obj.monsterName))
                    {
                        _finalData.Add(obj.monsterName, new OrderData());
                    }
                    _finalData[obj.monsterName]._monstDifferent.Add(obj.tierName, 0);
                }
                catch (ArgumentException e)
                {
                    Debug.Log("Erro: " + str + " " + e);
                    continue;
                }
            }

            //after the file is read
            //count number of correct order for monsters
            for (int i = 1; i < fileContent.Length; i = i + 3)
            {
                try
                {
                    PlaceholderTier obj  = JsonUtility.FromJson <PlaceholderTier>(fileContent[i]);
                    PlaceholderTier obj1 = JsonUtility.FromJson <PlaceholderTier>(fileContent[i + 1]);
                    PlaceholderTier obj2 = JsonUtility.FromJson <PlaceholderTier>(fileContent[i + 2]);
                    if ((obj.tierName == "default" && obj.orderNumber == 1 || obj.tierName == "Tier1" && obj.orderNumber == 2 || obj.tierName == "Tier2" && obj.orderNumber == 3) &&
                        (obj1.tierName == "default" && obj1.orderNumber == 1 || obj1.tierName == "Tier1" && obj1.orderNumber == 2 || obj1.tierName == "Tier2" && obj1.orderNumber == 3) &&
                        (obj2.tierName == "default" && obj2.orderNumber == 1 || obj2.tierName == "Tier1" && obj2.orderNumber == 2 || obj2.tierName == "Tier2" && obj2.orderNumber == 3))
                    {
                        _finalData[obj.monsterName]._correctOrder++;
                    }
                }
                catch (ArgumentException e)
                {
                    Debug.Log("Erro: " + e);
                    continue;
                }
            }

            //count the most different monster
            for (int i = 1; i < fileContent.Length; i++)
            {
                try
                {
                    PlaceholderTier obj = JsonUtility.FromJson <PlaceholderTier>(fileContent[i]);
                    if (obj.mostDifferent == true)
                    {
                        _finalData[obj.monsterName]._monstDifferent[obj.tierName]++;
                    }
                }
                catch (ArgumentException e)
                {
                    Debug.Log("Erro: " + e);
                    continue;
                }
            }
        }
    }