Beispiel #1
0
        async void Start()
        {
            _playerInfo = new PlayerInfo(MaxHitPoints);

            _shipInfo              = new ShipInfo();
            _shipInfo.Speed        = Speed;
            _shipInfo.WeaponDamage = WeaponDamage;
            _shipInfo.WeaponPlaces = new Vector3[4] {
                new Vector3(-0.6f, 0f, 0.5f),
                new Vector3(0.6f, 0f, 0.5f),
                new Vector3(-0.35f, 0f, 0.3f),
                new Vector3(0.35f, 0f, 0.3f)
            };
            _shipInfo.WeaponShootingFrequency = WeaponShootingFrequency;
            _shipInfo.Position.Value          = new Vector3(0f, 0f, 0f);
            _shipInfo.Active = true;

            _levelInfo = PersistentState.Get().CurrentLevelInfo;

            LevelGenerator.GenerateAsteroids(_levelInfo, out _asteroids);

            await System.Threading.Tasks.Task.Yield();

            MessageBroker.Default.Publish(SharedMessage.Create(this, SharedMessage.MessageType.INIT_PLAYER, _playerInfo));
            MessageBroker.Default.Publish(SharedMessage.Create(this, SharedMessage.MessageType.INIT_LEVEL, _levelInfo));
            MessageBroker.Default.Publish(SharedMessage.Create(this, SharedMessage.MessageType.INIT_ASTEROIDS, _asteroids));
            MessageBroker.Default.Publish(SharedMessage.Create(this, SharedMessage.MessageType.INIT_SHIP, _shipInfo));
        }
Beispiel #2
0
 void SetupPersistentState()
 {
     _mapState = new MapState();
     _mapState.SelectedLevel.Value = -1;
     _mapState.SelectedLevel.ObserveEveryValueChanged(value => value.Value)
     .Subscribe(value => {
         if (value > -1)
         {
             var levelInfo = Levels[value];
             PersistentState.Get().CurrentLevelInfo = levelInfo;
             SceneManager.LoadScene(1);
         }
     }).AddTo(_disposables);
 }