private void CreateAutoActions() { Dictionary <int, int> .Enumerator enumerator = battle.autoAction.GetEnumerator(); while (enumerator.MoveNext()) { int pos = enumerator.Current.Key; int targetPos = enumerator.Current.Value; if (pos != targetPos) { GameObject go; if (BattlePublicTools.GetDistance(battle.mapData.mapWidth, pos, targetPos) == 1) { if (battle.GetPosIsMine(pos) == battle.GetPosIsMine(targetPos)) { go = CreateArrow(pos, targetPos, new Color(0, 1, 0, 0.5f), 0); } else { go = CreateArrow(pos, targetPos, new Color(1, 0, 0, 0.5f), 0); } } else { go = CreateShootArrow(pos, targetPos, new Color(1, 1, 0, 0.5f)); } autoActionArrowList.Add(go); } } }
private static void TriggerAura(Battle _battle, Hero _hero, IAuraSDS _auraSDS, SuperEvent e, ref float _value) { Hero targetHero = e.datas[0] as Hero; if (targetHero == _hero) { return; } List <int> pos = BattlePublicTools.GetNeighbourPos(_battle.mapData.neighbourPosMap, _hero.pos); if (pos.Contains(targetHero.pos)) { _value = _value * _auraSDS.GetAuraDatas()[0]; } }
public void MapUnitEnter(MapUnit _unit) { if (downPos != -1) { if (mapData.dic.ContainsKey(_unit.index)) { if (BattlePublicTools.GetDistance(mapData.mapWidth, downPos, _unit.index) == 1) { if (showMyTarget) { mapData.moveMap[downPos] = new KeyValuePair <int, int>(_unit.index, mapData.moveMap[downPos].Value); } else { mapData.moveMap[downPos] = new KeyValuePair <int, int>(mapData.moveMap[downPos].Key, _unit.index); } ShowArrow(downPos, _unit.index); } } } }
private void DoAttackOnTurn(List <Hero> _heros, BinaryWriter _mBw, BinaryWriter _oBw) { int allDamage = 0; List <Hero> heroList = new List <Hero>(); List <List <Hero> > heroTargetList = new List <List <Hero> >(); List <int> heroDamageList = new List <int>(); Dictionary <int, int> doRushDic = new Dictionary <int, int>(); Dictionary <int, Dictionary <int, int> > doDamageDic = new Dictionary <int, Dictionary <int, int> >(); List <Hero> dieHeroList = null; for (int i = 0; i < _heros.Count; i++) { Hero hero = _heros[i]; if (hero.sds.GetHeroTypeSDS().GetCanAttack() && hero.sds.GetDamage() > 0) { List <Hero> targetHeroList = BattlePublicTools.GetAttackTargetHeroList(mapData.neighbourPosMap, heroMapDic, hero); if (targetHeroList.Count > 0) { heroList.Add(hero); heroTargetList.Add(targetHeroList); heroDamageList.Add(hero.sds.GetDamage()); Dictionary <int, int> tmpDamageDic = new Dictionary <int, int>(); doDamageDic.Add(hero.pos, tmpDamageDic); allDamage += hero.sds.GetDamage(); if (targetHeroList.Count == 1) { Hero targetHero = targetHeroList[0]; if (targetHero.nowPower > 0) { doRushDic.Add(hero.pos, targetHero.pos); targetHero.nowPower--; } } } } } while (allDamage > 0) { int tmp = (int)(random.NextDouble() * allDamage); int add = 0; for (int i = 0; i < heroList.Count; i++) { int damage = heroDamageList[i]; if (damage + add > tmp) { Hero hero = heroList[i]; List <Hero> targetHeroList = heroTargetList[i]; allDamage--; heroDamageList[i]--; Hero beDamageHero = GetBeDamageHero(targetHeroList); Dictionary <int, int> tmpDic = doDamageDic[hero.pos]; if (tmpDic.ContainsKey(beDamageHero.pos)) { tmpDic[beDamageHero.pos]++; } else { tmpDic.Add(beDamageHero.pos, 1); } beDamageHero.nowHp--; if (beDamageHero.nowHp == 0) { for (int m = heroList.Count - 1; m > -1; m--) { targetHeroList = heroTargetList[m]; int index = targetHeroList.IndexOf(beDamageHero); if (index != -1) { targetHeroList.RemoveAt(index); if (targetHeroList.Count == 0) { allDamage -= heroDamageList[m]; heroList.RemoveAt(m); heroTargetList.RemoveAt(m); heroDamageList.RemoveAt(m); } } } if (dieHeroList == null) { dieHeroList = new List <Hero>(); } dieHeroList.Add(beDamageHero); } break; } else { add += damage; } } } if (dieHeroList != null) { for (int i = 0; i < dieHeroList.Count; i++) { Hero dieHero = dieHeroList[i]; heroMapDic.Remove(dieHero.pos); } } _mBw.Write(doRushDic.Count); _oBw.Write(doRushDic.Count); Dictionary <int, int> .Enumerator enumerator3 = doRushDic.GetEnumerator(); while (enumerator3.MoveNext()) { _mBw.Write(enumerator3.Current.Key); _oBw.Write(enumerator3.Current.Key); _mBw.Write(enumerator3.Current.Value); _oBw.Write(enumerator3.Current.Value); } _mBw.Write(doDamageDic.Count); _oBw.Write(doDamageDic.Count); Dictionary <int, Dictionary <int, int> > .Enumerator enumerator = doDamageDic.GetEnumerator(); while (enumerator.MoveNext()) { _mBw.Write(enumerator.Current.Key); _oBw.Write(enumerator.Current.Key); Dictionary <int, int> tmpDic = enumerator.Current.Value; _mBw.Write(tmpDic.Count); _oBw.Write(tmpDic.Count); Dictionary <int, int> .Enumerator enumerator2 = tmpDic.GetEnumerator(); while (enumerator2.MoveNext()) { _mBw.Write(enumerator2.Current.Key); _oBw.Write(enumerator2.Current.Key); _mBw.Write(enumerator2.Current.Value); _oBw.Write(enumerator2.Current.Value); } } }
private static void RoundStartSummonRecoverDie(Battle _battle, Hero _hero, ISkillSDS _skillSDS, Dictionary <Hero, int> _hpChangeDic, Dictionary <Hero, int> _powerChangeDic) { switch (_skillSDS.GetSkillTarget()) { case SkillTarget.SELF: SkillTakeEffect(_skillSDS, new List <Hero>() { _hero }, _hpChangeDic, _powerChangeDic); break; case SkillTarget.ALLY: List <Hero> heros = null; List <int> posList = BattlePublicTools.GetNeighbourPos(_battle.mapData.neighbourPosMap, _hero.pos); for (int i = 0; i < posList.Count; i++) { int pos = posList[i]; if (_battle.heroMapDic.ContainsKey(pos)) { Hero tmpHero = _battle.heroMapDic[pos]; if (tmpHero.isMine == _hero.isMine) { if (heros == null) { heros = new List <Hero>(); } heros.Add(tmpHero); } } } if (heros != null) { while (heros.Count > _skillSDS.GetTargetNum()) { int index = (int)(Battle.random.NextDouble() * heros.Count); heros.RemoveAt(index); } SkillTakeEffect(_skillSDS, heros, _hpChangeDic, _powerChangeDic); } break; case SkillTarget.ENEMY: heros = null; posList = BattlePublicTools.GetNeighbourPos(_battle.mapData.neighbourPosMap, _hero.pos); for (int i = 0; i < posList.Count; i++) { int pos = posList[i]; if (_battle.heroMapDic.ContainsKey(pos)) { Hero tmpHero = _battle.heroMapDic[pos]; if (tmpHero.isMine != _hero.isMine) { if (heros == null) { heros = new List <Hero>(); } heros.Add(tmpHero); } } } if (heros != null) { while (heros.Count > _skillSDS.GetTargetNum()) { int index = (int)(Battle.random.NextDouble() * heros.Count); heros.RemoveAt(index); } SkillTakeEffect(_skillSDS, heros, _hpChangeDic, _powerChangeDic); } break; } }
private static void SkillTakeEffect(ISkillSDS _skillSDS, List <Hero> _heros, Dictionary <Hero, int> _hpChangeDic, Dictionary <Hero, int> _powerChangeDic) { switch (_skillSDS.GetSkillEffect()) { case SkillEffect.DAMAGE: case SkillEffect.DAMAGE_WITH_LEADER: case SkillEffect.RECOVER: for (int i = 0; i < _heros.Count; i++) { BattlePublicTools.AccumulateDicData(_hpChangeDic, _heros[i], (int)_skillSDS.GetSkillDatas()[0]); } break; case SkillEffect.FIX_ATTACK: for (int i = 0; i < _heros.Count; i++) { _heros[i].SetAttackFix(_skillSDS.GetSkillDatas()[0]); } break; case SkillEffect.FIX_SHOOT: for (int i = 0; i < _heros.Count; i++) { _heros[i].SetShootFix(_skillSDS.GetSkillDatas()[0]); } break; case SkillEffect.FIX_COUNTER: for (int i = 0; i < _heros.Count; i++) { _heros[i].SetCounterFix(_skillSDS.GetSkillDatas()[0]); } break; case SkillEffect.FIX_DEFENSE: for (int i = 0; i < _heros.Count; i++) { _heros[i].SetDfenseFix(_skillSDS.GetSkillDatas()[0]); } break; case SkillEffect.POWERCHANGE: for (int i = 0; i < _heros.Count; i++) { BattlePublicTools.AccumulateDicData(_powerChangeDic, _heros[i], (int)_skillSDS.GetSkillDatas()[0]); } break; } }
private static void DoSummon(Battle _battle, bool _isMine, double _wrongValue) { //---summon int money; Dictionary <int, int> handCards; int oppBasePos; if (_isMine) { oppBasePos = _battle.mapData.oBase; money = _battle.mMoney; handCards = _battle.mHandCards; } else { oppBasePos = _battle.mapData.mBase; money = _battle.oMoney; handCards = _battle.oHandCards; } List <int> cards = new List <int>(); List <double> randomList2 = new List <double>(); Dictionary <int, int> .Enumerator enumerator4 = handCards.GetEnumerator(); while (enumerator4.MoveNext()) { KeyValuePair <int, int> pair = enumerator4.Current; int cardID = pair.Value; IHeroSDS heroSDS = Battle.GetHeroData(cardID); if (heroSDS.GetCost() <= money) { cards.Add(pair.Key); randomList2.Add(1); } } if (cards.Count > 0) { List <int> resultList = new List <int>(); List <int> resultList2 = new List <int>(); List <int> nowCheckPos = new List <int>() { oppBasePos }; Dictionary <int, bool> checkedPos = new Dictionary <int, bool>(); checkedPos.Add(oppBasePos, false); while (nowCheckPos.Count > 0) { int nowPos = nowCheckPos[0]; nowCheckPos.RemoveAt(0); List <int> posList = BattlePublicTools.GetNeighbourPos(_battle.mapData.neighbourPosMap, nowPos); for (int i = 0; i < posList.Count; i++) { int pos = posList[i]; if (!checkedPos.ContainsKey(pos)) { checkedPos.Add(pos, false); bool b = _battle.GetPosIsMine(pos); if (b == _isMine) { if (!_battle.heroMapDic.ContainsKey(pos)) { resultList.Add(pos); } } else { nowCheckPos.Add(pos); } } } } for (int i = 0; i < resultList.Count; i++) { int nowPos = resultList[i]; List <int> posList = BattlePublicTools.GetNeighbourPos(_battle.mapData.neighbourPosMap, nowPos); for (int m = 0; m < posList.Count; m++) { int pos = posList[m]; if (!_battle.heroMapDic.ContainsKey(pos) && !resultList.Contains(pos) && !resultList2.Contains(pos)) { bool b = _battle.GetPosIsMine(pos); if (b == _isMine) { resultList2.Add(pos); } } } } PublicTools.ShuffleList(cards, Battle.random); while (Battle.random.NextDouble() < 0.8 && cards.Count > 0 && (resultList.Count > 0 || resultList2.Count > 0)) { int cardUid = cards[0]; cards.RemoveAt(0); randomList2.RemoveAt(0); int cardID = handCards[cardUid]; IHeroSDS heroSDS = Battle.GetHeroData(cardID); if (heroSDS.GetCost() <= money) { List <int> summonPosList; if (resultList.Count > 0 && resultList2.Count > 0) { if (Battle.random.NextDouble() < 0.6) { summonPosList = resultList; } else { summonPosList = resultList2; } } else if (resultList.Count > 0) { summonPosList = resultList; } else { summonPosList = resultList2; } int index = (int)(Battle.random.NextDouble() * summonPosList.Count); int summonPos = summonPosList[index]; summonPosList.RemoveAt(index); _battle.summon.Add(cardUid, summonPos); money -= heroSDS.GetCost(); } else { break; } } } }