private void Awake() { _partOfWave = GetComponentInParent <IEnemyWave>(); _mySprite = GetComponentInChildren <SpriteRenderer>(); _collider2D = GetComponentInChildren <Collider2D>(); _poolingAgent = _poolingAgent.SetUpPoolingAgent(GetComponents <PoolingAgent>(), PoolingID.FX); }
public override void Update(UpdateContext context, IEnemyWave wave) { base.Update(context, wave); var result = GetEnemyMostNearTheEndAndInTrackingRange(Center, wave.Sets, Settings.TrackingRange, Settings.FiringRange); if (result.HasValue) { (var enemy, bool inFiringRange) = result.Value; var angle = Path.GetAngleBetweenVectors(Center, enemy.Center); Rotation = MathOps.CalculateRotation(angle, Rotation, MathOps.CalculateMaxRotation(context.GameTime.ElapsedGameTime, Settings.RotationalSpeed)); switch (FiringState) { case FiringState.Idle: if (Math.Abs(MathOps.CalculateMinAngleDifference(Rotation, angle)) < 0.1) { TransitionToFiring(); enemy.Hit(Settings.Power); FireColorTransition.Start(Color.Red, Color.White, context.GameTime.TotalGameTime, TimeToNextFiringState); } break; case FiringState.Firing: FireColorTransition.Update(context.GameTime.TotalGameTime); break; } } }
public void IfCurrentWaveStatusIsDoneAndThereIsNoNextWave_NewStatusIsFinishingAndNextWaveIsFalse() { var currentWave = Substitute.For <IEnemyWave>(); currentWave.Status.Returns(EnemyWaveStatus.Done); var waves = new IEnemyWave[] { currentWave }; var actual = BattleScene.UpdateEnemyWaves(new UpdateContext(), currentWaveIndex: 0, currentWave, waves); Assert.That(actual.NewStatus, Is.EqualTo(BattleSceneStatus.Finishing)); Assert.That(actual.IsNextWave, Is.False); }
public void IfCurrentWaveStatusIsNotDone_NewStatusIsNullAndNextWaveIsFalse() { var currentWave = Substitute.For <IEnemyWave>(); currentWave.Status.Returns(EnemyWaveStatus.Spawning); var nextWave = Substitute.For <IEnemyWave>(); nextWave.Status.Returns(EnemyWaveStatus.Ready); var waves = new IEnemyWave[] { currentWave, nextWave }; var actual = BattleScene.UpdateEnemyWaves(new UpdateContext(), currentWaveIndex: 0, currentWave, waves); Assert.That(actual.NewStatus.HasValue, Is.False); Assert.That(actual.IsNextWave, Is.False); }
public virtual void Update(UpdateContext context, IEnemyWave waves) { switch (FiringState) { case FiringState.Reloading: TimeToNextFiringState -= context.GameTime.ElapsedGameTime; if (TimeToNextFiringState < TimeSpan.Zero) { TransitionToIdle(); } break; case FiringState.Firing: TimeToNextFiringState -= context.GameTime.ElapsedGameTime; if (TimeToNextFiringState < TimeSpan.Zero) { TransitionToReloading(); } break; } base.Update(context); }
public static (BattleSceneStatus?NewStatus, bool IsNextWave) UpdateEnemyWaves( UpdateContext childContext, int currentWaveIndex, IEnemyWave currentEnemyWave, IEnemyWave[] enemyWaves) { var result = (NewStatus : (BattleSceneStatus?)null, IsNextWave : false); foreach (var wave in enemyWaves) { wave.Update(childContext); } if (currentEnemyWave.Status == EnemyWaveStatus.Done) { if (currentWaveIndex < enemyWaves.Length - 1) { result.IsNextWave = true; } else { result.NewStatus = BattleSceneStatus.Finishing; } } return(result); }
public void Update(UpdateContext context, IEnemyWave enemyWave) { UpdateMouseHover(context); Weapon?.Update(context, enemyWave); base.Update(context); }
private void Start() { _partofWave = GetComponent <IEnemyWave>(); }
public override void Update(UpdateContext context, IEnemyWave waves) { base.Update(context, waves); }
/// <summary> /// Updates weapon pods and returns a clicked weapon pod if any. /// Caller is responsible for process click - i.e. create <see cref="WeaponPickerDialog"/>. /// </summary> /// <param name="childContext"></param> /// <param name="weaponPods"></param> /// <param name="currentEnemyWave"></param> /// <param name="canEntityClick"></param> /// <returns></returns> public static IWeaponPod UpdateWeaponPods(UpdateContext childContext, IWeaponPod[] weaponPods, IEnemyWave currentEnemyWave, bool canEntityClick) { IWeaponPod clickedWeaponPod = null; // converts mouse coordinates to absolute to scene foreach (var wp in weaponPods) { wp.Update(childContext, currentEnemyWave); // disable upgrades for now if (canEntityClick && wp.ClickState == ClickState.Clicked && wp.Weapon is null) { logger.Info($"Weapon pod {Array.IndexOf(weaponPods, wp)} was clicked"); clickedWeaponPod = wp; } } return(clickedWeaponPod); }