public bool Hover()
        {
            if (State != KnifeState.Flying)
            {
                return(false);
            }

            piercing = false;
            State    = KnifeState.Hover;

            _attackMove     = floatAttack;
            _defaultType    = AttackType.Float;
            _baseAttackRate = floatAttackRate;
            Activate(AttackPackage.CreateNewPackage(), _attackMove);

            if (flyingVFX)
            {
                flyingVFX.SetParent(null);
            }

            if (chargeFlyingEffect)
            {
                chargeFlyingEffect.StopDraw();
            }

            return(true);
        }
示例#2
0
        public void StartAttack()
        {
            var obj = Instantiate(_wavePrefab).GetComponent <BaseWeapon>();

            obj.Activate(AttackPackage.CreateNewPackage(), null);
            obj.transform.position = _attackPoint.position;
        }
示例#3
0
        public virtual void Launch()
        {
            if (_launchEffect != null)
            {
                _launchEffect.Play();
            }

            var projectile = GetProjectile();

            projectile.Activate(AttackPackage.CreateNewPackage(), _move);
        }
        private AttackPackage CreateNewPackage(AttackType type, AttackMove move)
        {
            var package = AttackPackage.CreateNewPackage();

            package._hitPointDamage.Base  = _baseHitPointDamage;
            package._enduranceDamage.Base = _baseEnduranceDamage;
            package._attackType           = type;
            package._faction = Faction.Player;
            package          = move.Process(package);

            return(package);
        }
示例#5
0
        public void ChargedMeleeAttack(float chargedPercent)
        {
            var package = AttackPackage.CreateNewPackage();

            package._faction              = Faction.Player;
            package._attackType           = AttackType.ChargedMelee;
            package._hitPointDamage.Base  = _state._hitPointDamage;
            package._enduranceDamage.Base = _state._enduranceDamage;
            package._chargedPercent.Base  = chargedPercent;
            OnRaisingAttack?.Invoke(sword, chargedMeleeMove);

            sword.Activate(package, chargedMeleeMove);

            _audio.clip = _normalMeleeSFX.PickRandom();
            _audio.Play();
        }
        public bool Withdraw()
        {
            if (State == KnifeState.InSheath || State == KnifeState.Returning)
            {
                return(false);
            }

            transform.parent = null;
            State            = KnifeState.Returning;

            _attackMove     = piercing ? chargedAttack : normalAttack;
            _defaultType    = piercing ? AttackType.ChargedRange : AttackType.Range;
            _baseAttackRate = normalAttackRate;
            Activate(AttackPackage.CreateNewPackage(), _attackMove);

            if (stuckOn != null)
            {
                Vector2 toStuckOn = (stuckOn as Component).transform.position - this.transform.position;
                toStuckOn = toStuckOn.normalized * PullingForce;
                if (stuckOn.TryPullOut(this.gameObject, ref toStuckOn))
                {
                    var direction = sheath.transform.position - this.transform.position;
                    direction    = DirectionalHelper.NormalizeHorizonalDirection(direction);
                    _defaultType = AttackType.StuckNDraw;
                    TryAttack(stuckAttack, direction);
                }

                stuckOn = null;
            }

            Returning();


            if (flyingVFX)
            {
                flyingVFX.SetParent(this.transform);
                flyingVFX.position = transform.position;
                flyingVFX.rotation = transform.rotation;
            }

            if (chargeFlyingEffect && piercing)
            {
                chargeFlyingEffect.StartDraw();
            }

            return(true);
        }
        public bool Launch(Vector3 direction, bool isPiercing = false)
        {
            if (State != KnifeState.InSheath)
            {
                return(false);
            }

            piercing = isPiercing;
            State    = KnifeState.Flying;

            transform.position = sheath.LaunchPosition.position;
            transform.right    = direction;

            _attackMove     = isPiercing ? chargedAttack : normalAttack;
            _defaultType    = isPiercing ? AttackType.ChargedRange : AttackType.Range;
            _baseAttackRate = normalAttackRate;
            Activate(AttackPackage.CreateNewPackage(), _attackMove);

            if (flyingVFX)
            {
                flyingVFX.SetParent(this.transform);
                flyingVFX.position = transform.position;
                flyingVFX.rotation = transform.rotation;

                List <ParticleSystem> particles = new List <ParticleSystem>();
                flyingVFX.GetComponentsInChildren(particles);

                foreach (var particle in particles)
                {
                    particle.Play();
                }
            }

            if (chargeFlyingEffect && piercing)
            {
                chargeFlyingEffect.StartDraw();
            }

            return(true);
        }
示例#8
0
        public void MeleeAttack()
        {
            var package = AttackPackage.CreateNewPackage();

            package._faction              = Faction.Player;
            package._attackType           = AttackType.Melee;
            package._hitPointDamage.Base  = _state._hitPointDamage;
            package._enduranceDamage.Base = _state._enduranceDamage;
            OnRaisingAttack?.Invoke(sword, meleeMove);

            sword.Activate(package, meleeMove);

            if (_currentAttackEffect)
            {
                return;
            }
            _currentAttackEffect = Instantiate(_attackEffectPrefab);
            _currentAttackEffect.transform.SetParent(sword.transform);
            _currentAttackEffect.transform.localPosition = Vector3.zero;

            _audio.clip = _normalMeleeSFX.PickRandom();
            _audio.Play();
        }