Esempio n. 1
0
        public Task HandleAsync(DestroyedEvent @event, CancellationToken cancellationToken = new CancellationToken())
        {
            switch (@event.Type)
            {
            case UnitType.TankHeavy:
                _counts[@event.Player].HeavyTankCount--;
                break;

            case UnitType.TankLight:
                _counts[@event.Player].LightTankCount--;
                break;

            case UnitType.PlaneBomber:
                _counts[@event.Player].BomberCount--;
                break;

            case UnitType.PlaneFighter:
                _counts[@event.Player].FighterPlaneCount--;
                break;

            case UnitType.Infantry:
                _counts[@event.Player].SoldierCount--;
                break;
            }

            if (GameIsOver())
            {
                var winner = _counts.Single(m => !m.Value.NoPieces).Key;
                _commandDelegator.SendAsync(new EndGameCommand(_currentMatchId, winner));
            }
            return(Task.CompletedTask);
        }
Esempio n. 2
0
 public void Damage(float damage)
 {
     Health -= damage;
     if (Health <= 0)
     {
         Health = 0.0f;
         DestroyedEvent?.Invoke();
     }
 }
Esempio n. 3
0
    private void OnDeath(Player damager)
    {
        Camera.PlayerKiller = damager.transform;

        if (DestroyedEvent != null)
        {
            DestroyedEvent.Invoke(m_PlayerIndex, damager);
        }

        DestroyedEvent = null;

        ExplodeTank();
        Destroy(gameObject);
    }
Esempio n. 4
0
 private void OnDestroyedEvent(DestroyedEvent devent)
 {
     Units.Remove(devent.UnitId);
 }
Esempio n. 5
0
 private void OnDestroy()
 {
     buildingsList.Items.Remove(gameObject);
     DestroyedEvent?.Invoke();
 }
 public async Task HandleAsync(DestroyedEvent @event, CancellationToken cancellationToken = new CancellationToken())
 {
     await _repo.RemoveUnit(@event.AggregateRootId, @event.Type, @event.Player, cancellationToken);
 }