public Scene(RootObject p_rootObject, Player p_player, params Entity[] p_entities) { tag = "Scene"; player = p_player; _rootObject = p_rootObject; _collider = new Collider(p_rootObject); entities = new List <Entity>(p_entities); entitiesToRemove = new List <Entity>(); _playerWeaponManager = new PlayerWeaponManager(p_player); _playerWeaponManager.OnLinkSwordDie += _playerWeaponManager_OnLinkSwordDie; _enemyWeaponManager = new EnemyWeaponManager(); SetPortals(RootObjectUtil.GetLayerByName(p_rootObject, "Portals")); SetItems(RootObjectUtil.GetLayerByName(p_rootObject, "Items")); SetEnemies(RootObjectUtil.GetLayerByName(p_rootObject, "Enemies")); SetDoors(RootObjectUtil.GetLayerByName(p_rootObject, "Doors")); entities.Add(player); portals.ForEach(p_portal => entities.Add(p_portal)); _enemies.ForEach(p_enemy => entities.Add(p_enemy)); if (_enemies.Count == 0) { AllEnemiesDead(); } _worldTileSet = Main.s_game.Content.Load <Texture2D>("TileSet_World"); _collisionMask = Main.s_game.Content.Load <Texture2D>("TileSet_CollisionMask"); SoundManager.instance.Play(World.IsOpenWorld() ? SoundType.OVERWORLD : SoundType.DUNGEON, true); SoundManager.instance.StopAndDispose(World.IsOpenWorld() ? SoundType.DUNGEON : SoundType.OVERWORLD); }
//private void Awake() private void Init() { if (IsPlayer) { PlayerController controller = gameObject.AddComponent <PlayerController>(); controller.UpperPart = this.UpperPart; PlayerWeaponManager playerWeaponManager = gameObject.AddComponent <PlayerWeaponManager>(); playerWeaponManager.UpperPart = this.UpperPart; playerWeaponManager.BulletVFX = this.Bullet; playerWeaponManager.HitVFX = this.HitVFX; playerWeaponManager.MuzzleVFX = this.MuzzleVFX; playerWeaponManager.InitBulletPosition = this.InitBulletPosition; playerWeaponManager.ShootSound = Shoot; } else { EnemyController controller = gameObject.AddComponent <EnemyController>(); controller.UpperPart = this.UpperPart; EnemyWeaponManager enemyWeaponManager = gameObject.AddComponent <EnemyWeaponManager>(); enemyWeaponManager.UpperPart = this.UpperPart; enemyWeaponManager.BulletVFX = this.Bullet; enemyWeaponManager.HitVFX = this.HitVFX; enemyWeaponManager.MuzzleVFX = this.MuzzleVFX; enemyWeaponManager.InitBulletPosition = this.InitBulletPosition; enemyWeaponManager.ShootSound = Shoot; } PositionManager positionManager = gameObject.AddComponent <PositionManager>(); positionManager.SetParameters(this.gameObject); }