コード例 #1
0
    /// <summary>
    /// <inheritdoc />
    /// </summary>
    /// <returns></returns>
    public override IEnumerable <GameObject> GetLootItems()
    {
        int target = Value.PickInt();
        int sum    = 0;

        //Sorts the currencies by their value so that higher denominations are prioritized
        var currenciesByValue = Currencies.OrderByDescending(i => i.GetComponentInChildren <CurrencyPickup>().Value);

        //Keep yielding pickups until we've reached our sum
        while (sum < target)
        {
            //Browse the currency items
            foreach (var i in currenciesByValue)
            {
                CurrencyPickup iCurrency = i.GetComponentInChildren <CurrencyPickup>();

                //If the current currency object's value does not exceed the remaining value to yield, then yield it
                if (sum + iCurrency.Value <= target)
                {
                    sum += iCurrency.Value;
                    yield return(i.gameObject);

                    break;
                }
            }
        }
    }
コード例 #2
0
    /// <summary>
    /// Makes the object jump around randomly
    /// </summary>
    private void FumbleAround()
    {
        //all decisions are made while grounded. Return if not.
        if (!grounded)
        {
            return;
        }

        //if the enemy has waited enough
        if (_groundTimeLeft <= 0f)
        {
            if (_fumbleJumpsLeft > 0)
            {
                //jump the direction the enemy is facing
                JumpToSign(Enemy.Flippable.DirectionSign);
            }
            else
            {
                //resets all counters
                _groundTimeLeft  = Commons.GetEffectValue(GroundTime.Pick(), EffectValueType.EnemyWaitTime);
                _fumbleJumpsLeft = FumbleJumps.PickInt() + 1;
                _flipTime        = _groundTimeLeft / 2;
            }
        }
        //wait more
        else
        {
            _groundTimeLeft -= Time.deltaTime;

            //halfway through the waiting: 50/50 chance of changing direction
            if (_groundTimeLeft < _flipTime)
            {
                if (Random.Range(0, 2) == 0)
                {
                    Enemy.Flippable.Flip();
                }

                _flipTime = -5;
            }
        }
    }
コード例 #3
0
    protected override void OnFire(WeaponInstance instance, WeaponShooterBase shooter, Vector2 direction)
    {
        for (int i = 0; i < BlastCount; i++)
        {
            Projectile newAmmo = Instantiate(
                original: Ammunition,
                position: shooter.GetProjectilesSpawnPoint(),
                rotation: Quaternion.identity
                );

            //Rotates the bullet random amount
            RandomValueBetween randomAngle = new RandomValueBetween(-MaxAngle / 2, MaxAngle / 2);
            int angle = randomAngle.PickInt();
            newAmmo.Direction = direction;
            newAmmo.transform.Rotate(angle);

            WeaponFireHurtbox hurtbox = newAmmo.GetComponentInChildren <WeaponFireHurtbox>();
            hurtbox.Shooter = shooter;
            hurtbox.Weapon  = instance;
        }
    }
コード例 #4
0
 /// <summary>
 /// Creates an explosion with at particle count determined by the SmallDropParticleCount field
 /// </summary>
 public void ExplodeSmall()
 {
     Explode(SmallDropParticleCount.PickInt());
 }
コード例 #5
0
 /// <summary>
 /// Creates an explosion with at particle count determined by the ParticleCount field
 /// </summary>
 public void ExplodeBig()
 {
     Explode(ParticleCount.PickInt());
 }