public static void InitializeController() { window = Program.MainWindow; // Subscribe to the notify event window.ViewNotification += Window_ViewNotification; player = Player.PlayerInstance; player.Initialize(); // Lazy initialization of projectile pool projectilePool = ProjectilePool.Instance; projectilePool.Initialize(); /*for (int i = 0; i < MapLoader.MonstersCount; i++) * { * IndexPair startPoint = new IndexPair(MapLoader.Monsters[i].StartPoint.X, MapLoader.Monsters[i].StartPoint.Y); * IndexPair endPoint = new IndexPair(MapLoader.Monsters[i].EndPoint.X, MapLoader.Monsters[i].EndPoint.Y); * Monster mon = new Monster(startPoint, endPoint); * movingObjects.Add(mon); * }*/ for (int i = 0; i < MapLoader.BombsCount; i++) { IndexPair start = new IndexPair(MapLoader.Bombs[i].StartPoint.X, MapLoader.Bombs[i].StartPoint.Y); BombA bomb = new BombA(start); constantObjects.Add(bomb); } for (int i = 0; i < MapLoader.CoinsCount; i++) { IndexPair start = new IndexPair(MapLoader.Coins[i].StartPoint.X, MapLoader.Coins[i].StartPoint.Y); CoinGift coin = new CoinGift(start); constantObjects.Add(coin); } for (int i = 0; i < MapLoader.BulletsCount; i++) { IndexPair start = new IndexPair(MapLoader.Bullets[i].StartPoint.X, MapLoader.Bullets[i].StartPoint.Y); BulletGift bullet = new BulletGift(start); constantObjects.Add(bullet); } movingObjects.Add(player); backgroundIllusionTimer.Interval = 100; backgroundIllusionTimer.Elapsed += BackgroundIllusionTimer_Elapsed; backgroundIllusionTimer.Enabled = true; #if !DEBUG #endif drawGraphics += DrawMovingBackground; drawGraphics += MapLoader.DrawGameFlares; drawGraphics += MapLoader.DrawLevelFloor; drawGraphics += MapLoader.DrawLevelObstacles; drawGraphics += player.UpdateGraphics; drawGraphics += UpdateTiles; drawGraphics += DrawShots; }
private void Start() { Random.InitState(321); _contexts = Contexts.sharedInstance; _contexts.game.SetGlobals(_globals); _contexts.game.SetProjectilePool(_projectilePool); _projectilePool.Initialize(_globals); _systems = CreateSystems(_contexts); _systems.Initialize(); }
public void Initialize(PlayerConfig playerConfig, ProjectileConfig projectileConfig) { Speed = playerConfig.Speed; HealthPoint = playerConfig.HealthPoint; _immuneTime = playerConfig.ImmuneTime; _fireВelay = playerConfig.FireDelay; GameObject gameObject = Object.Instantiate(Resources.Load("Prefabs/Player")) as GameObject; View = gameObject.GetComponent <PlayerView>(); View.Initialize(this); float heightInPixels = gameObject.GetComponent <SpriteRenderer>().bounds.size.y; gameObject.transform.localScale = new Vector3(playerConfig.Scale / heightInPixels, playerConfig.Scale / heightInPixels, 1); _projectilePool = new ProjectilePool(projectileConfig, this, playerConfig.Scale); _projectilePool.Initialize(); }
// Start is called before the first frame update void Awake() { // Main camera init var cameraPrefab = Resources.Load <GameObject>(CameraGameObjectPath); var cameraInstance = Instantiate(cameraPrefab); // Background init var backgroundPrefab = Resources.Load <GameObject>(BackgroundGameObjectPath); var backgroundInstance = Instantiate(backgroundPrefab); // Update loop init var updatePrefab = Resources.Load <GameObject>(UpdateGameObjectPath); var updateInstance = Instantiate(updatePrefab); var updateController = updateInstance.GetComponent <UpdateObject>(); updateController.Initialize(); ProjectilePool.Initialize(); Destroy(gameObject); }