void Awake() { int playerID = GameManager.Instance.Register(this); myID = playerID; _control = new Controller(playerID); _rb = GetComponent <Rigidbody>(); _lightsModule = GetComponent <PlayerLightsModuleHandler>(); MovementMultiplier = 1; Hp = maxHP; gameObject.name = "Player " + (playerID + 1); _stats = new PlayerStats(); ScoreController = GetComponent <PlayerScoreController>(); _soundModule = GetComponent <DroneSoundController>(); AnimationController = GetComponent <PlayerAnimations>(); _lifeForcefield = GetComponentInChildren <PlayerLifeForcefield>(); _camModule = GetComponentInChildren <PlayerCameraModule>(); _controlModule = GetComponent <PlayerControlModule>(); _col = GetComponent <Collider>(); weightModule = GetComponent <DroneWeightModule>(); _particleModule = GetComponent <PlayerParticlesModule>(); }
protected override void Initialize() { InputModules = new List<IGameplayModule>(); GraphicalModules = new List<IGameplayModule>(); base.Initialize(); // (calls LoadContent) Camera = new Camera(GraphicsDevice.Viewport.AspectRatio, 70.0f, 0.1f, 1000.0f); UpdateCamera(); White1x1 = new Texture2D(GraphicsDevice, 1, 1); White1x1.SetData<Color>(new[] { Color.White }); Audio = new AudioManager(); Audio.LoadDefaultPacks(Content); SkyModule = new SkyModule(this); ChunkModule = new ChunkModule(this); DebugInfoModule = new DebugInfoModule(this, Pixel); ChatModule = new ChatModule(this, Pixel); var hud = new HUDModule(this, Pixel); var windowModule = new WindowModule(this, Pixel); GraphicalModules.Add(SkyModule); GraphicalModules.Add(ChunkModule); GraphicalModules.Add(new HighlightModule(this)); GraphicalModules.Add(hud); GraphicalModules.Add(ChatModule); GraphicalModules.Add(windowModule); GraphicalModules.Add(DebugInfoModule); InputModules.Add(windowModule); InputModules.Add(DebugInfoModule); InputModules.Add(ChatModule); InputModules.Add(new HUDModule(this, Pixel)); InputModules.Add(ControlModule = new PlayerControlModule(this)); Client.PropertyChanged += HandleClientPropertyChanged; Client.Connect(EndPoint); BlockProvider.BlockRepository = BlockRepository; var itemRepository = new ItemRepository(); itemRepository.DiscoverItemProviders(); ItemRepository = itemRepository; BlockProvider.ItemRepository = ItemRepository; IconRenderer.CreateBlocks(this, BlockRepository); var centerX = GraphicsDevice.Viewport.Width / 2; var centerY = GraphicsDevice.Viewport.Height / 2; Mouse.SetPosition(centerX, centerY); MouseComponent.Scroll += OnMouseComponentScroll; MouseComponent.Move += OnMouseComponentMove; MouseComponent.ButtonDown += OnMouseComponentButtonDown; MouseComponent.ButtonUp += OnMouseComponentButtonUp; KeyboardComponent.KeyDown += OnKeyboardKeyDown; KeyboardComponent.KeyUp += OnKeyboardKeyUp; GamePadComponent.ButtonDown += OnGamePadButtonDown; GamePadComponent.ButtonUp += OnGamePadButtonUp; CreateRenderTarget(); SpriteBatch = new SpriteBatch(GraphicsDevice); ThreadID = Thread.CurrentThread.ManagedThreadId; }