Exemple #1
0
        public void Attack(Actor attacker, Actor attacked)
        {
            Debug.Assert(attacker.skillReachable.Contains(attacked.tilePosition));

            bool hasCover = IsInCoverTo(attacked, attacker);

            if (!hasCover || random.NextDouble() >= 0.5)
            {
                //hit
                attacked.TakeDamage(attacker.GetCurrentDamage());
                attacker.currAmmo--;
                attacker.UsedSkill();
            }
            else
            {
                //no hit
                attacker.currAmmo--;
                attacker.UsedSkill();
                damagePopup.Show(attacker, "miss");
            }


            if (attacker.faction == Faction.User)
            {
                Sounds.Play("playerAttack");
                Effects.ShowEffect("playerAttack", attacker.realPosition);
            }
            else
            {
                Sounds.Play("enemyAttack");
                Effects.ShowEffect("redLaser", attacker.realPosition);
            }
        }