Beispiel #1
0
    void Awake()
    {
        this.randomID = Random.Range(0, 10).ToString() + Random.Range(0, 10).ToString() + Random.Range(0, 10).ToString() + Random.Range(0, 10).ToString() + Random.Range(0, 10).ToString() + Random.Range(0, 10).ToString() + Random.Range(0, 10).ToString() + Random.Range(0, 10).ToString();

        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }
        DontDestroyOnLoad(this.gameObject);
    }
    protected void Start()
    {
        this.provIndentifier = provIndentifier + "_" + this.GetInstanceID().ToString();
        this.balanceApplier  = GameObject.Find("Balance").GetComponent <BalanceApplier>();
        this.temp_currHp     = this.stat_hp;
        GameObject provenanceObj = GameObject.Find("Provenance");

        this.animator          = this.GetComponent <Animator>();
        this.extractProvenance = this.GetComponent <ExtractProvenance>();
        this.scoreManager      = GameObject.Find("ScoreManager").GetComponent <ScoreManager>();
        //this.extractProvenance.influenceContainer = provenanceObj.GetComponent<InfluenceController>();
        //this.extractProvenance.provenance = provenanceObj.GetComponent<ProvenanceController>();
        this.rigidbody = this.GetComponent <Rigidbody2D>();
        ProjectilesLoad();
        acessPython = FindObjectOfType <AccessPython>();
    }
    void Start()
    {
        this.balanceApplier     = GameObject.Find("Balance").GetComponent <BalanceApplier>();
        this.transform.position = Camera.main.transform.position;
        this.extractProvenance  = this.GetComponent <ExtractProvenance>();
        Prov_Agent();
        float aux = cooldownSpawn;;

        if (cooldownSpawn < aux)
        {
            cooldownSpawn = aux;
        }

        // Register the types of power ups
        foreach (Object_Efeitos.Effects eff in System.Enum.GetValues(typeof(Object_Efeitos.Effects)))
        {
            itemController.RegisterType(eff.ToString());
        }
    }
    protected void Start()
    {
        this.balanceApplier = GameObject.Find("Balance").GetComponent <BalanceApplier>();
        if (this.CompareTag("Player_Shot"))
        {
            if (this.shooter.GetComponent <Characters_Player>().AttackBuff)
            {
                this.GetComponent <Animator>().SetTrigger("Crazy");
            }
            this.scoreManager = GameObject.Find("ScoreManager").GetComponent <ScoreManager>();
            this.damage      *= this.balanceApplier.DamageModifier;
            this.damage      *= this.shooter.GetComponent <Characters_Player>().DamageMultiplier;
        }

        if (this.CompareTag("Enemy_Shot"))
        {
            this.speed *= this.balanceApplier.difficultyMultipliers[this.prov_id];
        }

        this.rigidbody      = this.GetComponent <Rigidbody2D>();
        this.managers_spawn = GameObject.Find("SpawnManager").GetComponent <Managers_Spawn>();
    }
Beispiel #5
0
    private string GetArgs(string xmlName)
    {
        file = Application.dataPath + @"/" + xmlName;
        PlayerPrefs.SetString(AcessPython.KEYFILEXML, file);
        string args = "";

        for (int i = 0; i < KEYENEMY.Length; i++)
        {
            args += KEYENEMY[i] + " ";
        }
        BalanceApplier balance = FindObjectOfType <BalanceApplier>();

        if (balance != null)
        {
            for (int i = 0; i < KEYDIFMULTI.Length; i++)
            {
                args += KEYDIFMULTI[i];// + "=" + balance.difficultyMultipliers[i] + " ";
            }
        }

        return(args);
    }
