public Arena(ArenaProperties props) { _state = new PopulationState(); _state.StartPopulation = props.Population; _arenaRectTransform = props.ArenaObject.transform as RectTransform; if (_arenaRectTransform == null) { throw new Exception("_arenaRectTransform is null"); } _moveController = new MoveController(_arenaRectTransform); _arenaRectTransform.sizeDelta = new Vector2(props.WorldWidth, props.WorldHeight); var rand = new Random(); for (int i = 0; i < props.Population; i++) { var personProps = new PersonProperties(); if (rand.NextDouble() > props.PercentAtIsolation) { personProps.Speed = (float)(props.PersonSpeed + rand.NextDouble() * props.PersonSpeed); } else { personProps.Speed = 0; } personProps.PersonPrefab = props.PersonObject; var person = ArenaUtils.CreatePerson(personProps, _arenaRectTransform); _persons.Add(person); } }
public void StartNewArena() { if (_isStarted) { return; } _arenaUiComps.gameObject.SetActive(true); _arenaGo.gameObject.SetActive(true); _isStarted = true; _props = new ArenaProperties(10000, _arenaGo, _personPrefab, 100f, 0.0f, 50000, 50000); _arena = new Arena(_props); _arena.InfectRandom(new InfectionProps(60)); _arenaUi = new MainStatUi(_arenaUiComps, _arena.State, _arena); }