void Update () { if (!_cloned) { _cloned = true; Clone(gameObject); PlainType plainClone = Clone(MyPlainType); Debug.Log("Org = " + MyPlainType.Count + " Clone = " + plainClone.Count); } }
/// <summary> /// Вывод занятых ресурсов. /// </summary> internal void LogTakenResources(ExamProcess exam, PlainType plainType, int queueLevel) { sb.Append($"{exam.Student.Status()} started | "); foreach (var eqName in exam.Student.SubjectToPassing.EquipmentNames) { sb.Append($"<{exam.Equipments.Where(e => e.Name == eqName).FirstOrDefault().Status()}> "); } sb.AppendLine($"<{exam.Teacher.Status()}>"); Output(); }
internal AbstractPlanner(OutputMode mode, PlainType plainType, IEnumerable <Card> cards, int threadCount, int pause) { cardController = new CardController(cards); cardsLeft = cards.Count(); this.threadCount = threadCount; this.pause = pause; linearTime = (double)(pause * cardController.Cards.Count) / 1000; this.plainType = plainType; logger = new Logger(mode); logger.LogInfo(this.plainType, cardController.Cards.Count, threadCount, pause); }
/// <summary> /// Вывод входных параметров. /// </summary> /// <param name="type">Тип планирования.</param> /// <param name="cardsCount">Количество карт в коллекции.</param> /// <param name="threadCount">Количество потоков.</param> /// <param name="pause">Пауза.</param> internal void LogInfo(PlainType type, int cardsCount, int threadCount, int pause) { lock (sb) { sb.AppendLine($"Анализ коллекции из {cardsCount} карт, при ограниченнии количества одновременно работающих потоков {threadCount}, с задержкой {pause} мс."); sb.Append("Для планировки используется "); sb.AppendLine(type switch { PlainType.ThreadArraySemaphore => "массив потоков, сфемафор.", PlainType.ThreadArraySemaphorePetri => "массив потоков, сеть Петри моделирующая семафор.", PlainType.ThreadPool => "системный пул потоков.", PlainType.ThreadPoolPetri => "пул потоков, сеть Петри.", _ => throw new Exception("Неверный тип планирования.") });
public static T Clone<T>(T source) where T : class { if (typeof(T) == typeof(GameObject)) { GameObject clone = Instantiate(source as GameObject); return clone as T; } else if (typeof(T) == typeof(PlainType)) { PlainType p = new PlainType(); // clone code return p as T; } return null; }
/// <summary> /// Вывод при освобождении ресурсов. /// </summary> internal void LogReleasedResources(ExamProcess exam, int threadId, PlainType plainType, int queueLevel = 0) { sb.Append(exam.Student.Status()); if (exam.Student.SubjectToPassing.RemainingTime > 0) { sb.Append($" release | "); } else { sb.Append($" finish | "); } foreach (var eqName in exam.Student.SubjectToPassing.EquipmentNames) { sb.Append($"<{exam.Equipments.Where(e => e.Name == eqName).FirstOrDefault().Status()}> "); } sb.AppendLine($"<{exam.Teacher.Status()}>"); Output(); }
public void CheckDispReport(int speed, int height, List <string> reports, PlainType type) { int tempError = _erPoints; string res; if (speed == 0 && height == 0 && (type != PlainType.Landing && type != PlainType.Takeoff)) { throw new Exception("Самолет разбился!"); } CalcHeight(speed); CalcErrorPoints(height); res = $"Диспетчер {Name}\nРекомендуемая высота: {_recomenHeight}\nШтрафных очков: {_erPoints}\n"; if (speed > _maxSpeed) { res += $"Самолет превышает максимальную скорость!\nНемедленно снизьте скорость!\nНачислено 100 штрафных очков!\n"; _erPoints += 100; CalcHeight(_maxSpeed); } reports.Add(res); }