/// <summary> /// 执行攻击 /// </summary> /// <returns></returns> override public IEnumerator DoAtk() { //foreach (KeyValuePair<int, GameObject> item in dicCardObj) //{ // FightCard vFightCard = item.Value.GetComponent<FightCard>(); // if (vFightCard.postionState == FightCard.PostionState.choice) // { // } //} List <int> canAtkCardList = new List <int>(); List <FightCard> list = new List <FightCard>(); int numberSum = 0; foreach (KeyValuePair <int, GameObject> item in dicCardObj) { FightCard vFightCard = item.Value.GetComponent <FightCard>(); if (vFightCard.postionState == FightCard.PostionState.choice) { list.Add(vFightCard); FightAtkAnim atkAnim = item.Value.GetComponent <FightAtkAnim>(); atkAnim.PlayAtk(canAtkCardList.Count * atkSpaceTime); canAtkCardList.Add(vFightCard.GetCardDetail().id); if (!listSpcaePos.ContainsKey(vFightCard.pos)) { listSpcaePos.Add(vFightCard.pos, vFightCard.pos); this.listFightCard.Remove(vFightCard); numberSum = numberSum + vFightCard.GetCardDetail().number; } } } lastFightData.CalculationType(list, numberSum); if (canAtkCardList.Count == 0) { MsgPrompts.create("未选择一张卡片"); } else { for (int i = 0; i < canAtkCardList.Count; ++i) { this.dicCardObj.Remove(canAtkCardList[i]); } yield return(new WaitForSeconds(canAtkCardList.Count * atkSpaceTime + 1)); this.Licensing(); yield return(new WaitForSeconds(canAtkCardList.Count * atkSpaceTime + 1)); this.fightState.Waiver(); } }
//数字从小到大排序 int sortNumber(FightCard a, FightCard b) { if (a.GetCardDetail().number < b.GetCardDetail().number) { return(-1); } else { return(0); } }
/// <summary> /// 表现的卡牌位置排序 /// </summary> public void sortCardGameObject() { this.listFightCard.Sort(sortNumber); for (int i = 0; i < this.listFightCard.Count; ++i) { listFightCard[i].pos = i; FightCard fightCard = this.listFightCard[i]; int cardId = fightCard.GetCardDetail().id; GameObject obj = this.dicCardObj[cardId]; FightCard vFightCard = obj.GetComponent <FightCard>(); vFightCard.pos = i; //卡牌动画 FightCardAnim cardAnim = obj.GetComponent <FightCardAnim>(); cardAnim.PlayTo(this.fightCardTransfrom.GetPos(i)); } }
//数字从小到大排序 int sortNumber(FightCard a, FightCard b) { if( a.GetCardDetail().number < b.GetCardDetail().number) { return -1; } else { return 0; } }