Example #1
0
    public GameObject Create(Vector3 vector3, string name, [DefaultValue(ArticlesType.ARTICLES)] ArticlesType type)
    {
        string pex = "";

        switch (type)
        {
        case ArticlesType.ARTICLES: pex = "Warehouse/Articles/";
            break;

        case ArticlesType.BUILDS:
            pex = "Warehouse/Builds/";
            break;

        case ArticlesType.ENEMYS:
            pex = "Warehouse/Enemys/";
            break;

        case ArticlesType.NEUTRALS:
            pex = "Warehouse/Neutrals/";
            break;

        case ArticlesType.NPCS:
            pex = "Warehouse/Npcs/";
            break;
        }
        GameObject art = GameObject.Instantiate <GameObject>(Resources.Load <GameObject>(pex + name + ".prefab"), vector3, Quaternion.identity);

        return(art);
    }
Example #2
0
    public ArticlesAttachment GetAtriclesInfo(string name, ArticlesType type = ArticlesType.ARTICLES)
    {
        //用unity的内存指针去找,效率待测
        string p = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(Enum.GetName(typeof(ArticlesType), type));

        return(Resources.Load <GameObject>("Warehouse/" + p + "/" + name + ".prefab").GetComponent <ArticlesAttachment>());
    }
Example #3
0
    public GameObject Create(Vector3 vector3, int id, ArticlesType type = ArticlesType.ARTICLES)
    {
        GameObject[] cache = null;
        switch (type)
        {
        case ArticlesType.ARTICLES: cache = articles;
            break;

        case ArticlesType.BUILDS: cache = builds;
            break;

        case ArticlesType.ENEMYS: cache = enemys;
            break;

        case ArticlesType.NEUTRALS: cache = neutrals;
            break;

        case ArticlesType.NPCS: cache = npcs;
            break;
        }
        foreach (var item in cache)
        {
            if (item.GetComponent <ArticlesAttachment>().id.Equals(id))
            {
                GameObject art = GameObject.Instantiate <GameObject>(item, vector3, Quaternion.identity);
                return(art);
            }
        }
        return(null);
    }
Example #4
0
    public ArticlesAttachment GetAtriclesInfo(int id, ArticlesType type = ArticlesType.ARTICLES)
    {
        GameObject[] cache = null;
        switch (type)
        {
        case ArticlesType.ARTICLES:
            cache = articles;
            break;

        case ArticlesType.BUILDS:
            cache = builds;
            break;

        case ArticlesType.ENEMYS:
            cache = enemys;
            break;

        case ArticlesType.NEUTRALS:
            cache = neutrals;
            break;

        case ArticlesType.NPCS:
            cache = npcs;
            break;
        }
        foreach (var item in cache)
        {
            if (item.GetComponent <ArticlesAttachment>().id.Equals(id))
            {
                return(item.GetComponent <ArticlesAttachment>());
            }
        }
        return(null);
    }