Esempio n. 1
0
    /// <summary>
    /// Used to create an actual GameObject and pass in the script's variables to it.
    /// </summary>
    public void Instantiate()
    {
        GameObject  tile_effect_prefab = Resources.Load(EFFECT_PREFAB_FILE, typeof(GameObject)) as GameObject;
        GameObject  tile_effect_obj    = ((GameObject)Instantiate(tile_effect_prefab, current_tile.transform.position + new Vector3(0, .5f * (current_tile.GetComponent <Tile>().height + 1), 0), Quaternion.identity));
        Tile_Effect tile_effect_script = tile_effect_obj.GetComponent <Tile_Effect>();

        tile_effect_obj.name    = name;
        tile_effect_script.type = type;
        //Debug.Log(type.ToString());
        if (type == Types.Heal)
        {
            tile_effect_obj.GetComponent <SpriteRenderer>().sprite = Resources.LoadAll <Sprite>("Sprites/Object Sprites/potions_transparent")[0];
        }
        if (type == Types.Status)
        {
            tile_effect_obj.GetComponent <SpriteRenderer>().sprite = Resources.LoadAll <Sprite>("Sprites/Object Sprites/potions_transparent")[1];
        }
        if (type == Types.Damage)
        {
            tile_effect_obj.GetComponent <SpriteRenderer>().sprite = Resources.LoadAll <Sprite>("Sprites/Object Sprites/potions_transparent")[2];
        }
        if (type == Types.Heal && (value[0] == Accepted_Shortcuts.CMPC.ToString() || value[0] == Accepted_Shortcuts.TMPC.ToString()))
        {
            tile_effect_obj.GetComponent <SpriteRenderer>().sprite = Resources.LoadAll <Sprite>("Sprites/Object Sprites/potions_transparent")[3];
        }
        tile_effect_script.value        = value;
        tile_effect_script.modifier     = modifier;
        tile_effect_script.duration     = duration;
        tile_effect_script.current_tile = current_tile;
        controller.curr_scenario.tile_effects.Add(tile_effect_obj);
        current_tile.GetComponent <Tile>().effect = tile_effect_obj;
    }
Esempio n. 2
0
 /// <summary>
 /// Constructor for the class taking in an existing Tile_Effect script.
 /// </summary>
 /// <param name="old_effect">The old Tile_Effect tp base this one out of.</param>
 public Tile_Effect(Tile_Effect old_effect)
 {
     name         = old_effect.name;
     type         = old_effect.type;
     value        = old_effect.value;
     duration     = old_effect.duration;
     modifier     = old_effect.modifier;
     current_tile = old_effect.current_tile;
 }
Esempio n. 3
0
    /// <summary>
    /// Creates a Tile_Effect to restore Mana at a Random tile.
    /// </summary>
    public void Spawn_Mana_Orb()
    {
        bool spawned = false;

        string[] value = { "CMPC", "5" };

        while (!spawned)
        {
            int        random_x = (int)(UnityEngine.Random.value * 100) % tile_grid.tiles.GetLength(0);
            int        random_y = (int)(UnityEngine.Random.value * 100) % tile_grid.tiles.GetLength(1);
            GameObject obj      = tile_grid.tiles[random_x, random_y].gameObject;
            Tile       tile     = obj.GetComponent <Tile>();
            if (tile.effect == null && tile.obj == null && tile.traversible)
            {
                Debug.Log("Spawned manawell at: " + random_x + "," + random_y);
                Tile_Effect effect = new Tile_Effect("Manawell", "Heal", 10, value, 1, obj);
                effect.Instantiate();
                spawned = true;
            }
        }
    }