Example #1
0
        /// <summary>
        /// Registers a hit by the provided projectile. If the unit that the projectile hit
        /// is killed by the projectile, that is handled in this function.
        /// </summary>
        /// <param name="p">The projectile that struck its target</param>
        public void RegisterProjectileHit(Projectile p)
        {
            if (!p.Target.TargetBehavior.IsDead)
            {
                // Debug.Log(p.Target + " was hit by an attack for " + p.Damage + " damage!");
                p.Target.TargetBehavior.TakeDamage(p.Damage);
                if (p.Target.TargetBehavior.IsDead)
                {
                    // TODO: this block fires when a unit is killed by a projectile, maybe do particle stuff
                    p.Target.KillUnit();
                    p.Target.MovementBehavior.CurrentLocation.Occupants.Remove(p.Target);
                    _slainUnits[p.Target.UnitType] = 5;
                    _activeUnits.Remove(p.Target);

                    SoundPlayer.getInstance ().Play (sounds.death);
                }
            }

            p.MarkForDestruction();
            _deadProjectiles.Add(p);
        }
Example #2
0
        public ProjectileView(Projectile owner, Vector2 pos)
        {
            _owner = owner;

            _projectile = GuiAPI.CreateProjectile(pos.x, pos.y, ProjectileTypes.DummyProjectile);
        }
Example #3
0
        /// <summary>
        /// Spawns a new projectile and adds it to the list of pending projectiles in the
        /// CombatController.
        /// </summary>
        /// <param name="attacker">The unit that will spawn the projectile</param>
        /// <param name="target">The unit that the projectile will travel towards</param>
        public void LaunchAttackAtUnit(Unit attacker, Unit target)
        {
            // TODO where do we want to store projectile speed?
            Projectile newProjectile = new Projectile(attacker, target, 30);

            _pendingProjectiles.Add(newProjectile);
            //Debug.Log(attacker + " launched an attack at " + target + "!");

            SoundPlayer.getInstance ().Play (sounds.light_projectile);
        }