Пример #1
0
    private void begin()
    {
        TimedCallbacks callbacks = this.GetComponent <TimedCallbacks>();

        callbacks.AddCallback(this, this.SpawnPlayers, this.SpawnPlayersDelay);
        callbacks.AddCallback(this, this.SpawnEnemies, this.SpawnEnemiesDelay);
    }
Пример #2
0
    public void BeginSpawn()
    {
        if (this.ChildSpawners == null || this.ChildSpawners.Count == 0)
        {
            _spawnPosition = this.transform.position;
            _spawning      = true;

            if (this.SpawnVisualPrefab != null)
            {
                Instantiate(this.SpawnVisualPrefab, this.transform.position, Quaternion.identity);
            }

            TimedCallbacks callbacks = this.GetComponent <TimedCallbacks>();
            if (callbacks != null)
            {
                callbacks.AddCallback(this, this.Spawn, this.SpawnDelay);
            }
            else
            {
                Spawn();
            }
        }
        else
        {
            _cooldownTimer = this.SpawnCooldown;

            for (int i = 0; i < this.ChildSpawners.Count; ++i)
            {
                if (this.ChildSpawners[i] != null)
                {
                    this.ChildSpawners[i].BeginSpawn();
                }
            }

            if (this.DestroyAfterSpawn)
            {
                Destroy(this.gameObject);
            }
        }
    }
Пример #3
0
    void Start()
    {
        _currentAngle      = this.EnemyType.RotationOffset;
        _rotationAxis      = new Vector3(0, 0, 1);
        _weapon            = this.GetComponent <Weapon>();
        _rotationDirection = this.PossibleRotationDirections[Random.Range(0, this.PossibleRotationDirections.Length)];

        switch (this.EnemyType.MovementType)
        {
        default:
        case (int)MovementType.Free:
            _movementFunction = freeMovement;
            break;

        case (int)MovementType.Seek:
            _movementFunction = seekMovement;
            break;

        case (int)MovementType.MoveToward:
            _movementFunction = moveTowardMovement;
            break;
        }

        _actor = this.GetComponent <Actor2D>();
        if (_actor != null && this.EnemyType.MaxSpeed > 0.0f)
        {
            _actor.Velocity    = this.PossibleStartingVelocities.Length > 0 ? this.PossibleStartingVelocities[Random.Range(0, this.PossibleStartingVelocities.Length)] : Vector2.zero;
            _rotationDirection = this.PossibleRotationDirections[Random.Range(0, this.PossibleRotationDirections.Length)];
            this.localNotifier.Listen(CollisionEvent.NAME, this, this.OnCollide);
        }

        if (!this.UseDebugWeapon && this.WeaponType != null && _weapon != null)
        {
            _weapon.WeaponType = this.WeaponType;
        }

        Damager damager = this.GetComponent <Damager>();

        if (damager != null)
        {
            damager.Damage    = this.CollisionWeaponType.Damage;
            damager.Knockback = this.CollisionWeaponType.Knockback;
            damager.HitInvincibilityDuration = this.CollisionWeaponType.HitInvincibilityDuration;
        }

        Damagable damagable = this.GetComponent <Damagable>();

        if (damagable != null)
        {
            damagable.Health   = this.EnemyType.Health;
            damagable.Friction = this.EnemyType.Friction;

            if (this.CollisionWeaponType != null && this.CollisionWeaponType.SpecialEffect == WeaponType.SPECIAL_EXPLOSION)
            {
                damagable.OnDeathCallbacks.Add(onDeath);
            }
        }

        this.spriteRenderer.sprite = this.SpriteSheet.GetSprites()[this.EnemyType.SpriteName];
        GlobalEvents.Notifier.Listen(PlayerDiedEvent.NAME, this, playerDied);

        if (this.NoFire == false)
        {
            this.NoFire = true;
            TimedCallbacks callbacks = this.GetComponent <TimedCallbacks>();
            if (callbacks != null)
            {
                callbacks.AddCallback(this, fireOn, this.FireDelay);
            }
        }
    }