コード例 #1
0
    void LoadCharacterImg()
    {
        //角色图片路径
        string headImgPath    = "Characters/Head/";
        string playerBodyPath = "Characters/Body/";


        headImg    = new Sprite[4, 2];
        playerBody = new GameObject[4, 2];

        occupationName = new string[4];
        //加载资源

        for (int i = 0; i < headImg.GetLength(0); i++)
        {
            for (int j = 0; j < headImg.GetLength(1); j++)
            {
                OccupationType type       = (OccupationType)i;
                Gender         gender     = (Gender)j;
                string         sex        = gender.ToString();
                string         occupation = type.ToString();
                //头像图片
                headImg[i, j] = ResourceManager.Instance.Load <Sprite>(headImgPath + occupation + "_" + sex);
                //大图
                playerBody[i, j] = ResourceManager.Instance.Load(playerBodyPath + occupation + "_" + sex);

                switch (type)
                {
                case OccupationType.Warrior:
                    occupationName[i] = "战士";
                    break;

                case OccupationType.Support:

                    occupationName[i] = "辅助";
                    break;

                case OccupationType.Mage:

                    occupationName[i] = "法师";
                    break;

                case OccupationType.Assassin:
                    occupationName[i] = "刺客";
                    break;

                default:
                    break;
                }
            }
        }
    }
コード例 #2
0
    public GameObject  CreateEffectGo(SkillID path)
    {
        GameObject     effectGo   = null;
        OccupationType type       = (OccupationType)PlayerInfoModel.Instance.SelectedPlayer.occupation;
        string         occupation = type.ToString();

        if (skillEffectGoDic.ContainsKey(path))
        {
            effectGo = skillEffectGoDic[path];
            effectGo.SetActive(true);
            Destroy script = effectGo.GetComponent <Destroy>();
            script.ReAwake();
        }

        else
        {
            //生成新的对象
            GameObject effectPrefab = ResourceManager.Instance.Load("Effect_Prefeb/" + occupation + "_" + path.ToString());
            effectGo = GameObject.Instantiate(effectPrefab);
            skillEffectGoDic.Add(path, effectGo);
        }

        return(effectGo);
    }