Exemplo n.º 1
0
    /// <summary>
    /// 更新所有NPC阵容
    /// </summary>
    public void ChangeAllEnemyCards()
    {
        List <string>[] enemyHeroData = new List <string> [9];

        for (int i = 0; i < enemyHeroDatas.Count; i++)
        {
            enemyHeroData = enemyHeroDatas[i];

            for (int j = 0; j < 9; j++)
            {
                if (enemyHeroData[j] != null)
                {
                    sendData[j] = new List <string>();
                    //传递ID,品阶,战斗周目数
                    sendData[j].Add(enemyHeroData[j][0]);
                    sendData[j].Add(enemyHeroData[j][enemyHeroData[j].Count - 2]);
                    sendData[j].Add(enemyHeroData[j][enemyHeroData[j].Count - 1]);
                    //Debug.Log("heroid:" + sendData[j][0] + "   herograde:" + sendData[j][1]+"   fightNums:"+sendData[j][2]);
                    enemyHeroData[j].Clear();   //传递后清理
                }
                else
                {
                    sendData[j] = null;
                }
            }
            EmFightControll emFctll = new EmFightControll();
            //npc上阵武将数据更新
            enemyHeroDatas[i] = emFctll.SendHeroData(sendData, enemyUnits[i], FightCardSps[0].GetComponent <FightCardSP>().battles - 1);
            //清理临时传递的数据
            for (int n = 0; n < sendData.Length; n++)
            {
                if (sendData[n] != null)
                {
                    sendData[n].Clear();
                }
            }
            //清空当前NPC九宫格武将卡牌
            for (int m = 0; m < 9; m++)
            {
                if (JiuGongGes[i].GetChild(m).childCount > 0)
                {
                    Destroy(JiuGongGes[i].GetChild(m).GetChild(0).gameObject);
                }
            }
            //NPC新的武将卡牌上阵九宫格
            for (int m = 0; m < 9; m++)
            {
                if (enemyHeroDatas[i][m] != null)
                {
                    //实例化武将卡牌到备战位,并传递数据过去
                    GameObject newheroCard = Instantiate(hero_Card, JiuGongGes[i].GetChild(m));
                    newheroCard.transform.position = JiuGongGes[i].GetChild(m).position;
                    newheroCard.GetComponent <Image>().raycastTarget         = false;                                                           //关闭射线控制拖拽
                    newheroCard.GetComponent <HeroDataControll>().HeroData   = enemyHeroDatas[i][m];                                            //传递卡牌数据
                    newheroCard.GetComponent <HeroDataControll>().Grade_hero = int.Parse(enemyHeroDatas[i][m][enemyHeroDatas[i][m].Count - 2]); //传递阶值
                    //设置品阶颜色表现和属性
                    switch (int.Parse(enemyHeroDatas[i][m][enemyHeroDatas[i][m].Count - 2]))
                    {
                    case 1:
                        newheroCard.GetComponent <Image>().color = Color.white;
                        break;

                    case 2:
                        newheroCard.GetComponent <Image>().color = Color.blue;
                        break;

                    case 3:
                        newheroCard.transform.GetComponent <Image>().color = Color.red;
                        break;
                    }
                    //设置文字颜色,体现卡牌稀有度
                    switch (int.Parse(enemyHeroDatas[i][m][4]))
                    {
                    case 1:
                        newheroCard.transform.GetChild(0).GetComponent <Text>().color = new Color(49f / 255f, 193f / 255f, 82f / 255f, 1);    //绿色
                        break;

                    case 2:
                        newheroCard.transform.GetChild(0).GetComponent <Text>().color = new Color(48f / 255f, 127f / 255f, 192f / 255f, 1);    //蓝色
                        break;

                    case 3:
                        newheroCard.transform.GetChild(0).GetComponent <Text>().color = new Color(215f / 255f, 37f / 255f, 236f / 255f, 1);    //紫色
                        break;

                    case 4:
                        newheroCard.transform.GetChild(0).GetComponent <Text>().color = new Color(227f / 255f, 16f / 255f, 16f / 255f, 1);     //红色
                        break;
                    }
                    //显示英雄名等信息
                    newheroCard.transform.GetChild(0).GetComponent <Text>().text = enemyHeroDatas[i][m][0] + ":" + enemyHeroDatas[i][m][1];
                    newheroCard.transform.GetChild(1).GetComponent <Text>().text = enemyHeroDatas[i][m][6];
                    newheroCard.transform.GetChild(2).GetComponent <Text>().text = enemyHeroDatas[i][m][7];
                }
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 更新所有NPC阵容
    /// </summary>
    public void ChangeAllEnemyCards()
    {
        List <string>[] enemyHeroData = new List <string> [9];

        for (int i = 0; i < enemyHeroDatas.Count; i++)
        {
            enemyHeroData = enemyHeroDatas[i];

            for (int j = 0; j < 9; j++)
            {
                if (enemyHeroData[j] != null)
                {
                    sendData[j] = new List <string>();
                    //传递ID,品阶,战斗周目数
                    sendData[j].Add(enemyHeroData[j][0]);
                    sendData[j].Add(enemyHeroData[j][enemyHeroData[j].Count - 2]);
                    sendData[j].Add(enemyHeroData[j][enemyHeroData[j].Count - 1]);
                    enemyHeroData[j].Clear();   //传递后清理
                }
                else
                {
                    sendData[j] = null;
                }
            }
            EmFightControll emFctll = new EmFightControll();
            //npc上阵武将数据更新
            enemyHeroDatas[i] = emFctll.SendHeroData(sendData, npcUnits[i], FightCardSps[0].GetComponent <FightCardSP>().battles - 1, i);
            //清理临时传递的数据
            for (int n = 0; n < sendData.Length; n++)
            {
                if (sendData[n] != null)
                {
                    sendData[n].Clear();
                }
            }
            //清空当前NPC九宫格武将卡牌
            for (int m = 0; m < 9; m++)
            {
                if (JiuGongGes[i].GetChild(m).childCount > 0)
                {
                    Destroy(JiuGongGes[i].GetChild(m).GetChild(0).gameObject);
                }
            }
            //NPC新的武将卡牌上阵九宫格
            for (int m = 0; m < 9; m++)
            {
                if (enemyHeroDatas[i][m] != null)
                {
                    //实例化武将卡牌到备战位,并传递数据过去
                    GameObject newheroCard = Instantiate(hero_Card, JiuGongGes[i].GetChild(m));
                    newheroCard.transform.position = JiuGongGes[i].GetChild(m).position;
                    newheroCard.GetComponent <Image>().raycastTarget          = false;                                                           //关闭射线控制拖拽
                    newheroCard.GetComponent <HeroDataControll>().HeroData    = enemyHeroDatas[i][m];                                            //传递卡牌数据
                    newheroCard.GetComponent <HeroDataControll>().Grade_hero  = int.Parse(enemyHeroDatas[i][m][enemyHeroDatas[i][m].Count - 2]); //传递阶值
                    newheroCard.GetComponent <HeroDataControll>().HeroData[6] = (int.Parse(LoadJsonFile.RoleTableDatas[int.Parse(newheroCard.GetComponent <HeroDataControll>().HeroData[0]) - 1][6]) * Mathf.Pow(2, int.Parse(enemyHeroDatas[i][m][enemyHeroDatas[i][m].Count - 2]) - 1)).ToString();
                    newheroCard.GetComponent <HeroDataControll>().HeroData[8] = (int.Parse(LoadJsonFile.RoleTableDatas[int.Parse(newheroCard.GetComponent <HeroDataControll>().HeroData[0]) - 1][8]) * Mathf.Pow(2, int.Parse(enemyHeroDatas[i][m][enemyHeroDatas[i][m].Count - 2]) - 1)).ToString();

                    newheroCard.GetComponent <HeroDataControll>().BattleNums = int.Parse(enemyHeroDatas[i][m][enemyHeroDatas[i][m].Count - 1]);                          //传递战斗回合数
                    newheroCard.transform.GetComponent <Image>().sprite      = Resources.Load("Image/ArmsPicture/" + enemyHeroDatas[i][m][3], typeof(Sprite)) as Sprite; //设置敌方武将兵种背景图片
                    //设置品阶颜色表现和属性
                    newheroCard.transform.GetChild(4).GetChild(0).GetComponent <Text>().text = enemyHeroDatas[i][m][enemyHeroDatas[i][m].Count - 2];
                    //设置左上角兵种文字
                    newheroCard.transform.GetChild(5).GetChild(0).GetComponent <Text>().text = LoadJsonFile.SoldierTypeDates[int.Parse(enemyHeroDatas[i][m][3]) - 1][2];

                    //设置文字颜色,体现卡牌稀有度
                    switch (int.Parse(enemyHeroDatas[i][m][4]))
                    {
                    case 1:
                        //newheroCard.transform.GetChild(0).GetComponent<Text>().color = ColorData.green_Color;  //绿色
                        newheroCard.transform.GetChild(0).GetChild(0).GetComponent <Image>().color = ColorData.green_Color;     //绿色
                        break;

                    case 2:
                        //newheroCard.transform.GetChild(0).GetComponent<Text>().color = ColorData.blue_Color_hero; //蓝色
                        newheroCard.transform.GetChild(0).GetChild(0).GetComponent <Image>().color = ColorData.blue_Color_hero;    //蓝色
                        break;

                    case 3:
                        //newheroCard.transform.GetChild(0).GetComponent<Text>().color = ColorData.purple_Color; //紫色
                        newheroCard.transform.GetChild(0).GetChild(0).GetComponent <Image>().color = ColorData.purple_Color;    //紫色
                        break;

                    case 4:
                        //newheroCard.transform.GetChild(0).GetComponent<Text>().color = ColorData.red_Color_hero;  //红色
                        newheroCard.transform.GetChild(0).GetChild(0).GetComponent <Image>().color = ColorData.red_Color_hero;     //红色
                        break;
                    }
                    //显示英雄名等信息
                    newheroCard.transform.GetChild(0).GetComponent <Text>().text = enemyHeroDatas[i][m][1];
                    newheroCard.transform.GetChild(1).GetComponent <Text>().text = enemyHeroDatas[i][m][6];
                }
            }
        }
    }