コード例 #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;
        }