Exemplo n.º 1
0
        /// <summary>
        /// After a new projectile is created based on an available effect mold, it's finally given life
        /// </summary>
        /// <param name="lifespan">The duration this effect should live for</param>
        /// <param name="location">The raw X & Y coordinates of the effect</param>
        /// <param name="follow_source">Whether or not this effect should move with its source emitter</param>
        /// <param name="source">The source emitter of the effect</param>
        /// <param name="velocity">The velocity of the projectile</param>
        /// <param name="damage">Projectile damage</param>
        /// <param name="knockback">Projectile Knockback</param>
        /// <param name="damage_team">The damage team of the characters this projectile can harm</param>
        /// <param name="damage_type">The type of damage this projectile inflicts</param>
        /// <param name="spawn_frame">The frame in which this projecile spawns in its source's animation</param>
        public void Create_Projectile(
            float lifespan,
            Vector2 offset,
            bool follow_source,
            Character source,
            Vector2 velocity,
            int damage,
            float knockback,
            Shared.Damage_Team damage_team,
            Shared.Type damage_type,
            int spawn_frame)
        {
            this.lifespan      = lifespan;
            this.Velocity      = velocity;
            this.Damage        = damage;
            this.Knockback     = knockback;
            this.Damage_team   = damage_team;
            this.Damage_type   = damage_type;
            this.spawn_frame   = spawn_frame;
            this.position      = source.Position;
            this.Source_Offset = offset;

            if (source == null)
            {
                this.direction = Shared.Direction.RIGHT;
                follow_source  = false;

                this.position      = offset;
                this.Source_Offset = Vector2.Zero;
            }
            else
            {
                this.follow_source = follow_source;
                this.Source        = source;
                this.direction     = source.Direction;

                this.position      = source.Position;
                this.Source_Offset = offset;
            }

            if (!follow_source)
            {
                position += Source_Offset;
            }
        }
Exemplo n.º 2
0
        // -------------------------------
        /// <summary>
        /// Emites a new projectile from the available effect molds
        /// </summary>
        /// <param name="name">The name of the projectile</param>
        /// <param name="lifespan">The duration this effect should live for</param>
        /// <param name="source_offset">The X & Y offsets this projectile should spawn from</param>
        /// <param name="velocity">Velocity of the projectile</param>
        /// <param name="damage_team">Damage team this projectile should hurt</param>
        /// <param name="damage_type">The type of damage to inflict</param>
        /// <param name="spawn_frame">The frame in which this projectile should be fired in animation. Defaults to first frame.</param>
        /// <param name="follow_source">Whether or not this effect should move with its source emitter Defaults to false.</param>
        /// <param name="source">The source emitter of the effect. Defaults to null.</param>
        public static void Do_Projectile(
            string name,
            float lifespan,
            Vector2 source_offset,
            Vector2 velocity,
            int damage,
            float knockback,
            Shared.Damage_Team damage_team = Shared.Damage_Team.NEUTRAL,
            Shared.Type damage_type        = Shared.Type.MUNDANE,
            int spawn_frame    = 0,
            bool follow_source = false,
            Character source   = null)
        {
            if (Effects.ContainsKey(name))
            {
                Projectile projectile = new Projectile
                                        (
                    Effects[name].Image,
                    Effects[name].Dimensions,
                    Effects[name].Animation,
                    Effects[name].Anim_length,
                    Effects[name].Flippable,
                    Effects[name].Name
                                        );

                // Special Attributes
                // -------------------------
                projectile.overlay_color = Effects[name].Overlay_color;
                projectile.do_collision  = Effects[name].Do_collision;
                projectile.do_gravity    = Effects[name].Do_gravity;
                projectile.do_rotation   = Effects[name].Do_rotation;
                projectile.Resistance    = Effects[name].Resistance;
                // -------------------------

                projectile.Create_Projectile(lifespan, source_offset, follow_source, source, velocity, damage, knockback, damage_team, damage_type, spawn_frame);
                Active_Projectiles.Add(projectile);
            }
            else
            {
                Console.WriteLine("Projectile named '" + name + "' does not exist!");
            }
        }