public void InitBatle(string Name, Chat ch, string donger) { Init(); if (p1.nll == true) { Donger tmp=dongers.Find(x => x.dongerName == donger); if (tmp==null) p1 = new Player(Name, dongers[SeijaHelper.RandomProvider.GetThreadRandom().Next(0, dongers.Count)].Clone(), GetKonfaName(ch.Name)); else p1 = new Player(Name, tmp.Clone(), GetKonfaName(ch.Name)); ch.SendMessage("Первый игрок - " + p1.name + " и его донгер: \n\r" + p1.donger.Info + "\n\rОжидание второго игрока"); ch1 = ch; restTimer = new System.Windows.Threading.DispatcherTimer(); restTimer.Interval = new TimeSpan(0, 0, 30); restTimer.Tick += RestTick; restTimer.Start(); } else { restTimer.Stop(); ch2 = ch; if (Name == p1.name) p2 = new Player("SeijaBot", Donger.seija.Clone(), GetKonfaName(ch.Name)); else { Donger tmp=dongers.Find(x => x.dongerName == donger); if (tmp == null) { Donger temp; do { temp = dongers[SeijaHelper.RandomProvider.GetThreadRandom().Next(0, dongers.Count)].Clone(); } while (temp.dongerName == p1.donger.dongerName); p2 = new Player(Name, temp.Clone(), GetKonfaName(ch.Name)); } else p2 = new Player(Name, tmp.Clone(), GetKonfaName(ch.Name)); } SendMessages("Второй игрок - " + p2.name + " и его донгер: \n\r" + p2.donger.Info); StartBattle(); } }
public void StartBattle() { SeijaHelper.isEn = false; Donger currentDonger; System.Threading.Thread.Sleep(1000); SendMessages("Да начнется битва между [" + p1.konfa + "] " + p1.name + " и [" + p2.konfa + "] " + p2.name + "!"); p1.donger.enemy = p2.donger; p1.donger.systemEnemy = p2.donger; p2.donger.enemy = p1.donger; p2.donger.systemEnemy = p1.donger; currentDonger = p1.donger; while (p1.donger.hp > 0 && p2.donger.hp > 0) { System.Threading.Thread.Sleep(1000); currentDonger.attack(currentDonger); //currentDonger.RollSkill(); currentDonger = currentDonger.systemEnemy; //SendMessages(p1.donger + " (" + p1.dongerhp + ") VS " + p2.donger + " (" + p2.dongerhp + ")"); //System.Threading.Thread.Sleep(1000); //p1.dongerhp = p1.dongerhp - (SeijaHelper.FixedRandom(1, 10)); //p2.dongerhp = p2.dongerhp - (new Random().Next(1, 10)); } SendMessages(p1.donger.dongerName + " (" + p1.donger.hp + ") VS " + p2.donger.dongerName + " (" + p2.donger.hp + ")"); System.Threading.Thread.Sleep(1000); if (p1.donger.hp <= 0 && p2.donger.hp <= 0) SendMessages("Ничья!"); else { Player winner = p1.donger.hp <= 0 ? p2 : p1; //Donger winner_dong = p1.donger.hp <= 0 ? p2.donger.Clone() : p1.donger.Clone(); SendMessages("В битве победил: " + winner.name + " и его донгер " + winner.donger.dongerName); } p1 = new Player(""); p2 = new Player(""); ch1 = null; ch2 = null; SeijaHelper.isEn = true; }
public DongerBattler() { p1 = new Player(""); p2 = new Player(""); }