public void Use(BaseFighter fighterOne, BaseFighter fighterTwo) { int hlth = (int)(fighterOne.Intellegence * 0.25); messager?.Invoke($"---> {fighterOne.Name} лечится на {hlth}! <---"); fighterOne.Health += hlth; }
protected override void _DoSkill(BaseFighter target) { int damage = Random.Range(min, max + 1); // 卡牌存在,攻击卡牌 target.OnSkillHurt(this, damage); }
//Used For HitBoxes public virtual void HitMade(Collision2D col) { //Reset the jump counter.. hit either floor or player jumps = 0; //Dont care if player is touching the floor if (col.gameObject.tag == "Floor") { //turn the f**k around return; } if (timer >= timeBetweenAttacks) { timer = 0f; //This is the default way of dealing damage to other player if (StateOfPlayer == PlayerState.Strong || StateOfPlayer == PlayerState.Weak || StateOfPlayer == PlayerState.Special) { BaseFighter otherPlayer = (BaseFighter)col.gameObject.GetComponent(typeof(BaseFighter)); if (StateOfPlayer == PlayerState.Weak) { otherPlayer.DealDamageToSelf(AttackPower[0]); } if (StateOfPlayer == PlayerState.Strong) { otherPlayer.DealDamageToSelf(AttackPower[1]); } if (StateOfPlayer == PlayerState.Special) { otherPlayer.DealDamageToSelf(AttackPower[1 + CurrentSpecialUsed]); } } } }
// 减少攻击力 protected override void _DoSkill(BaseFighter target) { if (target.CanDoSkill()) { target.DeductAttack(deAttack); } }
/// <summary> /// Начинает бой /// </summary> /// <param name="fighterOne">Атакующий</param> /// <param name="fighterTwo">Защищающийся</param> /// <returns>Возвращает значение TRUE - если бой закончился и FALSE - если бой продолжается</returns> public static bool Fight(BaseFighter fighterOne, BaseFighter fighterTwo, int chooseAttack) { int attack = 0; attack += fighterOne.Attack(fighterTwo); attack += fighterOne.Effects(fighterTwo); fighterOne.SuperAbility(fighterTwo); if (attack > 0) { fighterTwo.Health -= attack; } else { attack = 0; } FighterInfoHelper.fightersNormalInfo(fighterOne, fighterTwo); Console.ForegroundColor = fighterOne.Color; messager($"{fighterOne.Name} нанёс {attack} урона {fighterTwo.Name}"); messager($"Оставшееся здоровье противника: {fighterTwo.Health}"); Console.ForegroundColor = ConsoleColor.White; return(fighterTwo.IsDeath()); }
/// <summary> /// 横扫技能效果,中间卡牌收到的伤害作为旁边二张卡牌的攻击力 /// </summary> public override void DoSkill() { if (card == null || card.IsDead || card.Attack <= 0) { return; } List <BaseFighter> targetList = card.owner.GetTargetByType(this, TargetType); if (targetList.Count == 0) { return; } if (targetList.Count == 1 && targetList[0] is PlayerFighter) { SkillFactory.GetAttackSkill(card).DoSkill(); return; } List <int> cardIDs = GetTargetID(targetList); card.Actions.Add(SkillStartAction.GetAction(card.ID, skillID, cardIDs)); BaseFighter fighter = targetList[0]; int damage = fighter.OnAttackHurt(card, card.Attack); for (int i = 1; i < targetList.Count; i++) { fighter = targetList[i]; fighter.OnAttackHurt(card, damage); } // card.Actions.Add(SkillEndAction.GetAction(card.ID, skillID)); }
protected override void _DoSkill(BaseFighter target) { int hurt = target.OnSkillHurt(this, damage); // 给自己加血 card.AddHp(hurt); }
public void Use(BaseFighter fighter, BaseFighter enemy) { int dmg = enemy.Defence - (fighter.Strength / 2); enemy.Effects.Add(new Bleeding()); enemy.Health -= dmg; messager?.Invoke($"{fighter.Name} Использует BloodBLade и наносит: {dmg}"); }
protected List <int> GetTargetID(BaseFighter target) { List <int> result = new List <int>(); result.Add(target.ID); return(result); }
public static RDVFDataContext GetDataContext(bool reset = false) { if (RDVFDataContext != null && !reset) { return(RDVFDataContext); } var firstFighter = new BaseFighter() { Dexterity = 4, Resilience = 4, Name = "AFighterWithValidStats", Endurance = 8, Strength = 4, Special = 4 }; var secondighter = new BaseFighter() { Dexterity = 4, Resilience = 4, Name = "AnotherFighterWithValidStats", Endurance = 4, Strength = 8, Special = 4 }; var thirdFighter = new BaseFighter() { Dexterity = 4, Resilience = 4, Name = "AFighterWithInvalidStats", Endurance = 4, Strength = 4, Special = 4 }; // In-memory database only exists while the connection is open var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); var connectionOptions = new DbContextOptionsBuilder <RDVFDataContext>() .UseSqlite(connection) .Options; // Create the schema in the database var context = new RDVFDataContext(connectionOptions); context.Database.EnsureCreated(); context.Fighters.Add(firstFighter); context.Fighters.Add(secondighter); context.Fighters.Add(thirdFighter); context.SaveChanges(); RDVFDataContext = context; return(RDVFDataContext); }
// 回到牌堆 protected override void _DoSkill(BaseFighter target) { CardFighter tempCard = target as CardFighter; if (tempCard != null) { tempCard.DoBack(); } }
/// <summary> /// Raises a combat event for when an enemy is detected /// </summary> /// <param name="enemy">Enemy.</param> protected virtual void OnEnemyDetected(BaseFighter enemy) { CombatEventHandler hand = CombatEvent; if (hand != null) { hand(this, new CombatEventArgs(enemy)); } }
internal static void fighterFullInfo(this BaseFighter fighter) { Console.ForegroundColor = ConsoleColor.Yellow; messager?.Invoke($"Name:{fighter.Name}, Class:{fighter.Class}, Level:{fighter.Level}, Exp:{fighter.Exp}"); messager?.Invoke($"Health:{fighter.Health}, Mana:{fighter.Mana}"); messager?.Invoke($"Strength:{fighter.Strength}, Defence:{fighter.Defence}, Agility:{fighter.Agility}, Intellegence:{fighter.Intellegence}"); messager?.Invoke($"Abilitye:{fighter.Ability}, Info:{fighter.Ability.FullInfo}"); Console.ForegroundColor = ConsoleColor.White; }
// Methods public void Awake() { // Call BaseFighter's initializer Init(); // Flag to show that there isn't an active target target = null; attackTimer = -1.0f; }
protected override void _DoSkill(BaseFighter target) { if (card.Attack <= 0) { return; } // 卡牌存在,攻击卡牌 target.OnAttackHurt(card, card.Attack); }
/// <summary> /// Проверяет на смерть /// </summary> /// <param name="fighter">Боец</param> /// <returns>Возвращает TRUE - если мертв и FALSE - если жив</returns> public static bool IsDeath(this BaseFighter fighter) { if (fighter.Health <= 0) { return(true); } else { return(false); } }
/// <summary> /// 受到普通攻击 /// </summary> public virtual int OnAttackHurt(BaseFighter attacker, int damage) { if (IsDead) { return(0); } DeductHp(damage, true); return(damage); }
protected override void _DoSkill(BaseFighter target) { if (!target.CanDoSkill()) { return; } // 给自己加血 target.OnSkillHurt(this, damage); target.DeductAttack(damage); }
protected override void _DoSkill(BaseFighter target) { // 卡牌存在,攻击卡牌 target.OnSkillHurt(this, damage); // 判定成功增加Buff if (target.canDoSkill && BuffID > 0 && !target.IsDead && Random.Range(0, 100) < rate) { BaseBuff buff = BuffFactory.GetBuffByID(BuffID, skillLevel); (target as CardFighter).AddBuff(buff); } }
void Start() { // Set up an array so our script can more easily set up the hit boxes //colliders = new PolygonCollider2D[]{frame1, frame2, frame3}; rotat = new Quaternion(0, 180, 0, 0); // Create a polygon collider localCollider = gameObject.AddComponent <PolygonCollider2D>(); localCollider.pathCount = 0; // Clear auto-generated polygons // Base Fighter Stuff fighter = (BaseFighter)this.GetComponent(typeof(BaseFighter)); }
/// <summary> /// Подсчет атаки или защиты Положительных и Отриацательных эффектов. /// </summary> /// <param name="fighterOne">Атакующий</param> /// <param name="FighterTwo">Защищающийся</param> /// <returns>Возвращается разница между уроном эффектов</returns> public static int Effects(this BaseFighter fighterOne, BaseFighter FighterTwo) { int dmg = 0; var posEffects = FighterTwo.Effects.FindAll(x => x.IsPositive == true); dmg += RunEffects(posEffects, FighterTwo); var negEffects = FighterTwo.Effects.FindAll(x => x.IsPositive == false); dmg += RunEffects(negEffects, FighterTwo); return(dmg); }
// Unity Methods // Use this for initialization void Start() { // Call BaseFighter's initializer Init(); // A size of 10 should be a good place to start for our lists targets = new List <BaseFighter>(10); // Flag the timer to show that we haven't found a unit yet. attackTimer = -1.0f; // Flag curTarget to null curTarget = null; }
/// <summary> /// Выполняет эффекты и удаляет уже завершившиеся /// </summary> /// <param name="effects">Лист эффектов для выполнения, Негативные или Положительные</param> /// <param name="fighter">Боей, чьи эффекты будут запускаться</param> /// <returns>Возвращает урон от эффектов в int</returns> public static int RunEffects(List <IEffect> effects, BaseFighter fighter) { int dmg = 0; foreach (var effect in effects) { dmg += effect.Run(fighter); if (effect.Ticks <= 0) { fighter.Effects.Remove(effect); } } return(dmg); }
/// <summary> /// Проверяем на возможность повышения уровня /// </summary> /// <param name="fighter">Боец</param> private static void LevelSet(BaseFighter fighter) { uint nextLevelExp; while ((nextLevelExp = (uint)(fighter.Level * 10) * 2) < fighter.Exp) { // Проверяем на возможность повышения уровня и сбрасываем кол-во опыта на уровне if (fighter.Exp > nextLevelExp) { fighter.Level++; fighter.Exp -= nextLevelExp; fighter.LvlUp += 3; } } }
/// <summary> /// Использование супер-способностей /// </summary> /// <param name="fighterOne">Атакующий</param> /// <param name="fighterTwo">Защищающийся</param> /// <returns>Накладывает положительные или отрицательные эффекты</returns> public static int SuperAbility(this BaseFighter fighterOne, BaseFighter fighterTwo) { int attack = 0; if (fighterOne.Mana >= fighterOne.Ability.Cost) { Console.ForegroundColor = fighterOne.Color; fighterOne.Mana = -fighterOne.Ability.Cost; fighterOne.Ability.Use(fighterOne, fighterTwo); Console.ForegroundColor = ConsoleColor.White; } return(attack); }
// BaseFighter events protected override void OnEnemyDetected(BaseFighter enemy) { base.OnEnemyDetected(enemy); // Unit FighterUnit specific code here // Set this as our current target target = enemy; // Flag the timer so that we attack ASAP attackTimer = AttackSpd + 1.0f; // Finally, subscribe to their CombatEvents enemy.CombatEvent += TargetDefeated; }
public override void ExecuteCommand(string character, IEnumerable <string> args, string channel) { if (Plugin.CurrentBattlefield.IsActive || (Plugin.FirstFighter != null && Plugin.SecondFighter != null)) { throw new FightInProgress(); } else if (Plugin.FirstFighter?.Name == character || Plugin.SecondFighter?.Name == character) { throw new FighterAlreadyExists(character); } BaseFighter fighter = null; using (var context = Plugin.Context) { fighter = context.Fighters.Find(character); } if (fighter == null) { throw new FighterNotRegistered(character); } var actualFighter = new Fighter(fighter, Plugin.CurrentBattlefield); if (Plugin.FirstFighter == null && Plugin.SecondFighter != null) { Plugin.FirstFighter = Plugin.SecondFighter; Plugin.SecondFighter = null; } if (Plugin.FirstFighter == null) { Plugin.FirstFighter = actualFighter; Plugin.FChatClient.SendMessageInChannel($"{actualFighter.Name} joined the fight!", channel); } else { Plugin.SecondFighter = actualFighter; if (!Plugin.CurrentBattlefield.IsActive && (Plugin.FirstFighter != null && Plugin.SecondFighter != null)) { Plugin.FChatClient.SendMessageInChannel($"{actualFighter.Name} accepted the challenge! Let's get it on!", channel); Plugin.FChatClient.SendMessageInChannel(Constants.VCAdvertisement, channel); Plugin.CurrentBattlefield.InitialSetup(Plugin.FirstFighter, Plugin.SecondFighter); } } }
public override void ExecuteCommand(string character, IEnumerable <string> args, string channel) { using (var context = Plugin.Context) { var fighter = context.Fighters.Find(character); if (fighter != null) { throw new FighterAlreadyExists(character); } int[] statsArray; try { statsArray = Array.ConvertAll(args.ToArray(), int.Parse); if (statsArray.Length != 5) { throw new Exception(); } } catch (Exception) { throw new ArgumentException("Invalid arguments. All stats must be numbers. Example: !register 5 8 8 1 2"); } var createdFighter = new BaseFighter() { Name = character, Strength = statsArray[0], Dexterity = statsArray[1], Resilience = statsArray[2], Endurance = statsArray[3], Special = statsArray[4] }; if (createdFighter.AreStatsValid) { context.Fighters.Add(createdFighter); context.SaveChanges(); Plugin.FChatClient.SendMessageInChannel($"Welcome among us, {character}!", channel); } else { throw new Exception(string.Join(", ", createdFighter.GetStatsErrors())); } } }
public void Start(BaseFighter fighter) { string strCh; int ch; do { Console.Clear(); messager?.Invoke($"Добро пожаловать, {fighter.Name}"); messager?.Invoke("Что будем делать ?"); messager?.Invoke("1 - Найти противника\n2 - Повысить уровень\n3 - Магазин\n4 - Информация о герое\n5 - Выход в меню"); strCh = Console.ReadLine(); if (int.TryParse(strCh, out ch)) { switch (ch) { case 1: var fm = new FightMenu(fighter); fm.StartAtack(); break; case 2: throw new MissingMethodException("Реализация в процессе"); break; case 3: throw new MissingMethodException("Реализация в процессе"); break; case 4: FighterInfoHelper.fighterFullInfo(fighter); messager?.Invoke("Для продолжения, нажмите 'Enter'..."); Console.ReadLine(); break; case 5: break; default: throw new NotSupportedException("Хакер, что ли"); break; } } } while (ch != 5); }
/// <summary> /// Fired when we're involved in a TriggerEnter event /// </summary> void OnTriggerEnter(Collider other) { BaseFighter othBF = other.GetComponent <BaseFighter> (); if (othBF == null) { // If we can't find a BaseFighter component, we can't fight this thing // Ignore return; } // We're here if something entered our trigger collider and we can fight it! if (other.tag == enemyTag) { // We found an enemy! OnEnemyDetected(othBF); } }