private void Walk(BaseEnemy enemy, BaseVerticalShooter.GameModel.IBaseMap gameMap, TimeSpan t) { var candidateWindowPosition = enemy.OnWindowPosition + enemy.Direction * (float)t.TotalSeconds * enemy.PixelsPerSec; var mapCollisionType = enemy.CheckMapCollision(gameMap, candidateWindowPosition); if (mapCollisionType != CollisionType.Blocked) { enemy.OnWindowPosition = candidateWindowPosition; } else { Vector2 newDirection = enemy.Direction; newDirection = GetDirectionAfterCollision(enemy); enemy.Direction = newDirection; } }
public Action <TimeSpan, IBasePlayer> GetTimedAction(BaseEnemy enemy, IBasePlayer player, BaseVerticalShooter.GameModel.IBaseMap gameMap) { var action = new Action <TimeSpan, IBasePlayer>((t, p) => { if (enemy.State == CharacterState.Alive) { if (accumulatedTime > Milestones.Last().End) { accumulatedTime = TimeSpan.FromSeconds(0); } var milestone = GetCurrentMilestone(); this.RoutineType = milestone.RoutineType; var milestoneExists = (milestone.Start != milestone.End); if (milestoneExists && milestone.RoutineType == RoutineType.Walk) { Walk(enemy, gameMap, t); } accumulatedTime = accumulatedTime.Add(t); enemy.CheckReload(); } }); return(action); }