Ejemplo n.º 1
0
    //Spawn enemies based on our budget
    public void init_enemies()
    {
        budget = max_budget;
        GameObject[] e_palette = GameObject.Find("Palette").GetComponent <palette>().enemies;
        int          i         = 0;

        if (p_start_health == 0)
        {
            p_start_health = 10;
        }
        else
        {
            p_start_health = util_ref.p_manager.cur_player.GetComponent <rpg_character>().stats.get_stat_value("Health");
        }
        //Set count of enemy classes to zero
        s_count = 0;
        a_count = 0;
        m_count = 0;

        //Spawn at least one enemy, and no more than 50, as an arbitrary upper limit
        while (budget > 0 && i < 50)
        {
            GameObject new_enemy = GameObject.Instantiate(e_palette[Random.Range(0, e_palette.Length)]);
            new_enemy.name = "Enemy " + (i++).ToString();
            features.spawn_feature(new_enemy);
            enemies.Add(new_enemy);
            budget -= get_enemy_cost(new_enemy);
        }
        //If we broke 50 enemies, something probably went wrong
        if (i > 50)
        {
            Debug.LogError("Spawning enemies timed out");
        }
    }
Ejemplo n.º 2
0
    public GameObject init_player()
    {
        GameObject new_player = GameObject.Instantiate(player_holder);

        features.spawn_feature(new_player);
        cur_player = new_player;
        p_script   = cur_player.GetComponent <player_script>();

        GameObject new_torch = GameObject.Instantiate(torch_prefab);

        new_torch.transform.SetParent(new_player.transform);
        new_torch.transform.localPosition = new Vector3(.5f, .5f, -2f);

        return(new_player);
    }