コード例 #1
0
    /// <summary>
    /// 告诉玩家去哪里
    /// </summary>
    /// <param name="targetPos"></param>
    public void MoveTo(Vector3 targetPos)
    {
        //如果目标点不是原点 进行移动
        if (targetPos == Vector3.zero)
        {
            return;
        }
        TargetPos = targetPos;
        //CurrRoleFSMMgr.ChangeState(RoleState.Run);

        //计算路径
        m_seeker.StartPath(transform.position, targetPos, (Path p) =>
        {
            if (!p.error)
            {
                AStarPath = (ABPath)p;

                if (Vector3.Distance(AStarPath.endPoint, new Vector3(AStarPath.originalEndPoint.x, AStarPath.endPoint.y, AStarPath.originalEndPoint.z)) > 1f)
                {
                    AppDebug.Log("不能到达目标点");
                    AStarPath = null;
                }

                AStartCurrWayPoint = 1;
                CurrRoleFSMMgr.ChangeState(RoleState.Run);
            }
            else
            {
                //寻路失败
                AppDebug.LogError(p.errorLog);
                AStarPath = null;
            }
        });
    }
コード例 #2
0
    /// <summary>
    /// 设置进度条的值
    /// </summary>
    /// <param name="value"></param>
    public void SetProgressValue(float value)
    {
        if (m_SliderProgress == null || m_TextProgress == null)
        {
            AppDebug.LogError("m_SliderProgress或m_TextProgress没配置");
            return;
        }

        m_SliderProgress.value = value;
        m_TextProgress.text    = string.Format("{0}%", (int)(value * 100));

        //m_ProgressLight.transform.localPosition = new Vector3(880 * value, 0, 0);
    }
コード例 #3
0
 protected override void OnStart()
 {
     base.OnStart();
     try
     {
         if (!CurrCanvas)
         {
             CurrCanvas       = this.transform.GetChild(0).GetComponent <Canvas>();
             Container_Center = transform.Find("Container_Center");
         }
     }
     catch (Exception e)
     {
         AppDebug.LogError(e.Message);
         AppDebug.LogError("请检查CurrCanvas或Container_Center有没有配置");
     }
 }
コード例 #4
0
    private IEnumerator DownloadData()
    {
        if (NeedDownloadCount == 0)
        {
            yield break;
        }
        m_CurrDownloadData = m_List[0];

        string dataUrl = DownloadMgr.DownloadUrl + m_CurrDownloadData.FullName; //资源下载路径

        AppDebug.Log("dataUrl=" + dataUrl);

        int lastIndex = m_CurrDownloadData.FullName.LastIndexOf('\\');

        if (lastIndex > -1)
        {
            //短路径 用于创建文件夹
            string path = m_CurrDownloadData.FullName.Substring(0, lastIndex);

            //得到本地路径
            string localFilePath = DownloadMgr.Instance.LocalFilePath + path;

            if (!Directory.Exists(localFilePath))
            {
                Directory.CreateDirectory(localFilePath);
            }
        }


        WWW www = new WWW(dataUrl);

        float timeout  = Time.time;
        float progress = www.progress;

        while (www != null && !www.isDone)
        {
            if (progress < www.progress)
            {
                timeout  = Time.time;
                progress = www.progress;

                m_CurrDownloadSize = (int)(m_CurrDownloadData.Size * progress);
            }

            if ((Time.time - timeout) > DownloadMgr.DownloadTimeOut)
            {
                AppDebug.LogError("下载失败 超时");
                yield break;
            }

            yield return(null); //一定要等一帧
        }

        yield return(www);

        if (www != null && www.error == null)
        {
            using (FileStream fs = new FileStream(DownloadMgr.Instance.LocalFilePath + m_CurrDownloadData.FullName, FileMode.Create, FileAccess.ReadWrite))
            {
                fs.Write(www.bytes, 0, www.bytes.Length);
            }
        }

        //下载成功
        m_CurrDownloadSize = 0;
        m_DownloadSize    += m_CurrDownloadData.Size;

        //写入本地文件
        DownloadMgr.Instance.ModifyLocalData(m_CurrDownloadData);

        m_List.RemoveAt(0);
        CompleteCount++;

        if (m_List.Count == 0)
        {
            m_List.Clear();
        }
        else
        {
            IsStartDownload = true;
        }
    }
コード例 #5
0
    public IEnumerator DownloadData(DownloadDataEntity currDownloadData, Action <bool> onComplete)
    {
        string dataUrl = DownloadMgr.DownloadUrl + currDownloadData.FullName; //资源下载路径

        AppDebug.Log("dataUrl=" + dataUrl);

        //短路径 用于创建文件夹
        string path = currDownloadData.FullName.Substring(0, currDownloadData.FullName.LastIndexOf('\\'));

        //得到本地路径
        string localFilePath = DownloadMgr.Instance.LocalFilePath + path;

        if (!Directory.Exists(localFilePath))
        {
            Directory.CreateDirectory(localFilePath);
        }

        WWW www = new WWW(dataUrl);

        float timeout  = Time.time;
        float progress = www.progress;

        while (www != null && !www.isDone)
        {
            if (progress < www.progress)
            {
                timeout  = Time.time;
                progress = www.progress;
            }

            if ((Time.time - timeout) > DownloadMgr.DownloadTimeOut)
            {
                AppDebug.LogError("下载失败 超时");
                if (onComplete != null)
                {
                    onComplete(false);
                }
                yield break;
            }

            yield return(null); //一定要等一帧
        }

        yield return(www);

        if (www != null && www.error == null)
        {
            using (FileStream fs = new FileStream(DownloadMgr.Instance.LocalFilePath + currDownloadData.FullName, FileMode.Create, FileAccess.ReadWrite))
            {
                fs.Write(www.bytes, 0, www.bytes.Length);
            }
        }

        //写入本地文件
        DownloadMgr.Instance.ModifyLocalData(currDownloadData);

        if (onComplete != null)
        {
            onComplete(true);
        }
    }
コード例 #6
0
 protected void LogError(object message)
 {
     AppDebug.LogError(message);
 }