Example #1
0
        public void StartCombat()
        {
            PlayerUnit = new Unit();
            EnemyUnit = new Unit();

            PlayerUnit.Position = new Vector2(4, 4);
            EnemyUnit.Position = new Vector2(4, 5);

            PlayerUnit.Name = "PlayerBot";
            EnemyUnit.Name = "EnemyBot";

            PlayerUnit.Target = EnemyUnit;
            EnemyUnit.Target = PlayerUnit;

            CurrentUnit = PlayerUnit;

            Game1.ActiveScreen = new CombatScreen();
        }
Example #2
0
        public static void UseSkill(Unit source, Unit target, String skill)
        {
            var actionPointCost = DataManager.SkillValueAsInt(skill, SkillKey.APCost);

            var baseDamage = CalculateBaseDamage(skill);
            var attackResult = DetermineAttackResult(source, target);
            var totalDamage = TotalDamageFromResult(attackResult, baseDamage);
            var combatMessage = CombatMessageFromResult(source, target, skill, attackResult, totalDamage);

            if (totalDamage > 0)
                if (source == GameManager.Instance.PlayerUnit) {
                    GameManager.AddEffect(new Hitspark(target.ScreenPosition));
                    GameManager.AddEffect(new EnemyFlash(target.ScreenPosition, CombatModule.EnemyRobotTexture));
                } else {
                    GameManager.AddEffect(new ScreenFlash());
                }

            ProcessEffects(source, target, skill);
            GameManager.Instance.Logger.SetText(combatMessage);

            source.ActionPoints -= actionPointCost;
            target.Health -= totalDamage;
        }
Example #3
0
        private static string CombatMessageFromResult(Unit source, Unit target, String skill, AttackResult attackResult, int damage)
        {
            var effectString = String.Empty;
            switch (attackResult) {
                case AttackResult.Hit:
                    effectString = String.Format("dealing {0} damage", damage);
                    break;
                case AttackResult.Miss:
                    effectString = String.Format("but misses, dealing no damage.");
                    break;
                case AttackResult.Critical:
                    effectString = String.Format("dealing a critical blow for {0} total damage!", damage);
                    break;
                case AttackResult.Glancing:
                    effectString = String.Format("dealing {0} damage with a glancing attack", damage);
                    break;
            }

            return String.Format("{0} fires off a {1} at {2}, {3}.",
                source.Name,
                skill,
                target.Name,
                effectString);
        }
Example #4
0
 public static void EndTurn(Unit currentUnit)
 {
     StartTurn(currentUnit.Target);
 }
Example #5
0
        private static void StartTurn(Unit currentUnit)
        {
            GameManager.Instance.CurrentUnit = currentUnit;
            if (currentUnit.StunCounter > 0) {
                GameManager.Instance.Logger.SetText(currentUnit.Name + " is stunned and cannot act!");
                currentUnit.StunCounter--;
                EndTurn(currentUnit);
            }

            currentUnit.ActionPoints = 100;
        }
Example #6
0
 private static void ProcessEffects(Unit source, Unit target, String skill)
 {
     target.StunCounter = DataManager.SkillValueAsInt(skill, SkillKey.Stun) != 0
         ? DataManager.SkillValueAsInt(skill, SkillKey.Stun)
         : target.StunCounter;
     source.OnCounterSkill = DataManager.SkillValue(skill, SkillKey.OnCounter);
     source.EvasionCounter = DataManager.SkillValueAsInt(skill, SkillKey.Counter);
 }
Example #7
0
        private static AttackResult DetermineAttackResult(Unit source, Unit target)
        {
            var d100 = GameManager.Instance.Random.Next(1, 101);
            var margin = source.HitRating - target.EvadeRating + d100;

            if (target.EvasionCounter > 0) {
                String text;
                target.EvasionCounter--;

                var counterSkill = target.OnCounterSkill;

                if (counterSkill != String.Empty) {
                    ProcessEffects(target, source, target.OnCounterSkill);
                    text = String.Format("{0} skillfully evades {1}'s blow, and strikes back with a [{2}]", target.Name, source.Name, counterSkill);
                    target.OnCounterSkill = String.Empty;
                } else {
                    text = String.Format("{0} skillfully evades {1}'s blow", target.Name, source.Name);
                }

                Console.WriteLine(text);
                GameManager.Instance.Logger.SetText(text);

                return AttackResult.Miss;
            }

            if (margin >= 50)
                return AttackResult.Critical;
            if (margin >= 10)
                return AttackResult.Hit;
            if (margin > 0)
                return AttackResult.Glancing;

                return AttackResult.Miss;
        }