Пример #1
0
    public override void Activate(MonsterCharacter character, int index)
    {
        if (character.SkillCooldowns[index] > 0)
        {
            Sounds.CreateSound(FailSound);
            return;
        }

        if (character.ChargePoints < ChargeCost)
        {
            Messaging.GUI.ScreenMessage.Invoke("NOT ENOUGH CHARGE", Color.red);
            Sounds.CreateSound(FailSound);
            return;
        }

        if (character.SoftDamage <= 0)
        {
            Messaging.GUI.ScreenMessage.Invoke("NO ACCUMULATED DAMAGE", Color.red);
            Sounds.CreateSound(FailSound);
            return;
        }

        int HealPerTick = (int)(character.SoftDamage * Portion / ActiveTime / 50);

        if (HealPerTick <= 0)
        {
            Messaging.GUI.ScreenMessage.Invoke("NOT ENOUGH ACCUMULATED DAMAGE", Color.red);
            Sounds.CreateSound(FailSound);
            return;
        }

        Sounds.CreateSound(ActivationSound);

        HealSkill s = Instantiate(this, character.transform);

        s.targetCharacter = character;
        s.healPerTick     = HealPerTick;

        character.ChargePoints         -= ChargeCost;
        character.SoftDamage            = 0;
        character.SkillCooldowns[index] = ActiveTime;
    }
Пример #2
0
    private bool Fire()
    {
        if (RaiseTimer > 0f)
        {
            return(false);
        }
        if (HolsterTimer > 0f)
        {
            return(false);
        }
        if (attackCooldownTimer > 0f)
        {
            return(false);
        }
        if (emptyTimer > 0f)
        {
            return(false);
        }

        if (UsesAmmo >= 0)
        {
            if (character.ammunition[UsesAmmo] < AmmoUseAmount)
            {
                Messaging.GUI.ScreenMessage.Invoke("OUT OF AMMO", Color.red);
                Sounds.CreateSound(EmptySound);
                emptyTimer = .4f;
                return(false);
            }
        }

        if (attackCooldownTimer <= 0f)
        {
            attackCooldownTimer += attackCooldown;
            DamageBeam();
        }

        OnFire.Invoke();

        return(true);
    }
Пример #3
0
    public override void Activate(MonsterCharacter character, int index)
    {
        if (string.IsNullOrEmpty(GrenadeDesignation))
        {
            return;
        }

        if (character.SkillCooldowns[index] > 0)
        {
            Sounds.CreateSound(FailSound);
            return;
        }

        if (AmmoType != -1)
        {
            if (character.ammunition[AmmoType] < AmmoAmount)
            {
                Messaging.GUI.ScreenMessage.Invoke("OUT OF AMMO", Color.red);
                Sounds.CreateSound(FailSound);
                return;
            }

            character.ammunition[AmmoType] -= AmmoAmount;
        }

        Sounds.CreateSound(ActivationSound);

        character.SkillCooldowns[index] = Cooldown;

        GrenadeSkill g = Instantiate(this, LevelLoader.DynamicObjects);

        g.targetCharacter = character;

        Mouse.UpdateWorldPosition();
        float distance = (Mouse.WorldPosition - character.transform.position).magnitude;

        g.speed = Mathf.Lerp(ThrowSpeed.x, ThrowSpeed.y, Mathf.InverseLerp(AttackDistance.x, AttackDistance.y, distance));
    }
Пример #4
0
    public override void Activate(MonsterCharacter character, int index)
    {
        if (character.SkillCooldowns[index] > 0)
        {
            if (character.Buffs.ContainsKey((int)StatusEffect.Shield))
            {
                character.Buffs[(int)StatusEffect.Shield].GetComponent <Skill>().DeActivateInstance();
                character.Buffs.Remove((int)StatusEffect.Shield);
            }
        }
        else
        {
            if (character.ChargePoints < ChargeCostPerSecond)
            {
                return;
            }

            Sounds.CreateSound(ActivationSound);

            ShieldSkill s = Instantiate(this, character.transform);
            s.targetCharacter = character;
            s.skillIndex      = index;
        }
    }
