void writeToRecords(EnemyCaptureResult enemyComponent, int corrospondIndex) { //If this type of component is in the record if (corrospondIndex > -1) { if (enemyComponent.CapturedComponentScore.IsScoreHigherThen(Records[corrospondIndex].CapturedComponentScore)) { Records[corrospondIndex] = enemyComponent; } } else { Records.Add(enemyComponent); Records.OrderBy(p => p.CapturedComponentID.ComponentID); } }
int getCorronspondingEnemyIndex(EnemyCaptureResult record) { return(Records.FindIndex(p => p.CapturedComponentID.Equals(record.CapturedComponentID))); }
public void AddNewRecord(EnemyCaptureResult enemyComponent) { int corrospondIndex = getCorronspondingEnemyIndex(enemyComponent); writeToRecords(enemyComponent, corrospondIndex); }