Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();
            BrickManager.Init();

            var ports     = SerialPort.GetPortNames();
            var portsList = new List <string>();

            portsList.Add("None");
            portsList.AddRange(ports);
            ports = portsList.ToArray();
            Brick1Comport.ItemsSource = ports;
            Brick2Comport.ItemsSource = ports;
            Brick3Comport.ItemsSource = ports;
            Brick4Comport.ItemsSource = ports;
            foreach (UserIndex value in Enum.GetValues(typeof(UserIndex)))
            {
                if (value == UserIndex.Any)
                {
                    continue;
                }
                var controler = new Controller(value);
                if (!controler.IsConnected)
                {
                    HideRing(value);
                    continue;
                }
                BrickManager.AddBrickAndControler(new BrickControl(null, controler));
            }
            _timer          = new Timer(75);
            _timer.Elapsed += _timer_Elapsed;
            _timer.Start();
        }
Exemplo n.º 2
0
        private void InitLevel()
        {
            _brickManager             = GetComponent <BrickManager>();
            _lifeManager              = GetComponent <LifeManager>();
            BrickManager.OnDestroyed += CheckBrickCount;
            LifeManager.OnFailed     += CheckLife;

            _playerColor     = UnityEngine.Random.ColorHSV(0.0f, 0.3f, 0.4f, 0.6f, 1.0f, 1.0f);
            _ballColor       = UnityEngine.Random.ColorHSV(0.3f, 0.6f, 0.3f, 0.6f, 1.0f, 1.0f);
            _backgroundColor = UnityEngine.Random.ColorHSV(0.6f, 1.0f, 0.1f, 0.2f, 1.0f, 1.0f);

            _playerMaterial.color = _playerColor;
            _ballMaterial.color   = _ballColor;
        }