public void SelectHeader(GameObject go)
    {
        long cardID = long.Parse(go.name);
        //更新PvP数据
        bool inTeam          = false;
        int  oldLeaderIndex  = -99;
        int  firstEmptyIndex = -99;

        for (int i = 0; i < Obj_MyselfPlayer.GetMe().PvPBattleArray.Length; i++)
        {
            //在阵型中把旧的队长删掉
            if (Obj_MyselfPlayer.GetMe().curPvPLearder > 0 && Obj_MyselfPlayer.GetMe().PvPBattleArray[i] == Obj_MyselfPlayer.GetMe().curPvPLearder)
            {
                oldLeaderIndex = i;
                Obj_MyselfPlayer.GetMe().PvPBattleArray[i] = -1;
            }
            if (Obj_MyselfPlayer.GetMe().PvPBattleArray[i] == cardID)
            {
                inTeam = true;
            }
            if (firstEmptyIndex == -99 && Obj_MyselfPlayer.GetMe().PvPBattleArray[i] == -1)
            {
                firstEmptyIndex = i;
            }
        }
        if (oldLeaderIndex == -99)         //无队长. 设置新队长为第一个空位
        {
            oldLeaderIndex = firstEmptyIndex;
        }
        foreach (UserCardItem item in Obj_MyselfPlayer.GetMe().cardBagList)
        {
            if (item.cardID == Obj_MyselfPlayer.GetMe().curPvPLearder)
            {
                item.qxzbFightIndex = -1;
            }
            if (item.cardID == cardID && inTeam)             //如果之前在阵容中不修改其所在位置
            {
                item.qxzbFightIndex = item.qxzbFightIndex % 100;
            }
            else if (item.cardID == cardID && !inTeam)
            {
                item.qxzbFightIndex = 0 + oldLeaderIndex + item.quality * 10;
                Obj_MyselfPlayer.GetMe().PvPBattleArray[oldLeaderIndex] = cardID;                 //之前不在阵容中,修改为之前的Leader的位置
            }
        }

        Obj_MyselfPlayer.GetMe().curPvPLearder = cardID;
        mainUILogic.OnPVPTeamWindow();
    }
Пример #2
0
 public void OnChooseCard()
 {
     if (mainUILogic == null)
     {
         mainUILogic = GameObject.Find("MainUILogic").GetComponent <MainUILogic>();
     }
     mainUILogic.OnPVPTeamWindow();
 }