Ejemplo n.º 1
0
        /// <summary>
        /// Check if the player is reaches the tick threshold and reset it.
        /// </summary>
        /// <param name="client"></param>
        private void UpdatePlayerTicks(Client client)
        {
            if (client == null)
            {
                return;
            }

            if (!client.HasData(EntityData.CurrentTick))
            {
                client.SetData(EntityData.CurrentTick, 0);
            }

            int currentTick = client.GetData(EntityData.CurrentTick);

            if (currentTick + 1 > Maxtick)
            {
                currentTick = 1;
            }

            client.SetData(EntityData.CurrentTick, currentTick + 1);

            if (!client.HasData(EntityData.Attack))
            {
                return;
            }

            if (client.GetData(EntityData.Attack) == null)
            {
                return;
            }

            bool isAttackReady = Weapons.IsWeaponTickReady(client.CurrentWeapon.ToString(), currentTick);

            if (!isAttackReady)
            {
                return;
            }

            AttackEvent.Trigger(client, client.GetData(EntityData.Attack) as Client, client.CurrentWeapon.ToString());
        }