コード例 #1
0
        public void PerformAttack(Character targetCharacter)
        {
            if (targetCharacter.Type == CharacterType.NPC)
            {
                Target = EcsEntity.Null;
                return;
            }

            var targetEntity = targetCharacter.Entity.Get <CombatEntity>();

            if (!targetEntity.IsValidTarget(CombatEntity))
            {
                ClearTarget();
                return;
            }

            Character.StopMovingImmediately();

            if (Character.AttackCooldown > Time.ElapsedTimeFloat)
            {
                QueueAttack = true;
                Target      = targetCharacter.Entity;
                return;
            }

            Character.SpawnImmunity = -1;

            CombatEntity.PerformMeleeAttack(targetEntity);

            QueueAttack = true;

            Character.AttackCooldown = Time.ElapsedTimeFloat + CombatEntity.Stats.AttackMotionTime;
        }
コード例 #2
0
        private bool OutPerformAttack()
        {
            var targetEntity = targetCharacter.Entity.Get <CombatEntity>();

            if (!targetEntity.IsValidTarget(CombatEntity))
            {
                return(false);
            }

            CombatEntity.PerformMeleeAttack(targetEntity);

            nextAiUpdate += MonsterBase.AttackTime;

            return(true);
        }