void Awake() { CollisionBus.Subscribe(CollisionBus.Timing.Enter, TagName.Enemy, TagName.Ball, (enemy, ball, collision) => { var killable = enemy.GetComponent <Killable>(); killable.TakeDamage(_ballDamage); }); CollisionBus.Subscribe(CollisionBus.Timing.Enter, TagName.Wall, TagName.Ball, (wall, ball, collision) => { GlobalAudioSource.PlayOneShot(_wallHitSE); }); CollisionBus.Subscribe(CollisionBus.Timing.Enter, TagName.Player, TagName.Ball, (player, ball, collision) => { GlobalAudioSource.PlayOneShot(_barHitSE); }); CollisionBus.Subscribe(CollisionBus.Timing.Enter, TagName.PlayerBullet, TagName.Ball, (bullet, ball, collision) => { GlobalAudioSource.PlayOneShot(_barHitSE); var vfx = ObjectPool.Alloc(_bulletHitVFX); vfx.transform.position = bullet.transform.position; ObjectPool.Free(vfx, 1f); ObjectPool.Free(bullet); }); CollisionBus.Subscribe(CollisionBus.Timing.Enter, TagName.PlayerBullet, TagName.Enemy, (bullet, enemy, collision) => { var killable = enemy.GetComponent <Killable>(); killable.TakeDamage(_bulletDamage); GlobalAudioSource.PlayOneShot(_bulletHitSE); var vfx = ObjectPool.Alloc(_bulletHitVFX); vfx.transform.position = bullet.transform.position; ObjectPool.Free(vfx, 1f); ObjectPool.Free(bullet); }); CollisionBus.Subscribe(CollisionBus.Timing.Enter, TagName.LaserFence, TagName.Ball, (fence, ball, collision) => { var vfx = ObjectPool.Alloc(_ballDieVFX); vfx.transform.position = ball.transform.position; ObjectPool.Free(vfx, 1f); ObjectPool.Free(ball); GlobalAudioSource.PlayOneShot(_ballDieSE); Observable.Timer(System.TimeSpan.FromSeconds(1f)).Subscribe(_ => { var newBall = ObjectPool.Alloc(_ball); var spawnVFX = ObjectPool.Alloc(_ballSpawnVFX); newBall.transform.position = Vector2.zero; spawnVFX.transform.position = newBall.transform.position; ObjectPool.Free(spawnVFX, 1f); }); Camera.main.transform.DOComplete(); Camera.main.transform.DOShakePosition(0.5f, 0.3f); }); }
void ResultUpdate() { if (MyInput.cursorUp || MyInput.cursorDown) { _isSelectedExit = !_isSelectedExit; _replaySelector.SetActive(!_isSelectedExit); _exitSelector.SetActive(_isSelectedExit); } if (MyInput.ok) { if (_isSelectedExit) { onResultSceneEnd(); Application.Quit(); } else { MyInput.locked = true; GlobalAudioSource.PlayOneShot(_okSE); Caller.Timer(1f).Subscribe(_ => { MyInput.locked = false; _sceneState = SceneState.Play; onResultSceneEnd(); onPlaySceneStart(); }); } } }
//! ----functions---- void Awake() { CollisionBus.Subscribe(new CollisionBus.Combo(TagName.Ball, TagName.Wall), (ball, wall, collision) => { TF.ObjectPool.Alloc(_vfx, 1f, collision.contacts[0].point); GlobalAudioSource.PlayOneShot(_se); }); }
//! ----functions---- void Awake() { CollisionBus.Subscribe(new CollisionBus.Combo(TagName.PlayerMissile, TagName.Wall), (missile, wall, collision) => { var missileCore = missile.GetComponent <Missiles.MissileCore>(); TF.ObjectPool.Alloc(_vfx, 1f, collision.contacts[0].point); GlobalAudioSource.PlayOneShot(_se); missileCore.Kill(); }); }
void Awake() { LifeCycleBus.Subscribe(TagName.Enemy, enemy => { var exp = ObjectPool.Alloc(_explosionVFX); exp.transform.position = enemy.transform.position; ObjectPool.Free(exp, 1f); GlobalAudioSource.PlayOneShot(_explosionSE); ScoreManager.AddScore(_scoreByEnemy); }); }
public static void Emit(string name) { var formation = _self._formations.FirstOrDefault(item => item.name == name); if (formation == null) { Debug.LogWarningFormat("Formation not found:name->{0}", name); return; } int cnt = 0; List <Enemies.EnemyMover> movers = new List <Enemies.EnemyMover>(); foreach (var info in formation.infos) { var disposer = Observable.Timer(TimeSpan.FromSeconds(cnt * _self._delay)).Subscribe(_ => { var enemy = ObjectPool.Alloc(info.prefab); enemy.transform.position = info.position; var mover = enemy.GetComponent <Enemies.EnemyMover>(); mover.locked = true; movers.Add(mover); ObjectPool.Alloc(_self._emitVFX, 1f, info.position); GlobalAudioSource.PlayOneShot(_self._emitSE); var core = enemy.GetComponent <EnemyCore>(); _arriveEnemies.Add(core); core.onReleased += () => { _arriveEnemies.Remove(core); if (arrives == 0) { onExtinctioned(); } }; }).AddTo(_self.gameObject); _disposers.Add(disposer); cnt++; } var d = Observable.Timer(TimeSpan.FromSeconds(formation.infos.Count * _self._delay + _self._delay)) .Subscribe(_ => { foreach (var mover in movers) { mover.locked = false; } }).AddTo(_self.gameObject); _disposers.Add(d); }
//! ----functions---- void Awake() { CollisionBus.Subscribe(TagName.Ball, TagName.LaserFence, (ball, laserFence, collision) => { var ballCore = ball.GetComponent <Balls.BallCore>(); TF.ObjectPool.Alloc(_vfx, 1f, ball.transform.position); GlobalAudioSource.PlayOneShot(_se); ballCore.Kill(); }); }
//! ----functions---- void Awake() { CollisionBus.Subscribe(TagName.Ball, TagName.Enemy, (ball, enemy, collision) => { var ballCore = ball.GetComponent <Balls.BallCore>(); var enemyCore = enemy.GetComponent <Enemies.EnemyCore>(); TF.ObjectPool.Alloc(_hitVFX, 1f, collision.contacts[0].point); GlobalAudioSource.PlayOneShot(_hitSE); enemyCore.ApplyDamage(ballCore.damage); }); }
//! ----functions---- void Awake() { CollisionBus.Subscribe(new CollisionBus.Combo(TagName.PlayerMissile, TagName.Enemy), (missile, enemy, collision) => { TF.ObjectPool.Alloc(_vfx, 1f, missile.transform.position); GlobalAudioSource.PlayOneShot(_se); var missileCore = missile.GetComponent <Missiles.MissileCore>(); var enemyCore = enemy.GetComponent <Enemies.EnemyCore>(); enemyCore.ApplyDamage(missileCore.damage); missileCore.Kill(); }); }
//! ----functions---- void TitleUpdate() { if (MyInput.anyKeyDown) { MyInput.locked = true; GlobalAudioSource.PlayOneShot(_okSE); Caller.Timer(1f).Subscribe(_ => { MyInput.locked = false; onTitleSceneEnd(); onPlaySceneStart(); }); } }
void Update() { if (Input.GetKeyDown(KeyCode.Z)) { for (int f1 = 0; f1 < 4; f1++) { var missile = ObjectPool.Alloc(_sourceMissile); missile.transform.position = transform.position; GlobalAudioSource.PlayOneShot(_missileSE); } } Move(); Shot(); }
//! ----functions---- void OnCollisionEnter2D(Collision2D collision) { var tag = collision.gameObject.GetEnumTagName(); if (tag == TagName.LaserFence) { Kill(); } if (tag == TagName.Player) { var player = collision.gameObject.GetComponent <Players.PlayerCore>(); player.ApplyDamage(damage); GlobalAudioSource.PlayOneShot(_hitSE); Kill(); } }
//! ----functions---- public override void Initialize() { base.Initialize(); fireController.onShot += () => { GlobalAudioSource.PlayOneShot(_fireSE); }; missileController.onShot += () => { GlobalAudioSource.PlayOneShot(_missileSE); }; core.onDead += () => { GlobalAudioSource.PlayOneShot(_deadSE); }; }
//! --------functions-------- public void Emit(string name) { var formation = _formations.FirstOrDefault(item => item.name == name); if (formation == null) { Debug.LogWarningFormat("Formation not found:name->{0}", name); return; } int cnt = 0; //移動ロック用 List <InvaderStepper> steppers = new List <InvaderStepper>(); foreach (var info in formation.infos) { Observable.Timer(TimeSpan.FromSeconds(cnt * _delay)).Subscribe(_ => { var enemy = ObjectPool.Alloc(info.prefab); enemy.transform.position = info.position; var stepper = enemy.GetComponent <InvaderStepper>(); stepper.locked = true; steppers.Add(stepper); var vfx = ObjectPool.Alloc(_emitVFX); vfx.transform.position = info.position; ObjectPool.Free(vfx, 1f); GlobalAudioSource.PlayOneShot(_emitSE); }).AddTo(gameObject); cnt++; } //Debug.LogFormat("emitted {0} enemies", cnt); //全てエミットされたらロック解除 Observable.Timer(TimeSpan.FromSeconds(formation.infos.Count * _delay + _delay)).Subscribe(_ => { // Debug.Log("unlocked"); foreach (var stepper in steppers) { stepper.locked = false; } }).AddTo(gameObject); }
//! ----life cycles---- void Awake() { Collisions.CollisionBus.Subscribe( new CollisionBus.Combo(TagName.PlayerBullet, TagName.Wall), (bullet, wall, collision) => { var core = bullet.GetComponent <PlayerBullets.PlayerBulletCore>(); var effect = TF.ObjectPool.Alloc(_effect); TF.ObjectPool.Free(effect, 1f); if (collision.contacts.Length != 0) { effect.transform.position = collision.contacts[0].point; } GlobalAudioSource.PlayOneShot(_hitSE); core.Kill(); }); }
//! ----functions---- GameObject SpawnBall() { var ball = ObjectPool.Alloc(_ballSource); ball.transform.position = _spawnPos; ObjectPool.Alloc(_spawnVFX, 1f, _spawnPos); GlobalAudioSource.PlayOneShot(_spawnSE); var ballCore = ball.GetComponent <BallCore>(); ballCore.onKilled += () => { _disposer = Observable.Timer(System.TimeSpan.FromSeconds(_spawnDelay)).Subscribe(_ => { _ball = SpawnBall(); }).AddTo(ballCore.gameObject); }; ball.GetComponent <Rigidbody2D>().AddForce(Vector2.up); return(ball); }
//! ----life cycles---- void Awake() { Collisions.CollisionBus.Subscribe( new CollisionBus.Combo(TagName.PlayerBullet, TagName.Enemy), (playerBullet, enemy, collision) => { var enemyCore = enemy.GetComponent <Enemies.EnemyCore>(); var playerBulletCore = playerBullet.GetComponent <PlayerBullets.PlayerBulletCore>(); enemyCore.ApplyDamage(playerBulletCore.damage); var effect = TF.ObjectPool.Alloc(_effect); if (collision.contacts.Length != 0) { effect.transform.position = collision.contacts[0].point; } TF.ObjectPool.Free(effect, 1f); GlobalAudioSource.PlayOneShot(_hitSE); playerBulletCore.Kill(); }); }
private void Attacker_onHitted(Collision2D collision) { GlobalAudioSource.PlayOneShot(_hitSE); }
private void Core_onDead() { GlobalAudioSource.PlayOneShot(_deadSE); }