Exemplo n.º 1
0
        // ----------------------------------
        /// <summary>
        /// Try entity attack
        /// </summary>
        public bool Try_Attack(string attack = "basic")
        {
            if (Attack_Roster.ContainsKey(attack))
            {
                // Save the current attack for ease of access
                // ----------------------------------
                Attack current_attack = Attack_Roster[attack];
                // ----------------------------------

                // Check focus costs
                // ----------------------------------
                if (current_attack.Focus_Cost > 0)
                {
                    if (!(Focus_Points >= current_attack.Focus_Cost))
                    {
                        if (this is Player && Shared.Player.Antispam.Time == 0)
                        {
                            Shared.SFX_Sounds["No_Focus"].Play();
                            Shared.Player.Antispam.Time = 0.5f;
                        }
                        return(false);
                    }
                }

                if (!dead && !busy && current_attack.Cooldown_timer == 0f)
                {
                    if (ATK_Direction != Shared.Direction.NONE)
                    {
                        // ----------------------------------
                        // Side Attacks
                        if (ATK_Direction == Shared.Direction.LEFT ||
                            ATK_Direction == Shared.Direction.RIGHT)
                        {
                            Set_State(Shared.EntityState.SIDE_ATTACK);
                        }
                        // ----------------------------------
                        // Up Attacks
                        if (ATK_Direction == Shared.Direction.UP)
                        {
                            Set_State(Shared.EntityState.UP_ATTACK);
                        }
                        // ----------------------------------
                        // Down Attacks
                        if (ATK_Direction == Shared.Direction.DOWN)
                        {
                            Set_State(Shared.EntityState.DOWN_ATTACK);
                        }
                        // ----------------------------------
                    }
                    // ----------------------------------
                    // Attack isn't directional, just set to attack
                    else
                    {
                        Set_State(Shared.EntityState.ATTACKING);
                    }
                    // ----------------------------------

                    // ----------------------------------
                    // Do attacky things.
                    if (current_attack.SFX != null)
                    {
                        current_attack.SFX.Play();
                    }

                    current_attack.Cooldown_timer = current_attack.Cooldown;

                    Focus_Points -= current_attack.Focus_Cost;

                    Anim_index    = 0;
                    Active_Attack = attack;

                    Handle_Attack_Projectiles();
                    return(true);
                    // ----------------------------------
                }
            }
            return(false);
        }