//Получаем урон public async Task GetDamage(Person hero, Magic magic = null) { var chanel = KingdomRun.client.GetChannel(room) as IMessageChannel; if (heroes.TryAdd(hero.name, hero)) { heroes.Add(hero.name, hero); } //Если это не магия if (magic == null) { Random rand = new Random(); float damag = rand.Next(hero.m_Attack - 10, hero.m_Attack + 10); damag = damage - (defence * 0.75f); hp = (int)(hp - damag); await Loging.Log(name + " получил " + hero.m_Attack + " урона. Осталось " + hp + " здоровья!", chanel); } else//если все таки магия { hp = (int)(hp - magic.value); await Loging.Log(name + " получил " + magic.value + " урона. Осталось " + hp + " здоровья!", chanel); await Loging.Log(name + " теперь " + magic.effect, chanel); } //Если враг побежден if (hp <= 0) { await Loging.Log(name + " побежден!", chanel); float splitExp = exp / heroes.Count; //распределяем опыт между игроками foreach (KeyValuePair <string, Person> p in heroes) { p.Value.fight = false; await p.Value.GetExp((int)splitExp); } await TravelService.CheckEnemys(); return; } }
public async Task SmashPly(string msg) { var chanel = KingdomRun.client.GetChannel(ulong.Parse(lastRoom)) as IMessageChannel; var mob = TravelService.enemys[way]; TravelService.lockWay[way] = false; mob.heroes.Remove(name); way = -1; ghost = true; fight = false; await chanel.SendMessageAsync(msg); await TravelService.CheckEnemys(); return; }
//получаем урон public async Task GetDamage(float damage) { var chanel = KingdomRun.client.GetChannel(ulong.Parse(lastRoom)) as IMessageChannel; Random rand = new Random(); damage = rand.Next((int)damage - 15, (int)damage + 15); damage = damage - (m_Defence * 0.85f); if (damage < 0) { damage = 1; } p_Hp = (int)(p_Hp - damage); //Если нет здоровья if (p_Hp < 0) { var mob = TravelService.enemys[way]; TravelService.lockWay[way] = false; mob.heroes.Remove(name); way = -1; ghost = true; fight = false; await Loging.Log("Ты проиграл битву и теперь ты дух. Тебе доступен только потусторонний мир!", chanel); await TravelService.CheckEnemys(); return; } await Loging.Log(name + " получил " + damage + " урона. Осталось " + p_Hp + " здоровья !", chanel); }