Пример #5
0
    private bool Fire()
    {
        if (cooldownTimer > 0f)
        {
            return(false);
        }
        if (RaiseTimer > 0f)
        {
            return(false);
        }
        if (HolsterTimer > 0f)
        {
            return(false);
        }
        if (UsesAmmo >= 0)
        {
            if (character.ammunition[UsesAmmo] < AmmoUseAmount)
            {
                Messaging.GUI.ScreenMessage.Invoke("OUT OF AMMO", Color.red);
                Sounds.CreateSound(EmptySound);
                cooldownTimer = .4f;
                return(false);
            }

            character.ammunition[UsesAmmo] -= AmmoUseAmount;
        }

        cooldownTimer = attackCooldown;

        CreateRocket();

        salvoRemain = Salvo;
        salvoTimer  = SalvoTime;

        return(true);
    }
Пример #6
0
    private bool AltFire()
    {
        if (AltFireBulletDamage <= 0)
        {
            return(false);
        }
        if (cooldownTimer > 0f)
        {
            return(false);
        }
        if (RaiseTimer > 0f)
        {
            return(false);
        }
        if (HolsterTimer > 0f)
        {
            return(false);
        }
        if (UsesAmmo >= 0)
        {
            if (character.ammunition[UsesAmmo] < altFireAmmoUseAmount)
            {
                Messaging.GUI.ScreenMessage.Invoke("OUT OF AMMO", Color.red);
                Sounds.CreateSound(AltFireEmptySound);
                cooldownTimer = .4f;
                return(false);
            }

            character.ammunition[UsesAmmo] -= altFireAmmoUseAmount;
        }

        cooldownTimer = altFireCooldown;

        Sounds.CreateSound(AltFireSound);

        if (MuzzlePrefab != null)
        {
            GameObject muzzle = Instantiate(MuzzlePrefab);
            muzzle.transform.rotation = _weaponPrefab.transform.rotation * Quaternion.Euler(MuzzleRotation);
            muzzle.transform.position = _weaponPrefab.transform.position + muzzle.transform.TransformDirection(MuzzlePosition);
            muzzle.transform.SetParent(_weaponPrefab.transform);
        }

        int burst = altFireBurst;

        while (burst-- > 0)
        {
            if (BulletPrefab != null)
            {
                Bullet bullet = Instantiate(BulletPrefab, LevelLoader.DynamicObjects);
                bullet.owner      = character;
                bullet.Damage     = AltFireBulletDamage;
                bullet.damageType = BulletDamageType;
                bullet.LifeTime   = BulletLifeTime;
                bullet.Force      = BulletForce;
                bullet.Speed      = BulletSpeed;

                //make a special raycasting move from character to barrel
                bullet.transform.position = character.transform.position;
                bullet.InitialMove((_weaponPrefab.transform.position + _weaponPrefab.transform.rotation * BulletPosition) - character.transform.position);

                if (AttackDirection == Vector2.zero)
                {
                    bullet.transform.rotation = character.LookDirection;
                }
                else
                {
                    bullet.transform.rotation = Quaternion.Euler(0, 0, Mathf.Atan2(AttackDirection.x, -AttackDirection.y) * Mathf.Rad2Deg);
                }

                //add spread
                float firstRoll  = Random.Range(-altFireSpread, altFireSpread);
                float secondRoll = Random.Range(-altFireSpread, altFireSpread);

                bullet.transform.rotation *= Quaternion.Euler(0, 0, Mathf.Abs(firstRoll) < Mathf.Abs(secondRoll) ? firstRoll : secondRoll);

                bullet.GetComponent <SaveGameObject>().SpawnName = BulletDesignation;
            }
        }

        OnFire.Invoke();

        return(true);
    }
Пример #7
0
 public override void DeActivateInstance()
 {
     GoingDown = true;
     Sounds.CreateSound(DeactivationSound);
     OnDeactivateInstance.Invoke();
 }
