Ejemplo n.º 1
0
        public void TakeDamageFrom(IBullet bullet)
        {
            var newActual = HitPoints.Actual - bullet.Damage;

            newActual = Math.Max(newActual, 0);
            HitPoints = new Value(HitPoints.Maximum, newActual);
            Regeneration.ResetActiveIn();
            OnDamaged(bullet);

            OnChanged();
            if (HitPoints.Actual <= 0)
            {
                Die(bullet.Shooter);
            }
        }
Ejemplo n.º 2
0
        public override async Task UpdateAsync()
        {
            await base.UpdateAsync();

            if (IsDead)
            {
                myRespawnIn -= DeltaTime;
                OnChanged();
                if (myRespawnIn < TimeSpan.Zero)
                {
                    Respawn();
                }

                return;
            }

            await myWeapon.UpdateAsync();

            try
            {
                Regeneration.Update();
                if (IsAiming)
                {
                    Aim();
                    return;
                }
                var turnAction = GetTurnAction();
                if (turnAction != null)
                {
                    switch (turnAction)
                    {
                    case ShootAtTurnAction shoot:
                        Execute(shoot);
                        break;

                    case MoveTowardsTurnAction moveTowards:
                        Execute(moveTowards);
                        break;

                    case MoveAwayFromTurnAction moveAway:
                        Execute(moveAway);
                        break;

                    case PickUpResourceTurnAction pickUpResource:
                        Execute(pickUpResource);
                        break;

                    case DropDownResourceTurnAction dropDownResource:
                        Execute(dropDownResource);
                        break;

                    case PickUpWeaponTurnAction pickUpAmmo:
                        Execute(pickUpAmmo);
                        break;

                    case EquipWeaponTurnAction equipWeapon:
                        Execute(equipWeapon);
                        break;

                    case PickUpFirstAidKitTurnAction pickUpFirstAidKit:
                        Execute(pickUpFirstAidKit);
                        break;
                    }
                }
            }
            catch
            {
                // ignored
            }
        }
Ejemplo n.º 3
0
 private void PickUpFirstAidKit(FirstAidKit firstAidKit)
 {
     Regeneration.Regenerate(firstAidKit.RegenerationAmount);
     Battlefield.Remove(firstAidKit);
 }
Ejemplo n.º 4
0
 public Bot([NotNull] Battlefield battlefield, BotAI botAI) : base(battlefield)
 {
     Regeneration = new Regeneration(this);
     Init(battlefield, botAI);
 }