Beispiel #6
0
    private static void FindChanges(string pyInstruction)
    {
        string[]       splitReturn = pyInstruction.Split(new char[] { ';' }), split;
        float          valueBalance;
        BalanceApplier balance = FindObjectOfType <BalanceApplier>();

        if (balance)
        {
            #region enemy
            for (int i = 0; i < KEYENEMY.Length; i++)
            {
                for (int j = 0; j < splitReturn.Length; j++)
                {
                    if (splitReturn[j].Contains(KEYENEMY[i]))
                    {
                        split = splitReturn[j].Split(new char[] { ':' });
                        if (split.Length > 1)
                        {
                            try
                            {
                                valueBalance = float.Parse(split[split.Length - 1]);
                                balance.ApplyDifficulty(i, valueBalance);
                                //print("__________");
                                //print(split[j] + " find -> " + valueBalance);
                            }
                            catch (System.Exception e)
                            {
                                print(e.Message);
                                print(i);
                                //print("Dont find value on:" + splitReturn[j]);
                            }
                        }
                    }
                }
            }
            #endregion

            #region dif multi

            string aux = "";
            for (int i = 0; i < KEYDIFMULTI.Length; i++)
            {
                for (int j = 0; j < splitReturn.Length; j++)
                {
                    if (splitReturn[j].Contains(KEYDIFMULTI[i]))
                    {
                        split = splitReturn[j].Split(new char[] { ':' });
                        if (split.Length > 1)
                        {
                            try
                            {
                                aux          = split[split.Length - 1];
                                valueBalance = float.Parse(aux);
                                balance.SetItemDistances(i, valueBalance);
                                //print("__________");
                                //print(split[0] + " find -> " + valueBalance);
                            }
                            catch (System.Exception e)
                            {
                                print(e.Message);
                                print(i);
                                //print("Dont find value on:" + splitReturn[j]);
                            }
                        }
                    }
                }
            }

            #endregion

            for (int j = 0; j < splitReturn.Length; j++)
            {
                if (splitReturn[j].Contains(PLAYERHITRATE))
                {
                    split = splitReturn[j].Split(new char[] { ':' });
                    if (split.Length > 1)
                    {
                        try
                        {
                            valueBalance = float.Parse(split[split.Length - 1]);
                            balance.ModifyDamage(valueBalance);
                            //print("__________");
                            //print(split[0] + " find -> " + valueBalance);
                        }
                        catch (System.Exception e)
                        {
                            print(e.Message);
                            print("Dont find value on:" + split[split.Length - 1]);
                        }
                    }
                }
            }
        }
    }
    public void WriteResults()
    {
        if (scoreManager == null)
        {
            this.scoreManager = GameObject.Find("ScoreManager").GetComponent <ScoreManager>();
        }
        if (spawnManager == null)
        {
            this.spawnManager = GameObject.Find("SpawnManager").GetComponent <Managers_Spawn>();
        }
        if (spawnItemManager == null)
        {
            this.spawnItemManager = GameObject.Find("SpawnManager").GetComponent <SpawnItemManager>();
        }

        BalanceApplier balanceApplier = FindObjectOfType <BalanceApplier>();
        string         path           = Application.dataPath + @"/Resources/" + this.GetComponent <BalanceApplier>().RandomID.ToString() + ".txt";
        bool           firstLine      = false;

        if (!File.Exists(path))
        {
            firstLine = true;
        }
        string       text   = "";
        StreamWriter writer = new StreamWriter(path, true);

        if (firstLine)
        {
            text += "Date" + ";" +
                    "Time Survived" + ";" +
                    "Score" + ";" +
                    "Straight Spawns" + ";" +
                    "Straight Kills" + ";" +
                    "Chaser Spawns" + ";" +
                    "Chaser Kills" + ";" +
                    "Round Spawns" + ";" +
                    "Round Kills" + ";" +
                    "Boomerang Spawns" + ";" +
                    "Boomerang Kills" + ";" +
                    "PowerUp Spawns" + ";" +
                    "PowerUp Got" + ";" +
                    "PowerDown Spawns" + ";" +
                    "PowerDown Got" + ";" +
                    "SpeedUp Spawns" + ";" +
                    "SpeedUp Got" + ";" +
                    "SpeedDown Spawns" + ";" +
                    "SpeedDown Got" + ";" +
                    "Straight Difficulty" + ";" +
                    "Straight Speed" + ";" +
                    "Chaser Difficulty" + ";" +
                    "Chaser Speed" + ";" +
                    "Chaser HP" + ";" +
                    "Round Difficulty" + ";" +
                    "Round Bullet Speed" + ";" +
                    "Round Prepare Time" + ";" +
                    "Boomerang Difficulty" + ";" +
                    "Boomerang Bullet Speed" + ";" +
                    "Boomerang Prepare Time" + ";" +
                    "Item1" + ";" +
                    "Item2" + ";" +
                    "Item3" + ";" +
                    "Item4" + ";" +
                    "PlayerDamage" + ";" + Environment.NewLine;
        }

        List <float> normalizedDifficulties = new List <float>();

        normalizedDifficulties.Add((balanceApplier.difficultyMultipliers[0] - balanceApplier.DifficultyMultipliersMinimum[0]) /
                                   (balanceApplier.difficultyMultipliersMaximum[0] - balanceApplier.difficultyMultipliersMinimum[0]));
        normalizedDifficulties.Add((balanceApplier.difficultyMultipliers[1] - balanceApplier.DifficultyMultipliersMinimum[1]) /
                                   (balanceApplier.difficultyMultipliersMaximum[1] - balanceApplier.difficultyMultipliersMinimum[1]));
        normalizedDifficulties.Add((balanceApplier.difficultyMultipliers[2] - balanceApplier.DifficultyMultipliersMinimum[2]) /
                                   (balanceApplier.difficultyMultipliersMaximum[2] - balanceApplier.difficultyMultipliersMinimum[2]));
        normalizedDifficulties.Add((balanceApplier.difficultyMultipliers[3] - balanceApplier.DifficultyMultipliersMinimum[3]) /
                                   (balanceApplier.difficultyMultipliersMaximum[3] - balanceApplier.difficultyMultipliersMinimum[3]));


        text += DateTime.Now.ToString() + ";" +
                this.scoreManager.ElapsedTime + ";" +
                this.scoreManager.Score + ";" +
                this.spawnManager.EnemySpawns[0] + ";" +
                this.scoreManager.EnemyKills[0] + ";" +
                this.spawnManager.EnemySpawns[1] + ";" +
                this.scoreManager.EnemyKills[1] + ";" +
                this.spawnManager.EnemySpawns[2] + ";" +
                this.scoreManager.EnemyKills[2] + ";" +
                this.spawnManager.EnemySpawns[3] + ";" +
                this.scoreManager.EnemyKills[3] + ";" +

                this.spawnItemManager.SpawnedItems[0] + ";" +
                this.scoreManager.ItemsGot[0] + ";" +
                this.spawnItemManager.SpawnedItems[1] + ";" +
                this.scoreManager.ItemsGot[1] + ";" +
                this.spawnItemManager.SpawnedItems[2] + ";" +
                this.scoreManager.ItemsGot[2] + ";" +
                this.spawnItemManager.SpawnedItems[3] + ";" +
                this.scoreManager.ItemsGot[3] + ";" +

                normalizedDifficulties[0] + ";" +
                this.enemyPrefabs[0].GetComponent <Characters_Enemies>().Stat_Speed *balanceApplier.difficultyMultipliers[0] + ";" +

                normalizedDifficulties[1] + ";" +
                this.enemyPrefabs[1].GetComponent <Characters_Enemies>().Stat_Speed *balanceApplier.difficultyMultipliers[1] + ";" +
                this.enemyPrefabs[1].GetComponent <Characters_Global>().Stat_HP *balanceApplier.difficultyMultipliers[1] + ";" +

                normalizedDifficulties[2] + ";" +
                this.bulletPrefab.GetComponent <Projectiles_Global>().Speed *balanceApplier.difficultyMultipliers[2] + ";" +
                this.enemyPrefabs[2].GetComponent <Enemies_RoundShooter>().PrepareTime *balanceApplier.difficultyMultipliers[2] + ";" +

                normalizedDifficulties[3] + ";" +
                this.bulletPrefab.GetComponent <Projectiles_Global>().Speed *balanceApplier.difficultyMultipliers[3] + ";" +
                this.enemyPrefabs[3].GetComponent <Enemies_Irregular>().PrepareTime *balanceApplier.difficultyMultipliers[3] + ";" +

                balanceApplier.itemDistances[0] + ";" +
                balanceApplier.itemDistances[1] + ";" +
                balanceApplier.itemDistances[2] + ";" +
                balanceApplier.itemDistances[3] + ";" +
                balanceApplier.DamageModifier + ";";

        /*
         * if (balanceApplier)
         * {
         *  string[] enemy = new string[balanceApplier.ChangedDifficultyMultiplier.Length];
         *
         *  for (int i = 0; i < enemy.Length; i++)
         *  {
         *      enemy[i] = "enemy " + (i + 1);
         *  }
         *
         *  for (int i = 0; i < balanceApplier.ChangedDifficultyMultiplier.Length; i++)
         *  {
         *      text += enemy[i % enemy.Length] + ": " + balanceApplier.ChangedDifficultyMultiplier[i] + Environment.NewLine;
         *  }
         *
         *  string[] item = new string[balanceApplier.ChangedItemDistances.Length];
         *
         *  for (int i = 0; i < item.Length; i++)
         *  {
         *      item[i] = "item " + (i + 1);
         *  }
         *
         *  for (int i = 0; i < balanceApplier.ChangedItemDistances.Length; i++)
         *  {
         *      text += item[i % item.Length] + ": " + balanceApplier.ChangedItemDistances[i] + Environment.NewLine;
         *  }
         *
         *  string tag = "Player Damage";
         *  text += tag + ": " + balanceApplier.ChangedDamageModifier + Environment.NewLine;
         *
         * }
         * else
         * {
         *  print("Dont find BalanceApplier");
         * }*/

        writer.WriteLine(text);
        writer.Close();
    }