FindById() public static method

public static FindById ( string id ) : GameObject
id string
return GameObject
Beispiel #1
0
    public void castSpell(GameObject target)
    {
        if (target.GetComponent("Enchantable") == null)
        {
            TraceLogger.LogKVtime("attempt", getSpellName());
            TraceLogger.LogKV("target", target.GetInstanceID().ToString() + ", " + target.name + ", " + target.transform.position);
            TraceLogger.LogKV("player", "" + ObjectManager.FindById("Me").transform.position);
            (GameObject.Find("Popup").GetComponent("Popup") as Popup).popup("Target (" + target.name + ") immune to magic.");
            SetHidden(false);
            return;
        }

        TraceLogger.LogKVtime("spell", getSpellName());
        ProgramLogger.LogKVtime("spell", getSpellName());
        TraceLogger.LogKV("target", target.GetInstanceID().ToString() + ", " + target.name + ", " + target.transform.position);
        TraceLogger.LogKV("player", "" + ObjectManager.FindById("Me").transform.position);

        June june = new June(target, file_name);

        SetHidden(false);

        item_name = "Blank";
        file_name = "";
        animate   = false;


        inventoryTexture = Resources.Load("Textures/Scroll") as Texture2D;


        (target.GetComponent("Enchantable") as Enchantable).enchant(june, delegate(GameObject t){ absorbSpell(t); });
    }
Beispiel #2
0
    public string getWithin(string id)
    {
        numTimesCalled++;
        GameObject parent = ObjectManager.FindById(id);

        if (parent.GetComponent <ObjectTracker>() == null)
        {
            return("");
        }

        List <string> ids = new List <string>();

        parent.GetComponent <ObjectTracker>().getWithin();

        foreach (GameObject child in parent.GetComponent <ObjectTracker>().getWithin())
        {
            if (child != null && child.GetComponent <Enchantable>() != null)
            {
                ids.Add(child.GetComponent <Enchantable>().getId());
            }
        }

        string[] id_array = ids.ToArray();
        foreach (string i in id_array)
        {
            logObj("area", i, id);
        }

        return(string.Join(";", id_array));
    }
Beispiel #3
0
    public string size(string id)
    {
        GameObject parent = ObjectManager.FindById(id);
        string     ret    = parent.collider.bounds.size.x + "," + parent.collider.bounds.size.y + "," + parent.collider.bounds.size.z;

        return(ret);
    }
Beispiel #4
0
    public static string getObjWith(string idCenter, string idName, double radius)
    {
        int        counter = 0;
        GameObject center  = ObjectManager.FindById(idCenter);
        GameObject named   = ObjectManager.FindById(idName);
        string     ids     = "";

        bool isFirst = true;

        if (named.GetComponent("Enchantable"))
        {
            Collider[] nearColliders = Physics.OverlapSphere(center.transform.position, (float)radius);
            foreach (Collider col in nearColliders)
            {
                if ((col.gameObject.GetComponent("Enchantable") != null) && ((named.name).Equals(col.transform.name)))
                {
                    counter++;
                    ids    += (isFirst) ? "" : ";";
                    isFirst = false;
                    ids    += ((col.gameObject.GetComponent("Enchantable") as Enchantable).getId());
                }
            }
        }
        return(ids);
    }
Beispiel #5
0
    public string getEnchantedChildrenOf(string id)
    {
        GameObject parent = ObjectManager.FindById(id);

        List <string> ids = new List <string>();

        foreach (Transform child in parent.transform)
        {
            if (child.gameObject.GetComponent <Enchantable>() != null)
            {
                ids.Add(child.GetComponent <Enchantable>().getId());
            }
        }

        string[] id_array = ids.ToArray();

        return(string.Join(";", id_array));
    }
Beispiel #6
0
    // log information about each object used in a spell
    public static string logObj(string when, string id, string spellname)
    {
        GameObject g = ObjectManager.FindById(id);

        // Object id, type/name, position, ground height at position, is on fire
        bool flaming = false;

        if (g.GetComponent <Flamable>())
        {
            flaming = g.GetComponent <Flamable>().isIgnited();
        }
        TraceLogger.LogKV("object" + when, spellname + ", " + id + ", " + g.name + ", " + g.transform.position + ", " + Terrain.activeTerrain.SampleHeight(g.transform.position) + ", " + flaming);
        Util util = new Util();

        if (when.Equals("end") && g.name.Equals("Flag(Clone)"))
        {
            util.getWithin(id);
        }

        return(g.name);
    }
Beispiel #7
0
    public static bool isOfType(string id, int type)
    {
        GameObject g = ObjectManager.FindById(id);

        switch (type)
        {
        case 1:        //rock
            return((g.name).StartsWith("rock_with_collider"));

        case 2:        //plant
            return((g.name).StartsWith("plant"));

        case 3:        //seed
            return((g.name).Contains("Seed"));

        case 4:        //rocksugar
            return((g.name).StartsWith("RockSugar"));

        case 5:        //flour
            return((g.name).StartsWith("Flour"));

        case 6:        //bread
            return((g.name).Contains("bread"));


        case 7:        //hasIgnited
            if (g.GetComponent <Flamable>())
            {
                return(g.GetComponent <Flamable>().isIgnited());
            }
            return(false);

        default:
            return(false);
        }
    }
Beispiel #8
0
 public void removeItem(GameObject item)
 {
     to_remove.Add(item);
     TraceLogger.LogKVtime("droppedoff", item.GetInstanceID() + ", " + item.name + ", " + item.transform.position + ", " + ObjectManager.FindById("Me").transform.position);
     if (DroppedOff != null)
     {
         DroppedOff(item);
     }
 }
Beispiel #9
0
 public void addItem(GameObject item)
 {
     items.Add(item);
     item_infos.Add(item, new ItemInfo());
     TraceLogger.LogKVtime("pickedup", item.GetInstanceID() + ", " + item.name + ", " + item.transform.position + ", " + ObjectManager.FindById("Me").transform.position);
     if (PickedUp != null)
     {
         PickedUp(item);
     }
 }
Beispiel #10
0
 public void reregister(string old_id, string new_id)
 {
     ObjectManager.Reregister(ObjectManager.FindById(old_id), old_id, new_id);
 }