public void showTalkTips(int stageId, int monsterId, heroTalkType type, Transform headTransform) { Debug.LogFormat("=======stageId:{0} {1} {2}", stageId, monsterId, (int)type); PlotWarHeroConf plotWarHeroConf = GetPlotWarHeroConf(stageId, monsterId, type); if (plotWarHeroConf == null) { //Debug.LogFormat("cant find plotWarHeroConf"); return; } int randIdx = Random.Range(1, 100); if (randIdx > plotWarHeroConf.triggerRate) { //Debug.LogFormat("rate: {0} {1}", randIdx, plotWarHeroConf.triggerRate); return; } string curHeroTalkKey = string.Format("{0}_{1}_{2}", stageId, monsterId, (int)type); heroTalkInfo talkInfo; if (heroTalkInfoDic.TryGetValue(curHeroTalkKey, out talkInfo)) { talkInfo.count++; } else { talkInfo = new heroTalkInfo(); talkInfo.id = curHeroTalkKey; talkInfo.count = 0; heroTalkInfoDic.Add(curHeroTalkKey, talkInfo); } GameObject heroTalkItem = headTransform.FindChild("Content/heroTalkItem").gameObject; heroTalkItem.SetActive(true); Image imgBg = headTransform.FindChild("Content/heroTalkItem/imgBg").GetComponent <Image>(); if (headTransform.localPosition.x > 1000) { RectTransform rectTransform = (RectTransform)heroTalkItem.transform; imgBg.rectTransform.localRotation = Quaternion.Euler(0f, 180f, 0f); rectTransform.anchoredPosition = new Vector3(-90, 70, 0); } Debug.LogFormat("====count: {0}", talkInfo.count); if (talkInfo.count > plotWarHeroConf.count && plotWarHeroConf.count != 0) { return; } if (plotWarHeroConf.contentArray.Length <= 0) { return; } int idxContent = talkInfo.count % plotWarHeroConf.contentArray.Length; Text textContent = headTransform.FindChild("Content/heroTalkItem/textTalk").GetComponent <Text>(); textContent.text = plotWarHeroConf.contentArray[idxContent]; StartCoroutine(TipsDone(heroTalkItem)); }
public PlotWarHeroConf GetPlotWarHeroConf(int stageId, int monsterId, heroTalkType triggerType) { string id = string.Format("{0}_{1}_{2}", stageId, monsterId, (int)triggerType); PlotWarHeroConf plotWarHeroConf; if (plotWarHeroConfDic.TryGetValue(id, out plotWarHeroConf)) { return(plotWarHeroConf); } return(null); }