/* * @brief 创建单行泡泡 * @parma rowInfo 单行泡泡信息 * @desc 移动的时候考虑下移的多少 */ void CreateOneRowPubble(PubbleRowInfo rowInfo) { //单行9个泡泡 for (int i = 0; i < rowPubbleNum; i++) { markTopRowPubble[i] = null; //获取当前泡泡的信息 PubbleInfo pubbleInfo = rowInfo.PubbleRowDic[i]; //如果不是空泡泡类型 if (pubbleInfo.ColorType != PubbleColorType.PUBBLE_EMPTY_TYPE) { //创建当前泡泡的坐标 Vector3 pubblePosition = new Vector3(markCurrentPointX, markCurrentPointY, 0); Vector3 pubbleScale = new Vector3(1, 1, 1); //创建泡泡 GameObject pubbleObject = (GameObject)Instantiate(pubbleKindPrefabs[(int)pubbleInfo.ColorType - 1]); pubbleObject.transform.parent = transform; pubbleObject.transform.localPosition = pubblePosition; pubbleObject.transform.localScale = pubbleScale; //计算该泡泡的周边泡泡 pubbleObject.GetComponent<PubbleObject>().CalculateAdjacentObjects(); //如果是到了创建最后一行泡泡,则开始保存这一行泡泡,作为顶部泡泡 if (countPubbleRowsInPanel == markCreateRowIndex + 1) { //记录顶行泡泡的脚本 markTopRowPubble[i] = pubbleObject.GetComponent<PubbleObject>(); } //创建的第一个泡泡,将会是最底下的,记录一下,便于后面判断 SlidePlayPanel.Instance.AssignBottomPubble(pubbleObject); //记录当前有效的预备泡泡类型 CalculatePrefabPubbleType(pubbleInfo.ColorType); } //如果是到了创建最后一行泡泡,则开始记录该行9个泡泡位置 if (countPubbleRowsInPanel == markCreateRowIndex + 1) { markTopPubblePostion[i] = new Vector3(markCurrentPointX, markCurrentPointY, 0); } //计算X坐标:不断往右平移一个单位坐标,跟一个间隔 markCurrentPointX += pubbleWidth; markCurrentPointX += marginEachPubble; } //计算Y坐标:不断上移 markCurrentPointY += markMoveUnit; //记录当前创建了多少行泡泡 markCreateRowIndex++; }
/* * @brief 极限模式的时候创建单行泡泡 * @desc 此时位置 要以 当前界面上的泡泡位置去算,不能保证顶行是九个位置 */ public void CreatePubbleOneRowLimitStyle(PubbleRowInfo rowInfo) { //记录极限的行数 countLimitCreateNum++; //记录总的行数 countPubbleRowsInPanel++; if (1 == countLimitCreateNum % 2) { //表示在顶行泡泡之上的奇数 ,此时一行总共是8个泡泡,缩进一个泡泡位置 markCurrentPointX = startPointX + pubbleWidth; } else { //表示双行:缩进半个width markCurrentPointX = startPointX + pubbleWidth/2; } CreateOneRowPubble(rowInfo); }
/* * @brief 游戏开始创建全部的泡泡 * @desc 此时泡泡位置遵循最顶部 九个位置 */ void CreatePubbleOneRowStartGame(PubbleRowInfo rowInfo) { //获取当前行起始的X 坐标:因为分单行双行(各自起始点不一样) if (1 == (countPubbleRowsInPanel - markCreateRowIndex) % 2) { //表示单行:缩进半个width markCurrentPointX = startPointX + pubbleWidth / 2; } else { //表示双行:缩进一个width markCurrentPointX = startPointX + pubbleWidth; } CreateOneRowPubble(rowInfo); }
/* * @brief 随机生成两行泡泡 */ static public Dictionary<int, PubbleRowInfo> GetRandomInfo() { Dictionary<int, PubbleRowInfo> m_PubbleAllRowInfo = new Dictionary<int, PubbleRowInfo>(); string[] barrInfo = ResourceManager.LoadTxtFile("document/barr901"); int rowCount = barrInfo.Length; int random = Random.Range(0, rowCount - 1); Debug.Log("读取随机文件-----文件也从下往上 ~~~~~" + barrInfo[random]); string[] itemRowList = barrInfo[random].Split(';'); PubbleRowInfo data = new PubbleRowInfo(itemRowList); m_PubbleAllRowInfo.Add(0, data); return m_PubbleAllRowInfo; }
/* * @brief 从配置文件中读取关卡信息 * @prama isLight 是否有闪电技能泡泡 * @prama isColor 是否有颜色技能泡泡 */ public void ReadBarrInfo(bool isColor, bool isLight ) { m_PubbleAllRowInfo.Clear(); Debug.Log("选中的关卡: ------- " + chooseLevel_id + "从配置文件中读取关卡信息"); string[] barrInfo = ResourceManager.LoadTxtFile("document/barr" + chooseLevel_id); rowCount = barrInfo.Length; //配置文件中从下往上显示,因此读取文件也从下往上 for (int i = barrInfo.Length - 1; i >= 0; i--) { //Debug.Log("读取文件也从下往上 ~~~~~" + barrInfo[i]); string[] itemRowList = barrInfo[i].Split(';'); PubbleRowInfo data = new PubbleRowInfo(itemRowList); m_PubbleAllRowInfo.Add(barrInfo.Length - i - 1, data); } //记录下当前的总页码数 pageCount = m_BarrData.Count; // Debug.Log("闪电球的行数位置-----" + isLight + isColor); /* for (int i = 0; i < m_PubbleAllRowInfo.Count; i++) { Debug.Log("所在行的行数:" + i + " 所在行的泡泡的数量" + m_PubbleAllRowInfo[i].PubbleRowDic[8].ActionType); }*/ // 如果包含闪电球 则设置配置文件中读取的数据 if (isLight) { int[] randNum = ResourceManager.GetNoRepeatRandNumber(barrInfo.Length); foreach (int a in randNum) { Debug.Log("闪电球的行数位置-----" + a); } foreach (int cur in randNum) { //获取随机生成的第n行的泡泡数据 Dictionary<int, PubbleInfo> dict = m_PubbleAllRowInfo[cur].PubbleRowDic; int random = Random.Range(0, dict[8].ActionType-1); Debug.Log("闪电球的位置-----行:" + cur + "random:" + random); int coutTag = 0; for (int i = 0; i < dict.Count; i++) { //Debug.Log("pubble的位置"+ i+ "----pubble的 actiontype值是:----" + dict[i].ActionType); //第0个位置有泡泡 并且该位置被随机成闪电泡泡 if (i == 0) { if (random == 0 && dict[0].ActionType == 1) { PubbleInfo pubble = dict[0]; pubble.ColorType = PubbleColorType.PUBBLE_THUNDER_TYPE; } if (dict[0].ActionType == 1) { coutTag++; } } else { //Debug.Log("pubble的位置 else --------" + i + "----pubble的 actiontype值是:----" + dict[i].ActionType); if ((dict[i].ActionType - dict[i - 1].ActionType) == 1) { if (coutTag == random) { PubbleInfo pubble = dict[i]; pubble.ColorType = PubbleColorType.PUBBLE_THUNDER_TYPE; } coutTag++; } } } } } // 如果包含颜色球 则设置配置文件中读取的数据 if (isColor) { int[] randNum = ResourceManager.GetNoRepeatRandNumber(barrInfo.Length-2); foreach (int a in randNum) { Debug.Log("颜色球的行数位置-----" + a); } foreach (int cur in randNum) { //获取随机生成的第n行的泡泡数据 Dictionary<int, PubbleInfo> dict = m_PubbleAllRowInfo[cur].PubbleRowDic; int random = Random.Range(0, dict[8].ActionType - 1); Debug.Log("颜色球的位置-----行:" + cur + "random:" + random); int coutTag = 0; for (int i = 0; i < dict.Count; i++) { if (i == 0) { if (random == 0 && dict[0].ActionType == 1) { PubbleInfo pubble = dict[0]; pubble.ColorType = PubbleColorType.PUBBLE_RAINBOW_TYPE; } if (dict[0].ActionType == 1) { coutTag++; } } else { //Debug.Log("pubble的位置 else --------" + i + "----pubble的 actiontype值是:----" + dict[i].ActionType); if ((dict[i].ActionType - dict[i - 1].ActionType) == 1) { if (coutTag == random) { PubbleInfo pubble = dict[i]; pubble.ColorType = PubbleColorType.PUBBLE_RAINBOW_TYPE; } coutTag++; } } } } } }
public void PubblePageAddRowInfo(PubbleRowInfo rowInfo,int i) { m_PubblePageDic.Add(i,rowInfo); }