Esempio n. 1
0
        // -------------------------------
        #endregion
        // -------------------------------

        // -------------------------------
        /// <summary>
        /// Creates a cute simple automated blood splurt at the position
        /// </summary>
        /// <param name="position">Position to splurt</param>
        /// <param name="quantity">Quantity of blood particles</param>
        public static void Do_Bloodspurt(Character source, int quantity, int intensity = 5, bool fountain = false)
        {
            for (int count = 0; count < quantity; count++)
            {
                if (fountain)
                {
                    Particles.Do_Effect(
                        "Blood",
                        1f,
                        Vector2.Zero,
                        new Vector2
                        (
                            Shared.Randomizer.Next(-intensity, intensity),
                            Shared.Randomizer.Next(-10, 0)
                        ),
                        source: source
                        );
                }
                else
                {
                    Particles.Do_Effect(
                        "Blood",
                        1f,
                        Vector2.Zero,
                        new Vector2
                        (
                            Shared.Randomizer.Next(-intensity, intensity),
                            Shared.Randomizer.Next(-intensity, intensity)
                        ),
                        source: source
                        );
                }
            }
        }
Esempio n. 2
0
        // ----------------------------------

        // ----------------------------------
        /// <summary>
        /// Shows this NPC's healthbar
        /// </summary>
        public void Show_Health()
        {
            // ----------------------------------
            // Health Container. Remove old if not null
            if (health_container != null)
            {
                Particles.Active_Effects.Remove(health_container);
            }

            Particles.Do_Effect(
                "HPcontainer",
                4,
                new Vector2(0, -((Get_Bounds().Height) / 2 + Particles.Effects["HPcontainer"].Dimensions.Y)),
                Vector2.Zero,
                true,
                this
                );
            // ----------------------------------
            // Health Bar. Remove old if not null
            if (health_bar != null)
            {
                Particles.Active_Effects.Remove(health_bar);
            }

            Particles.Do_Effect(
                "HP",
                4,
                new Vector2(0, -((Get_Bounds().Height) / 2 + Particles.Effects["HP"].Dimensions.Y)),
                Vector2.Zero,
                true,
                this
                );
        }
Esempio n. 3
0
        // ----------------------------------
        /// <summary>
        /// Try entity dead
        /// </summary>
        public void Try_Dead()
        {
            if (!dead)
            {
                Shared.SFX_Sounds["Overflow"].Play();

                Particles.Do_Bloodspurt(this, 20, 5);

                Particles.Do_Effect(
                    "Death",
                    3,
                    Vector2.Zero,
                    Vector2.Zero,
                    false,
                    this);

                if (this is Player)
                {
                    Shared.Player.Respawner.Time = Shared.Player.Respawn_Delay;
                }
            }
            dead = true;
        }
        // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


        // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        // Behavior Actions
        // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        /// <summary>
        /// Pursuit behavior - NPC chases target entity
        /// </summary>
        /// <returns>Returns true if able to chase target</returns>
        public bool Pursue()
        {
            // -------------------------------
            // Reference timer for ease of acess
            Clock pursue_timer = Timers["Pursue"];

            // -------------------------------
            if (target != null && !target.Is_dead())
            {
                // -------------------------------
                // Save result of Sight & Range check
                bool Sight_And_Range_Check = Sight_And_Range(target);
                // -------------------------------
                if (!Sight_And_Range_Check && pursue_timer.Primary_Decision == 1)
                {
                    pursue_timer.Time = host.Persistence;
                }

                if (Sight_And_Range_Check || pursue_timer.Time > 0f)
                {
                    // -------------------------------
                    if (pursue_timer.Secondary_Decision == 0)
                    {
                        // -------------------------------
                        Shared.SFX_Sounds["ALERT"].Play();
                        Particles.Do_Effect(
                            "Alert",
                            1,
                            new Vector2(0, -((host.Get_Bounds().Height) / 2 + Particles.Effects["Alert"].Dimensions.Y)),
                            Vector2.Zero,
                            true,
                            host);
                        // Ensures the alert emote only plays once per sighting
                        pursue_timer.Secondary_Decision = 1;
                        // -------------------------------
                    }
                    // -------------------------------
                    if (Sight_And_Range_Check)
                    {
                        pursue_timer.Primary_Decision = 1;
                    }
                    else
                    {
                        pursue_timer.Primary_Decision = 0;
                    }

                    // x_offset has our pursuer try to run past their target instead of atop them.
                    // -------------------------------
                    int x_offset = 1;
                    if (host.Direction == Shared.Direction.LEFT)
                    {
                        x_offset = -1;
                    }
                    // -------------------------------
                    Vector2 target_dest = new Vector2
                                          (
                        target.Grid_Position.X + x_offset,
                        target.Grid_Position.Y
                                          );

                    if (host.Grid_Position == target_dest)
                    {
                        Turn_Around();
                    }

                    if (host.Direction == Shared.Direction.RIGHT &&
                        host.Grid_Position.X > target.Grid_Position.X)
                    {
                        Turn_Around();
                    }
                    else if (host.Direction == Shared.Direction.LEFT &&
                             host.Grid_Position.X < target.Grid_Position.X)
                    {
                        Turn_Around();
                    }

                    Chase(target_dest, "run");
                    // -------------------------------
                    return(true);
                }
                else if (pursue_timer.Secondary_Decision == 1)
                {
                    // -------------------------------
                    Shared.SFX_Sounds["CONFUSED"].Play();
                    Particles.Do_Effect(
                        "Confused",
                        2,
                        new Vector2(0, -((host.Get_Bounds().Height / 2) + Particles.Effects["Alert"].Dimensions.Y)),
                        Vector2.Zero,
                        true,
                        host);
                    // Ensures the confused emote only plays once per sighting
                    pursue_timer.Secondary_Decision = 0;
                    // -------------------------------
                }
            }
            else     // Target is null! They don't exist no more! Or never did! Set to defaults.
            {
                pursue_timer.Time               = 0f;
                pursue_timer.Primary_Decision   = 0;
                pursue_timer.Secondary_Decision = 0;
            }
            return(false);
        }