internal void Initialize(IAssetDispenser assetDispenser) { this.assetDispenser = assetDispenser; if (inputReader == null) { inputReader = new InputReader(sessionCam.ScreenToWorldPoint); } if (boundsChecker == null) { boundsChecker = new ScreenBounds(sessionCam.ScreenToWorldPoint); } if (!sessionSpaceTransfrom) { sessionSpaceTransfrom = GetComponent <Transform>(); } if (!station) { var stationPrefab = assetDispenser.GetSpaceStationPrefab(); station = GameObject.Instantiate(stationPrefab, Vector3.zero, Quaternion.identity, sessionSpaceTransfrom); station.Killed += OnStationKilled; station.Initialize(assetDispenser, inputReader, boundsChecker, sessionEvents); } if (enemySpawner == null) { enemySpawner = new EnemySpawner(assetDispenser, boundsChecker, sessionEvents); } }
void OnTriggerEnter2D(Collider2D collider) { PickupableObject pickupableObject = collider.GetComponent <PickupableObject>(); if (pickupableObject && pickupableObject.CanBePickedUp()) { pickupableObject.PickUp(gameObject); PowerUpController powerUp = collider.GetComponent <PowerUpController>(); if (powerUp) { ModifyFactor(powerUp.Amount, powerUp.Type); } else { PilotController pilot = collider.GetComponent <PilotController>(); if (pilot) { UpdateSpecialAttackTimer(MaxSpecialAttackTimer); WorldController.PilotPickedUp(pilot); } } } else { SpaceStationController SpaceStation = collider.GetComponent <SpaceStationController>(); if (SpaceStation) { CanBeControlled = false; DesiredRotation = 0f; DesiredMovement = 0f; Shoot = false; ExecuteSpecialAttack = false; Rigidbody.velocity = Vector2.zero; TailParticleSystem.Stop(); RightParticleSystem.Stop(); LeftParticleSystem.Stop(); Vector2 spaceStationPosition = WorldController.SpaceStationReached(); DOTween.Sequence() .Join(transform.DOMove(spaceStationPosition, 1f).SetEase(Ease.OutQuad)) .Join(transform.DOScale(transform.localScale * 0.2f, 1f)) .OnComplete(() => { Destroy(gameObject); }); } } }