public void ZieleErfassen() { var andereSchiffspositionen = Fields.Cast <Schiffsposition>().Where(s => s.Opacity == 1.0).ToLookup(s => s.AllowedOccupantId); foreach (Schiffsposition schiffsposition in Fields) { schiffsposition.tokens.Canvas.Children.Clear(); foreach (var zielerfassung in schiffsposition.ViewModel.Tokens.Zielerfassungen) { if (andereSchiffspositionen[zielerfassung].Any()) { var ziel = andereSchiffspositionen[zielerfassung].First(); var entfernungsVektor = ziel.Position.AsVector() - schiffsposition.Position.AsVector(); var entfernungsUndRichtungsVektor = entfernungsVektor.Rotate(-schiffsposition.OrientationAngle); var zielerfassungsVektor = entfernungsUndRichtungsVektor.Enlarge(-61); var zielerfassungslinie = new ArrowLine { X1 = 43, Y1 = 43, X2 = zielerfassungsVektor.X + 43, Y2 = zielerfassungsVektor.Y + 43, Stroke = schiffsposition.ViewModel.Color, StrokeThickness = 1 }; schiffsposition.tokens.Canvas.Children.Add(zielerfassungslinie); } } } }
public IList <GoalField> GetNotOccupiedGoalFields(TeamColour teamColour) { var possibleFields = Fields.Cast <Field>().Where(f => f is GoalField); var possibleGoalFields = possibleFields.Cast <GoalField>().Where(f => f.Team == teamColour && f.Type == GoalFieldType.goal); return(possibleGoalFields.ToList()); }
public IEnumerable <GoalField> GetGoalFields() { var gF = Fields.Cast <Field>().Where(f => f is GoalField); var goalFields = gF.Cast <GoalField>(); return(goalFields.ToList()); }
public IEnumerable <TaskField> GetTaskFields() { var tF = Fields.Cast <Field>().Where(f => f is TaskField); var taskFields = tF.Cast <TaskField>(); return(taskFields.ToList()); }
public override void OnStartFinished(StartState state) { base.OnStartFinished(state); _converterModule = part.Modules.GetModule <ModuleResourceConverter>(); if (_converterModule == null) { Debug.LogError("[FCT] Converter module not found."); return; } if (HighLogic.LoadedScene == GameScenes.EDITOR) { FillLimit = _converterModule.FillAmount; } else { _converterModule.FillAmount = FillLimit; } _fillLimitField = Fields.Cast <BaseField>().FirstOrDefault(f => f.name == FieldName); if (_fillLimitField == null) { Debug.LogError("[FCT] FillLimit field not found."); return; } _fillLimitField.OnValueModified += FillLimitChanged; }
public Field GetEmptyPositionForPlayer(TeamColour team) { //no player, TaskField or our GoalField var possibleFields = Fields.Cast <Field>().Where(f => (f is TaskField || (f is GoalField && !IsInEnemyGoalArea(f.Y, team))) && f.PlayerId == null); //maybe random is a bad idea (unfair?) return(possibleFields.RandomElementUsing(rnd)); }
private void FillFields(Fields fields) { foreach (var item in _filedsMapper) { var p = fields.Cast <Field>().FirstOrDefault(x => x.Code.Text.Contains(item.Key)); if (p != null) { p.Result.Text = item.Value; } } }
public void SetFieldToSearch(params object[] Fields) { if (Fields.Length == 0 && IsSimple) { SetFieldToSearch(singleSearchField); } else { set_field_to_search(Fields.Cast <object>()); } }
protected override void OnRegisterDependencies( ITypeInitializationContext context) { base.OnRegisterDependencies(context); foreach (INeedsInitialization field in Fields .Cast <INeedsInitialization>()) { field.RegisterDependencies(context); } }
public TaskField GetRandomEmptyFieldInTaskArea() { //TODO this can overwrite existing Pieces rnd = new Random(Guid.NewGuid().GetHashCode()); var possibleFields = Fields.Cast <Field>().Where(f => f.Y >= GoalsHeight && f.Y < GoalsHeight + TasksHeight && f.PlayerId == null); if (possibleFields.Count() == 0) { return(null); } return((TaskField)possibleFields.RandomElementUsing(rnd)); }
public DataTable AsNativeDataTable() { var table = new DataTable(this.Name); foreach (var f in Fields.Cast <XLTableField>()) { Type type = typeof(object); if (f.IsConsistentDataType()) { var c = f.Column.Cells().Skip(this.ShowHeaderRow ? 1 : 0).First(); switch (c.DataType) { case XLDataType.Text: type = typeof(String); break; case XLDataType.Boolean: type = typeof(Boolean); break; case XLDataType.DateTime: type = typeof(DateTime); break; case XLDataType.TimeSpan: type = typeof(TimeSpan); break; case XLDataType.Number: type = typeof(Double); break; } } table.Columns.Add(f.Name, type); } foreach (var row in this.DataRange.Rows()) { var dr = table.NewRow(); foreach (var f in this.Fields) { dr[f.Name] = row.Cell(f.Index + 1).Value; } table.Rows.Add(dr); } return(table); }
private void CompleteFields( ITypeInitializationContext context) { foreach (INeedsInitialization field in Fields .Cast <INeedsInitialization>()) { field.CompleteType(context); } if (Fields.IsEmpty) { context.ReportError(new SchemaError( $"The input object `{Name}` does not have any fields.")); } }
protected override void OnCompleteType( ITypeInitializationContext context) { base.OnCompleteType(context); foreach (INeedsInitialization field in Fields .Cast <INeedsInitialization>()) { field.CompleteType(context); } CompleteAbstractTypeResolver(context); CompleteClrType(context); ValidateFieldsRequirement(context); }
private void CompleteFields( ITypeInitializationContext context) { foreach (INeedsInitialization field in Fields .Cast <INeedsInitialization>()) { field.CompleteType(context); } if (Fields.IsEmpty) { context.ReportError(new SchemaError(string.Format( CultureInfo.InvariantCulture, TypeResources.InputObjectType_NoFields, Name))); } }
public void UpdateDistanceToPiece(IList <Piece> pieces) { foreach (var field in Fields.Cast <Field>().Where(f => f is TaskField)) { if (pieces.Where(p => p.PlayerId == null).Count() == 0) { (field as TaskField).DistanceToPiece = NO_PIECE; } else { //you need to cast to long, otherwise uint can wrap around -.- var possiblePieces = pieces.Where(p => p.PlayerId == null); var distances = possiblePieces.Select(p => Math.Abs((long)p.Location.x - (long)field.X) + Math.Abs((long)p.Location.y - (long)field.Y)); var distance = distances.Min(); (field as TaskField).DistanceToPiece = (int)distance; } } }
public bool IsThereAMine() { var actualFieldList = Fields.Cast <Field>().ToList(); int numberOfSuspectedMines = actualFieldList.Count(w => w.Flag == Mark.yes && w.Type == Type.Mine); if (numberOfSuspectedMines == NumberOfMines) { return(true); } int numberOfDetectedFields = actualFieldList.Count(w => w.Detected); if (numberOfDetectedFields + NumberOfMines == Fields.Length) { return(true); } return(false); }
void FillFields(Fields fields, Dictionary <string, string> mapper) { foreach (var item in mapper) { //foreach (Field field in fields) //Old fashion way of getting fields //{ // if (field.Code.Text.Contains(item.Key)) // { // field.Result.Text = item.Value; // break; // } //} //New way using linq to get access to the fields var p = fields.Cast <Field>() .Where(x => x.Code.Text.Contains(item.Key)) .FirstOrDefault(); if (p != null) { p.Result.Text = item.Value; } } }