public AsteroidManager(uint maxAsteroids) { _maxAsteroids = maxAsteroids; _asteroids = new List <Asteroid>((int)_maxAsteroids); for (int i = 0; i < _maxAsteroids; i++) { var asteroidView = MiniPool.Create(PrefabName.Asteroid, Vector3.zero); var asteroid = new Asteroid(asteroidView); _asteroids.Add(asteroid); } }
protected override void Execute(List <GameEntity> entities) { foreach (var gameEntity in entities) { gameEntity.AddView(MiniPool.Create(gameEntity.prefab.name, gameEntity.position.value)); gameEntity.view.value.transform.SetParent(_gameContainer); if (gameEntity.isPlayer) { gameEntity.view.value.AddComponent <EntityLink>().Link(gameEntity, Contexts.sharedInstance.game); gameEntity.view.value.AddComponent <CubeCollisionEmitter>(); } else if (gameEntity.isObstacle) { gameEntity.view.value.transform.GetChild(0).GetComponent <MeshRenderer>().material = Resources.Load <MaterialDictionary>("Materials").GetRandomMaterial(); } } }
public AddViewSystem(IContext <GameEntity> context) : base(context) { _gameContainer = MiniPool.Create(PrefabName.GameContainer, Vector3.zero).transform; }