Ejemplo n.º 1
0
        public override void SharedOnHit(
            WeaponFinalCache weaponCache,
            IWorldObject damagedObject,
            double damage,
            WeaponHitData hitData,
            out bool isDamageStop)
        {
            base.SharedOnHit(weaponCache,
                             damagedObject,
                             damage,
                             hitData,
                             out isDamageStop);

            if (IsClient)
            {
                // on client we cannot consume energy
                return;
            }

            // consume energy on hit
            var byCharacter          = weaponCache.Character;
            var requiredEnergyAmount = SkillWeaponsEnergy.SharedGetRequiredEnergyAmount(byCharacter,
                                                                                        this.EnergyUsePerHit);

            CharacterEnergySystem.ServerDeductEnergyCharge(byCharacter, requiredEnergyAmount);
        }
        // Please note: the check SharedCanFire() has been already passed
        public override bool SharedOnFire(ICharacter character, WeaponState weaponState)
        {
            if (IsClient)
            {
                // on client we cannot consume energy
                return true;
            }

            var requiredEnergyAmount = SkillWeaponsEnergy.SharedGetRequiredEnergyAmount(character,
                this.EnergyUsePerShot);
            return CharacterEnergySystem.ServerDeductEnergyCharge(character, requiredEnergyAmount);
        }
        public override bool SharedCanFire(ICharacter character, WeaponState weaponState)
        {
            var requiredEnergyAmount = SkillWeaponsEnergy.SharedGetRequiredEnergyAmount(character,
                this.EnergyUsePerShot);
            if (CharacterEnergySystem.SharedHasEnergyCharge(character, requiredEnergyAmount))
            {
                return true;
            }

            if (IsClient && weaponState.SharedGetInputIsFiring())
            {
                CharacterEnergySystem.ClientShowNotificationNotEnoughEnergyCharge(this);
                // stop using weapon item!
                weaponState.ProtoWeapon.ClientItemUseFinish(weaponState.ItemWeapon);
            }

            return false;
        }
        public override bool SharedCanSelect(IItem item, ICharacter character)
        {
            var requiredEnergyAmount = SkillWeaponsEnergy.SharedGetRequiredEnergyAmount(
                character,
                this.EnergyUsePerShot + this.EnergyUsePerHit);

            if (CharacterEnergySystem.SharedHasEnergyCharge(character, requiredEnergyAmount))
            {
                return(true);
            }

            if (IsClient)
            {
                CharacterEnergySystem.ClientShowNotificationNotEnoughEnergyCharge(this);
            }

            return(false);
        }
Ejemplo n.º 5
0
        public override bool SharedCanFire(ICharacter character, WeaponState weaponState)
        {
            var requiredEnergyAmount = SkillWeaponsEnergy.SharedGetRequiredEnergyAmount(
                character,
                this.EnergyUsePerShot + this.EnergyUsePerHit);

            if (CharacterEnergySystem.SharedHasEnergyCharge(character, requiredEnergyAmount))
            {
                return(true);
            }

            if (IsClient && weaponState.SharedGetInputIsFiring())
            {
                CharacterEnergySystem.ClientShowNotificationNotEnoughEnergyCharge(this);
                weaponState.ProtoWeapon.ClientItemUseFinish(weaponState.ItemWeapon);
                ClientHotbarSelectedItemManager.SelectedSlotId = null;
            }

            return(false);
        }
        public override void ServerOnDamageApplied(
            IItem weapon,
            ICharacter byCharacter,
            IWorldObject damagedObject,
            double damage)
        {
            base.ServerOnDamageApplied(weapon, byCharacter, damagedObject, damage);

            if (IsClient)
            {
                // on client we cannot deduct energy
                return;
            }

            // deduct energy on hit
            var requiredEnergyAmount = SkillWeaponsEnergy.SharedGetRequiredEnergyAmount(
                byCharacter,
                this.EnergyUsePerHit);

            CharacterEnergySystem.ServerDeductEnergyCharge(byCharacter, requiredEnergyAmount);
        }
Ejemplo n.º 7
0
        public override bool SharedCanSelect(IItem item, ICharacter character, bool isAlreadySelected, bool isByPlayer)
        {
            if (!base.SharedCanSelect(item, character, isAlreadySelected, isByPlayer))
            {
                return(false);
            }

            var requiredEnergyAmount = SkillWeaponsEnergy.SharedGetRequiredEnergyAmount(
                character,
                this.EnergyUsePerShot + this.EnergyUsePerHit);

            if (CharacterEnergySystem.SharedHasEnergyCharge(character, requiredEnergyAmount))
            {
                return(true);
            }

            // cannot select
            if (IsClient && isByPlayer)
            {
                CharacterEnergySystem.ClientShowNotificationNotEnoughEnergyCharge(this);
            }

            return(false);
        }