コード例 #1
0
ファイル: TowerModel.cs プロジェクト: porohkun/DexterDefence
 private void TowerAI_BulletShoot(BulletModel bullet)
 {
     if (BulletShoot != null)
     {
         BulletShoot(bullet);
     }
 }
コード例 #2
0
ファイル: MapModel.cs プロジェクト: porohkun/DexterDefence
 private void Tower_BulletShoot(BulletModel bullet)
 {
     _bullets.Add(bullet);
     bullet.Hitted += Bullet_Hitted;
     if (BulletCreated != null)
     {
         BulletCreated(bullet);
     }
 }
コード例 #3
0
 private void Bullet_Hitted(BulletModel bullet, UnitModel unit)
 {
     if (_bulletViews.ContainsKey(bullet))
     {
         var bulletView = _bulletViews[bullet];
         bulletView.Stop();
         Destroy(bulletView.gameObject, bulletView.DestroyDelay);
         _bulletViews.Remove(bullet);
     }
 }
コード例 #4
0
 private void CreateBullet(BulletModel bullet)
 {
     foreach (var bulletPrefab in _bulletViewPrefabs)
     {
         if (bulletPrefab.name == bullet.Visual)
         {
             var bulletView = Instantiate(bulletPrefab, _bulletsRoot);
             bullet.Hitted += Bullet_Hitted;
             bulletView.AttachTo(bullet);
             _bulletViews.Add(bullet, bulletView);
             break;
         }
     }
 }
コード例 #5
0
 protected override void _bullet_Hitted(BulletModel bullet, UnitModel _)
 {
     foreach (var unit in _getUnits().ToArray())
     {
         if (unit.Position.x >= bullet.Position.x - _explosionRadius && unit.Position.x <= bullet.Position.x + _explosionRadius &&
             unit.Position.y >= bullet.Position.y - _explosionRadius && unit.Position.y <= bullet.Position.y + _explosionRadius)
         {
             if (unit.Position.DistanceTo(bullet.Position) < _explosionRadius)
             {
                 unit.Health -= _damage;
             }
         }
     }
 }
コード例 #6
0
 private void Map_BulletCreated(BulletModel bullet)
 {
     CreateBullet(bullet);
 }
コード例 #7
0
ファイル: LaserShotAI.cs プロジェクト: porohkun/DexterDefence
 protected override void _bullet_Hitted(BulletModel bullet, UnitModel unit)
 {
 }
コード例 #8
0
ファイル: MapModel.cs プロジェクト: porohkun/DexterDefence
 private void Bullet_Hitted(BulletModel bullet, UnitModel unit)
 {
     _bullets.Remove(bullet);
 }
コード例 #9
0
 protected virtual void Shot()
 {
     _bullet         = new BulletModel(_bulletVisual, _position, _target, _bulletSpeed);
     _bullet.Hitted += _bullet_Hitted;
     OnBulletShoot();
 }
コード例 #10
0
 protected virtual void _bullet_Hitted(BulletModel bullet, UnitModel unit)
 {
     unit.Health -= _damage;
 }