Пример #8
0
    private bool Fire()
    {
        if (cooldownTimer > 0f)
        {
            return(false);
        }
        if (RaiseTimer > 0f)
        {
            return(false);
        }
        if (HolsterTimer > 0f)
        {
            return(false);
        }

        cooldownTimer = attackCooldown;
        reboundTimer  = reboundCooldown;

        character.CallAnimation(AttackAnimation);
        character.CurrentWeaponAnimation = AttackAnimation;

        Vector3 pos = _weaponPrefab.transform.position + character.LookDirection * attackCenter;

        Collider2D[] targets  = Physics2D.OverlapCircleAll(pos, radius);
        bool         hitEnemy = false;

        foreach (Collider2D target in targets)
        {
            Damageable d = target.GetComponent <Damageable>();
            if (d == null)
            {
                continue;
            }
            if (d == character as Damageable)
            {
                continue;
            }

            Vector2 dif      = target.transform.position - pos;
            Vector2 dir      = dif == Vector2.zero ? Vector2.zero : dif.normalized;
            Vector2 hitPoint = (Vector2)target.transform.position - dir;

            d.HitSound(hitPoint, AttackType.Melee);

            d.Impulse(dir, Force);
            d.Damage(new DamageFrame(Damage, AttackType.Melee, DamageType.Physical, character, hitPoint));

            hitEnemy = true;
        }

        if (hitEnemy)
        {
            character.ChargePoints += RechargeChargeAmount;
        }

        if (EffectPrefab)
        {
            GameObject effect = Instantiate(EffectPrefab, LevelLoader.TemporaryObjects);
            effect.transform.position = _weaponPrefab.transform.position + character.LookDirection * EffectPosition;
            effect.transform.rotation = character.LookDirection;
        }

        Sounds.CreateSound(AttackSound);

        return(true);
    }
Пример #9
0
    private bool Fire()
    {
        if (RaiseTimer > 0f)
        {
            return(false);
        }
        if (HolsterTimer > 0f)
        {
            return(false);
        }

        if (attackCooldownTimer <= 0f)
        {
            if (UsesAmmo >= 0)
            {
                if (character.ammunition[UsesAmmo] < AmmoUseAmount)
                {
                    Messaging.GUI.ScreenMessage.Invoke("OUT OF AMMO", Color.red);
                    Sounds.CreateSound(EmptySound);
                    attackCooldownTimer = .4f;
                    return(false);
                }

                character.ammunition[UsesAmmo] -= AmmoUseAmount;
            }

            attackCooldownTimer = attackCooldown;

            if (SprayPrefab != null)
            {
                Spray spray = Instantiate(SprayPrefab, LevelLoader.DynamicObjects);
                spray.owner              = character;
                spray.Damage             = SprayDamage;
                spray.damageType         = SprayDamageType;
                spray.LifeTime           = SprayLifeTime;
                spray.Force              = SprayForce;
                spray.Speed              = SpraySpeed;
                spray.BurnTotalDamage    = SprayTotalDamage;
                spray.DamagePerBurn      = DamagePerApplication;
                spray.RadiusOverLifetime = SprayRadius;

                //make a special raycasting move from character to barrel
                spray.transform.position = character.transform.position;
                spray.InitialMove((_weaponPrefab.transform.position + _weaponPrefab.transform.rotation * SprayPosition) - character.transform.position);

                if (AttackDirection == Vector2.zero)
                {
                    spray.transform.rotation = character.LookDirection;
                }
                else
                {
                    spray.transform.rotation = Quaternion.Euler(0, 0, Mathf.Atan2(AttackDirection.x, -AttackDirection.y) * Mathf.Rad2Deg);
                }

                //add spread
                float firstRoll  = Random.Range(-spread, spread);
                float secondRoll = Random.Range(-spread, spread);

                spray.transform.rotation *= Quaternion.Euler(0, 0, Mathf.Abs(firstRoll) < Mathf.Abs(secondRoll) ? firstRoll : secondRoll);

                //inherit speed
                spray.Speed += InheritSpeed * Vector2.Dot(character.physicsBody.velocity, character.LookDirection * Vector3.right);

                spray.GetComponent <SaveGameObject>().SpawnName = SprayDesignation;
            }
        }

        if (UsesAmmo >= 0 && character.ammunition[UsesAmmo] < AmmoUseAmount)
        {
            return(false);
        }

        OnFire.Invoke();

        return(true);
    }
