Esempio n. 1
0
    public GlobalPlayer LoadPlayer_(string playerName, out GlobalPlayerLoaderResult result)
    {
        if (string.IsNullOrEmpty(playerName))
        {
            result = GlobalPlayerLoaderResult.ParamError;
            return(null);
        }
        var trans = this.transform;
        DefaultLoaderPlayer finder = null;

        for (int i = 0; i < trans.childCount; ++i)
        {
            var child = trans.GetChild(i);
            DefaultLoaderPlayer loader = child.GetComponent <DefaultLoaderPlayer>();
            if (loader == null)
            {
                continue;
            }
            var plyName = loader.GetPlayerName();
            if (string.Compare(plyName, playerName) == 0)
            {
                finder = loader;
                break;
            }
        }
        if (finder == null)
        {
            GameObject obj = new GameObject(playerName, typeof(DefaultLoaderPlayer));
            obj.transform.SetParent(this.transform, false);
            finder = obj.GetComponent <DefaultLoaderPlayer>();
        }
        GlobalPlayer ret = LoadPlayer(finder, out result);

        return(ret);
    }
Esempio n. 2
0
    public bool HasLoadPlayer(DefaultLoaderPlayer loaderPlayer)
    {
        if (loaderPlayer == null)
        {
            return(false);
        }
        string playerName = loaderPlayer.GetPlayerName();

        return(m_PlayerDict.ContainsKey(playerName));
    }
Esempio n. 3
0
    public void Init()
    {
        Clear();

        m_ImgLib = new ImageLibrary(Is32BitPallet);
        DefaultLoaderPlayer loadPlayer = GetComponent <DefaultLoaderPlayer> ();
        var    player     = loadPlayer.GetGlobalPayer();
        string spriteName = GlobalConfigMgr.GetConfigFileNameNoExt(player.PlayerCfg.Files.sprite);

        LoadOk = m_ImgLib.LoadChar(loadPlayer.GetPlayerName(), player.AirCfg, spriteName);
    }
Esempio n. 4
0
    public bool Load(DefaultLoaderPlayer loaderPlayer)
    {
        if (m_IsInited)
        {
            return(true);
        }

        if (loaderPlayer == null)
        {
            return(false);
        }
        GlobalPlayerLoaderResult result;
        var player = GlobalConfigMgr.GetInstance().LoadPlayer(loaderPlayer, out result);

        if (player == null || player.PlayerCfg == null || !player.PlayerCfg.IsVaild || player.PlayerCfg.Files == null)
        {
            return(false);
        }

        string soundName = player.PlayerCfg.Files.sound;

        if (string.IsNullOrEmpty(soundName))
        {
            return(false);
        }
        soundName = GlobalConfigMgr.GetConfigFileNameNoExt(soundName);
        if (string.IsNullOrEmpty(soundName))
        {
            return(false);
        }

        string playerName = loaderPlayer.GetPlayerName();

        if (string.IsNullOrEmpty(playerName))
        {
            return(false);
        }
        string fileName = string.Format("{0}@{1}/{2}.snd.bytes", AppConfig.GetInstance().PlayerRootDir, playerName, soundName);

        byte[] buffer = AppConfig.GetInstance().Loader.LoadBytes(fileName);
        if (buffer == null || buffer.Length <= 0)
        {
            return(false);
        }

        m_IsInited = true;
        IsLoadedOk = LoadFromBuffer(buffer);
        return(IsLoadedOk);
    }
Esempio n. 5
0
    public GlobalPlayer LoadPlayer(DefaultLoaderPlayer loaderPlayer, out GlobalPlayerLoaderResult result)
    {
        if (loaderPlayer == null)
        {
            result = GlobalPlayerLoaderResult.ParamError;
            return(null);
        }
        string       playerName = loaderPlayer.GetPlayerName();
        GlobalPlayer ret        = LoadPlayer(playerName, out result, loaderPlayer.CnsName);

        if (ret != null)
        {
        }
        return(ret);
    }