Exemple #1
0
 public void SetValue(float value, GameObject gameObject, string param)
 {
     // print("tutaj 111 "+value);
     gameObject.transform.Find("Value").GetComponent <Text>().text = value.ToString();
     currentEnemyStatisticsSerializable.GetType().GetField(param).SetValue(currentEnemyStatisticsSerializable, value);
     CanBeSaved();
 }
Exemple #2
0
    public void desctiptionSetAndButton(Enemy enemy, bool nightEnemy)
    {
        currentEnemy = enemy;
        CanBeSaved();
        //inputNameField.on
        //enemy = GameObject.Instantiate(enemy);
        //currentEnemy = enemy.gameObject;
        // print(enemy.GetType());
        //  print(enemy.gameObject.name);
        //print(enemy.enemyStatistics.GetType());
        currentEnemyStatisticsSerializable            = enemy.enemyStatistics.ToSerializable();
        currentEnemyStatisticsSerializable.nightEnemy = nightEnemy;
        //print(currentEnemyStatisticsSerializable.night);
        //  print(nightEnemy);


        foreach (Transform child in enemyStats.transform)
        {
            Destroy(child.gameObject);
        }
        //print(enemy.enemyStatistics.ToSerializable(enemy.gameObject.name).GetType());
        //print(enemy.enemyStatistics.GetType());
        //print(enemy.enemyStatistics.ToSerializable(enemy.gameObject.name).enemyPrefabName);
        //var ins = ScriptableObject.CreateInstance<typeof(enemy.GetType())>()

        foreach (var param in currentEnemyStatisticsSerializable.GetType().GetFields())//.GetConstructors()[0].GetParameters()
        {
            if (param.Name != "color" && param.Name != "lootTable" && param.Name != "enemyPrefabName" && param.Name != "name" && param.Name != "night" && param.Name != "nightEnemy" &&
                param.Name != "power" && param.Name != "inGame")
            {
                GameObject empty;
                // print(param.Name);
                empty = Instantiate(statSlider);
                empty.transform.SetParent(enemyStats.transform, false);
                empty.GetComponent <Image>().color = Color.Lerp(Color.blue, Color.white, 0.8f);
                empty.transform.Find("Text").GetComponent <Text>().text      = param.Name;
                empty.transform.Find("Slider").GetComponent <Slider>().value = (float)currentEnemyStatisticsSerializable.GetType().GetField(param.Name).GetValue(currentEnemyStatisticsSerializable);
                SetValue(empty.transform.Find("Slider").GetComponent <Slider>().value, empty, param.Name);
                empty.transform.Find("Slider").GetComponent <Slider>().onValueChanged.AddListener((value) => { SetValue(value, empty, param.Name); });
            }
            else if (param.Name == "color")
            {
                GameObject empty;
                // print(param.Name);
                empty = Instantiate(colorSlider);
                empty.transform.SetParent(enemyStats.transform, false);
                empty.GetComponent <Image>().color = Color.Lerp(Color.blue, Color.white, 0.8f);
                empty.transform.Find("Text").GetComponent <Text>().text = param.Name;

                SetColorValue(empty, param.Name);
                empty.transform.Find("red").GetComponent <Slider>().onValueChanged.AddListener((value) => { SetColorValue(empty, param.Name); });
                empty.transform.Find("green").GetComponent <Slider>().onValueChanged.AddListener((value) => { SetColorValue(empty, param.Name); });
                empty.transform.Find("blue").GetComponent <Slider>().onValueChanged.AddListener((value) => { SetColorValue(empty, param.Name); });
            }
            else if (param.Name == "lootTable")
            {
                GameObject empty;
                // print(param.Name);
                empty = Instantiate(lootOption);
                empty.transform.SetParent(enemyStats.transform, false);
                empty.GetComponent <Image>().color = Color.Lerp(Color.blue, Color.white, 0.8f);
                empty.transform.Find("Text").GetComponent <Text>().text = param.Name;
                lootableName = empty.transform.Find("LootTableName").GetComponent <TextMeshProUGUI>();
                //lootableName.text= currentEnemyStatisticsSerializable.lootTable.name;
                createLoot.currentLootTable = currentEnemyStatisticsSerializable.lootTable.ToNonSerializable();
                empty.transform.Find("New").GetComponent <Button>().onClick.AddListener(() => createLoot.OpenWindow());
                //  empty.transform.Find("red").GetComponent<Slider>().onValueChanged.AddListener((value) => { SetColorValue(empty); });
                //  empty.transform.Find("green").GetComponent<Slider>().onValueChanged.AddListener((value) => { SetColorValue(empty); });
                //  empty.transform.Find("blue").GetComponent<Slider>().onValueChanged.AddListener((value) => { SetColorValue(empty); });
            }
        }
    }