Пример #10
0
    public override void Activate(MonsterCharacter character, int index)
    {
        //would result in illegal normalization, need a direction to dash into
        if (character.physicsBody.velocity == Vector2.zero)
        {
            return;
        }

        //need 65% of full power at minimum
        if (character.ChargePoints < (ChargeCost * .65f))
        {
            Sounds.CreateSound(FailSound);
            Messaging.GUI.ScreenMessage.Invoke("NOT ENOUGH CHARGE", Color.red);
            return;
        }

        if (character.SkillCooldowns[index] > 0)
        {
            Sounds.CreateSound(FailSound);
            return;
        }

        Sounds.CreateSound(ActivationSound);

        character.SkillCooldowns[index] = Cooldown;

        float strength = Strength;

        if (character.ChargePoints < ChargeCost)
        {
            strength *= (float)character.ChargePoints / ChargeCost;
            character.ChargePoints = 0;
        }
        else
        {
            character.ChargePoints -= ChargeCost;
        }

        DashSkill d = Instantiate(this, LevelLoader.DynamicObjects);

        d.Strength        = strength;
        d.direction       = character.physicsBody.velocity.normalized;
        d.targetCharacter = character;
        d.timer           = ActiveTime;

        if (AttachmentEffect != null)
        {
            foreach (string attachPoint in AttachmentPoints)
            {
                GameObject effect = Instantiate(AttachmentEffect);

                GenericTimer e = effect.AddComponent <GenericTimer>();
                e.LifeTime = ActiveTime * 5;
                e.OnTimer.AddListener(() =>
                {
                    TrailRenderer tr = effect.GetComponentInChildren <TrailRenderer>();
                    if (tr != null)
                    {
                        tr.emitting = false;
                    }
                });

                DestroyAfterTime t = effect.AddComponent <DestroyAfterTime>();
                t.LifeTime = ActiveTime * 10;

                effect.transform.SetParent(character.GetAttachmentPoint(attachPoint), false);
            }
        }
    }
Пример #11
0
    private bool Fire()
    {
        if (cooldownTimer > 0f)
        {
            return(false);
        }
        if (RaiseTimer > 0f)
        {
            return(false);
        }
        if (HolsterTimer > 0f)
        {
            return(false);
        }
        if (UsesAmmo >= 0)
        {
            if (character.ammunition[UsesAmmo] < AmmoUseAmount)
            {
                Messaging.GUI.ScreenMessage.Invoke("OUT OF AMMO", Color.red);
                Sounds.CreateSound(EmptySound);
                cooldownTimer = .4f;
                return(false);
            }

            character.ammunition[UsesAmmo] -= AmmoUseAmount;
        }

        cooldownTimer = attackCooldown;

        Sounds.CreateSound(FireSound, transform.position);

        if (MuzzlePrefab != null)
        {
            GameObject muzzle = Instantiate(MuzzlePrefab);

            if (swap)
            {
                //muzzle.transform.rotation = _weaponPrefab1.transform.rotation * Quaternion.Euler(MuzzleRotation);
                muzzle.transform.position = _weaponPrefab1.transform.position + _weaponPrefab2.transform.TransformDirection(MuzzlePosition);
                muzzle.transform.SetParent(_weaponPrefab1.transform);
                muzzle.transform.localRotation = Quaternion.Euler(MuzzleRotation);
            }
            else
            {
                //muzzle.transform.rotation = _weaponPrefab2.transform.rotation * Quaternion.Euler(MuzzleRotation);
                muzzle.transform.position = _weaponPrefab2.transform.position + _weaponPrefab2.transform.TransformDirection(MuzzlePosition);
                muzzle.transform.SetParent(_weaponPrefab2.transform);
                muzzle.transform.localRotation = Quaternion.Euler(MuzzleRotation);
            }
        }

        if (RocketPrefab != null)
        {
            Rocket rocket = Instantiate(RocketPrefab, LevelLoader.DynamicObjects);
            rocket.owner           = character;
            rocket.Damage          = RocketDamage;
            rocket.ArmDistance     = RocketArmDistance;
            rocket.ArmTimeRange    = RocketArmTimeRange;
            rocket.Force           = RocketForce;
            rocket.Speed           = RocketSpeed;
            rocket.Slowdown        = RocketSlowdown;
            rocket.ExplosionRadius = RocketExplosionRadius;
            rocket.LifeTime        = RocketLifeTime;
            rocket.damageType      = RocketDamageType;

            //make a special raycasting move from character to barrel
            rocket.transform.position = character.transform.position;

            if (swap)
            {
                rocket.InitialMove((_weaponPrefab1.transform.position + _weaponPrefab1.transform.rotation * RocketPosition) - character.transform.position);
            }
            else
            {
                rocket.InitialMove((_weaponPrefab2.transform.position + _weaponPrefab2.transform.rotation * RocketPosition) - character.transform.position);
            }

            if (AttackDirection == Vector2.zero)
            {
                rocket.transform.rotation = character.LookDirection;
            }
            else
            {
                rocket.transform.rotation = Quaternion.Euler(0, 0, Mathf.Atan2(AttackDirection.x, -AttackDirection.y) * Mathf.Rad2Deg);
            }

            //add spread
            float firstRoll  = Random.Range(-spread, spread);
            float secondRoll = Random.Range(-spread, spread);
            rocket.transform.rotation *= Quaternion.Euler(0, 0, Mathf.Abs(firstRoll) < Mathf.Abs(secondRoll) ? firstRoll : secondRoll);

            rocket.GetComponent <SaveGameObject>().SpawnName = RocketDesignation;
        }

        swap = !swap;

        OnFire.Invoke();

        return(true);
    }
