Exemple #1
0
    public void RunTask(AutoGuideCfgs agc)
    {
        if (agc != null)
        {
            curtTaskData = agc;
        }
        //导航系统开启
        nav.enabled = true;
        //解析任务数据
        if (curtTaskData.npcID != -1)
        {
            float dis = Vector3.Distance(playeController.transform.position, npcPosTrans[agc.npcID].position);
            if (dis < 0.5f)
            {
                isNavGuide    = false;
                nav.isStopped = true;
                playeController.SetBlend(Constants.BlendIdel);
                nav.enabled = false;

                OpenGuideWnd();
            }
            else
            {
                isNavGuide  = true;
                nav.enabled = true;
                nav.speed   = Constants.PlayerMoveSpeed;
                nav.SetDestination(npcPosTrans[agc.npcID].position);
                playeController.SetBlend(Constants.BlendMove);
            }
        }
        else
        {
            OpenGuideWnd();
        }
    }
Exemple #2
0
    protected override void InitWnd()
    {
        base.InitWnd();
        curtTaskData = MainCitySys.Instance.GetCurtTaskData();
        //使用分割符号切对话
        dialogArr = curtTaskData.dilogArr.Split('#');
        index     = 1;

        SetTalk();
    }
Exemple #3
0
    public void RefreshUI()
    {
        #region UI
        SetText(txtFight, Common.Tools.GetFightByProps(PlayerData.Level, PlayerData.AD, PlayerData.AP, PlayerData.Addef, PlayerData.Apdef));
        SetText(txtPower, "体力" + PlayerData.Power + "/" + Common.Tools.GetPowerLimit(PlayerData.Level));
        imgPowerPrg.fillAmount = PlayerData.Power * 1.0f / Common.Tools.GetPowerLimit(PlayerData.Level);
        SetText(txtLevel, PlayerData.Level);
        SetText(txtName, PlayerData.playerName);

        //expprg 进度条自适应
        //获取当前经验值是升级所需经验值的百分比
        int expPrgVal = (int)(PlayerData.Exp * 1.0f / Common.Tools.GetExpUpValByLv(PlayerData.Level) * 100);
        //改变组件的值
        SetText(txtExpPrg, expPrgVal + "%");
        //把经验值百分比分成10份
        int index = expPrgVal / 10;

        GridLayoutGroup grid = expPrgTrans.GetComponent <GridLayoutGroup>();
        //计算实际场景高度是当前分辨率的多少占比
        float globalRate = 1.0f * Constants.ScreenStandardHeight / Screen.height;
        //计算出来当前的场景宽度应该是多少
        float screenWidth = Screen.width * globalRate;
        //计算经验条应该是多长(实际场景宽度减去边边角角)
        float width = (screenWidth - 106) / 10;
        //然后调整经验条的位置
        grid.cellSize = new Vector2(width, 5);

        for (int i = 0; i < expPrgTrans.childCount; i++)
        {
            Image img = expPrgTrans.GetChild(i).GetComponent <Image>();
            //前面几份肯定是满的
            if (i < index)
            {
                img.fillAmount = 1;
            }
            //到了半满那份就要调整宽度
            else if (i == index)
            {
                img.fillAmount = expPrgVal % 10 * 1.0f / 10;
            }
            //最后几份肯定是空的
            else
            {
                img.fillAmount = 0;
            }
        }
        #endregion

        //设置自动任务图标
        if (resSvc != null)
        {
            curtTaskData = resSvc.GetAutoGuideCfgData(PlayerData.GuideID);
        }

        if (curtTaskData != null)
        {
            SetGuideBtnIcon(curtTaskData.npcID);
        }
        else
        {
            SetGuideBtnIcon(-1);
        }
    }
Exemple #4
0
    private void InitGuideCfgs(string path)
    {
        TextAsset xml = Resources.Load <TextAsset>(path);

        if (!xml)
        {
            Debug.LogError("Xml file:" + path + "加载失败,请检查文件是否正确");
        }
        else
        {
            //建立一个XML
            XmlDocument doc = new XmlDocument();
            //读取XML内容
            doc.LoadXml(xml.text);
            //读取root下的子节点 成为一个队列
            XmlNodeList nodLst = doc.SelectSingleNode("root").ChildNodes;
            //读取节点数据
            for (int i = 0; i < nodLst.Count; i++)
            {
                XmlElement ele = nodLst[i] as XmlElement;
                if (ele.GetAttributeNode("ID") == null)
                {
                    continue;
                }
                int           ID = Convert.ToInt32(ele.GetAttributeNode("ID").InnerText);
                AutoGuideCfgs mc = new AutoGuideCfgs
                {
                    ID = ID
                };

                foreach (XmlElement e in nodLst[i].ChildNodes)
                {
                    switch (e.Name)
                    {
                    case "npcID":
                        mc.npcID = int.Parse(e.InnerText);
                        break;

                    case "dilogArr":
                        mc.dilogArr = e.InnerText;
                        break;

                    case "actID":
                        mc.actID = int.Parse(e.InnerText);
                        break;

                    case "coin":
                        mc.coin = int.Parse(e.InnerText);
                        break;

                    case "exp":
                        mc.exp = int.Parse(e.InnerText);
                        break;

                    default:
                        break;
                    }
                }

                guideDict.Add(ID, mc);
            }
        }
    }