예제 #1
0
        protected virtual void Fire(bool alternative)
        {
            DoPreFireEvent(alternative);

            MeleeWeaponType.MeleeWeaponMode typeMode = alternative ?
                                                       Type.AlternativeMode : Type.NormalMode;

            if (typeMode.FireTimes.Count == 0)
            {
                return;
            }

            readyTimeRemaining  = typeMode.BetweenFireTime;
            currentFireTypeMode = typeMode;
            currentFireTime     = 0;
            fireTimesExecuted   = 0;

            OnFire(typeMode);

            if (EntitySystemWorld.Instance.IsServer() &&
                Type.NetworkType == EntityNetworkTypes.Synchronized)
            {
                Server_SendFireEventToAllClients(alternative);
            }
        }
예제 #2
0
        void Client_ReceiveSoundPlayKick(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            bool alternative = reader.ReadBoolean();

            if (!reader.Complete())
            {
                return;
            }
            MeleeWeaponType.MeleeWeaponMode typeMode = alternative ?
                                                       Type.AlternativeMode : Type.NormalMode;
            SoundPlay3D(typeMode.SoundKick, .5f, false);
        }
예제 #3
0
        void Client_ReceiveFireEvent(RemoteEntityWorld sender, ReceiveDataReader reader)
        {
            bool alternative = reader.ReadBoolean();

            if (!reader.Complete())
            {
                return;
            }
            MeleeWeaponType.MeleeWeaponMode typeMode = alternative ?
                                                       Type.AlternativeMode : Type.NormalMode;
            OnFire(typeMode);
        }
예제 #4
0
        /// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnTick()"/>.</summary>
        protected override void OnTick()
        {
            base.OnTick();

            //fireTimes
            if (currentFireTypeMode != null)
            {
                currentFireTime += TickDelta;
                int fireTimesCount = currentFireTypeMode.FireTimes.Count;
                if (fireTimesExecuted < fireTimesCount)
                {
again:
                    if (fireTimesExecuted < fireTimesCount)
                    {
                        float nextTime = currentFireTypeMode.FireTimes[fireTimesExecuted];
                        if (currentFireTime >= nextTime)
                        {
                            fireTimesExecuted++;
                            Blow();
                            goto again;
                        }
                    }
                }
                else
                {
                    currentFireTypeMode = null;
                }
            }

            if (readyTimeRemaining != 0)
            {
                float coef = 1.0f;

                Unit unit = GetParentUnitHavingIntellect();
                if (unit != null && unit.FastAttackInfluence != null)
                {
                    coef *= unit.FastAttackInfluence.Type.Coefficient;
                }

                readyTimeRemaining -= TickDelta * coef;
                if (readyTimeRemaining < 0)
                {
                    readyTimeRemaining = 0;
                }
            }
        }
예제 #5
0
        public override bool TryFire(bool alternative)
        {
            if (!Ready)
            {
                return(false);
            }

            MeleeWeaponType.MeleeWeaponMode typeMode = alternative ?
                                                       Type.AlternativeMode : Type.NormalMode;

            if (typeMode.Damage == 0 && typeMode.Impulse == 0)
            {
                return(false);
            }

            Fire(alternative);
            return(true);
        }
예제 #6
0
        protected override bool OnLoad(TextBlock block)
        {
            if (!base.OnLoad(block))
            {
                return(false);
            }

            if (block.IsAttributeExist("currentFireTypeMode"))
            {
                if (block.GetAttribute("currentFireTypeMode") == "normal")
                {
                    currentFireTypeMode = Type.NormalMode;
                }
                else
                {
                    currentFireTypeMode = Type.AlternativeMode;
                }
            }

            return(true);
        }
예제 #7
0
        void OnFire(MeleeWeaponType.MeleeWeaponMode typeMode)
        {
            //sound
            SoundPlay3D(typeMode.SoundFire, .5f, true);

            //update animation tree
            if (!string.IsNullOrEmpty(typeMode.FireAnimationTrigger))
            {
                foreach (AnimationTree tree in GetAllAnimationTrees())
                {
                    tree.ActivateTrigger(typeMode.FireAnimationTrigger);
                }

                Unit parentUnit = GetParentUnit();
                if (parentUnit != null)
                {
                    foreach (AnimationTree parentTree in parentUnit.GetAllAnimationTrees())
                    {
                        parentTree.ActivateTrigger(typeMode.FireAnimationTrigger);
                    }
                }
            }
        }
예제 #8
0
        protected virtual void Fire(bool alternative)
        {
            DoPreFireEvent(alternative);

            MeleeWeaponType.MeleeWeaponMode typeMode = alternative ?
                Type.AlternativeMode : Type.NormalMode;

            if (typeMode.FireTimes.Count == 0)
                return;

            readyTimeRemaining = typeMode.BetweenFireTime;
            currentFireTypeMode = typeMode;
            currentFireTime = 0;
            fireTimesExecuted = 0;

            OnFire(typeMode);

            if (EntitySystemWorld.Instance.IsServer() &&
                Type.NetworkType == EntityNetworkTypes.Synchronized)
            {
                Server_SendFireEventToAllClients(alternative);
            }
        }
예제 #9
0
        /// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnTick()"/>.</summary>
        protected override void OnTick()
        {
            base.OnTick();

            //fireTimes
            if (currentFireTypeMode != null)
            {
                currentFireTime += TickDelta;
                int fireTimesCount = currentFireTypeMode.FireTimes.Count;
                if (fireTimesExecuted < fireTimesCount)
                {
                again:
                    if (fireTimesExecuted < fireTimesCount)
                    {
                        float nextTime = currentFireTypeMode.FireTimes[fireTimesExecuted];
                        if (currentFireTime >= nextTime)
                        {
                            fireTimesExecuted++;
                            Blow();
                            goto again;
                        }
                    }
                }
                else
                    currentFireTypeMode = null;
            }

            if (readyTimeRemaining != 0)
            {
                float coef = 1.0f;

                Unit unit = GetParentUnitHavingIntellect();
                if (unit != null && unit.FastAttackInfluence != null)
                    coef *= unit.FastAttackInfluence.Type.Coefficient;

                readyTimeRemaining -= TickDelta * coef;
                if (readyTimeRemaining < 0)
                    readyTimeRemaining = 0;
            }
        }
예제 #10
0
        protected override bool OnLoad(TextBlock block)
        {
            if (!base.OnLoad(block))
                return false;

            if (block.IsAttributeExist("currentFireTypeMode"))
            {
                if (block.GetAttribute("currentFireTypeMode") == "normal")
                    currentFireTypeMode = Type.NormalMode;
                else
                    currentFireTypeMode = Type.AlternativeMode;
            }

            return true;
        }