Пример #12
0
    private void Move(Vector2 step)
    {
        if (step == Vector2.zero)
        {
            return;
        }

        Vector2 dir      = step.normalized;
        float   distance = step.magnitude;

        int count = Physics2D.RaycastNonAlloc(transform.position, dir, hits, distance, LayerMask.WallsWalkersAndShootables);

        Damageable target   = null;
        float      closest  = float.MaxValue;
        Vector2    hitpoint = Vector2.zero;

        for (int i = 0; i < count; i++)
        {
            RaycastHit2D hit = hits[i];

            Damageable dmg = hit.collider.GetComponentInParent <Damageable>();
            if (owner != null && dmg != null)
            {
                if (owner.gameObject == hit.collider.gameObject)
                {
                    continue;
                }

                if (owner.Faction != Factions.AgainstAll)
                {
                    if (owner.Faction == dmg.Faction)
                    {
                        continue;
                    }
                }
            }

            float d = hit.distance;
            if (d < closest)
            {
                hitpoint = hit.point;
                closest  = d;
                target   = dmg;
            }
        }

        if (closest == float.MaxValue)
        {
            transform.position += (Vector3)step;
        }
        else
        {
            transform.position = hitpoint;
            PendingForDeletion = true;

            if (OnHitObject != null)
            {
                GameObject onHitObject = Instantiate(OnHitObject, LevelLoader.TemporaryObjects);
                onHitObject.transform.position = transform.position;
                onHitObject.transform.rotation = transform.rotation;
            }

            if (target != null)
            {
                if (!target.HitSound(hitpoint, AttackType.Bullet))
                {
                    Sounds.CreateSound(DefaultHitSound, hitpoint);
                }

                target.Damage(new DamageFrame(Damage, AttackType.Bullet, damageType, owner, hitpoint));

                if (BurnTotalDamage > 0)
                {
                    target.Dot(new DotFrame(BurnTotalDamage, DamagePerBurn, DamageType.Fire, owner));
                }

                target.Impulse(dir, Force);
            }
            else
            {
                Sounds.CreateSound(DefaultHitSound, hitpoint);
            }
        }

        travelled += distance;
        if (travelled >= Options.MaxAttackDistance)
        {
            PendingForDeletion = true;
        }
    }