public SpellsManager(GameStateManager stateManager, UnitsManager unitsManager, bool isHost)
 {
     _unitsManager = unitsManager;
     _stateManager = stateManager;
     _stateManager.OnSpellActivated += ResolveSpellActivation;
     _stateManager.OnCardPlayed     += ActivateSpell;
     _isHost = isHost;
 }
        protected async Task Start()
        {
            Debug.Log("start called");

            _stateManager = new GameStateManager(_connection);
            _stateManager.OnCardRequested        += OnCardRequested;
            _stateManager.OnCardPlayed           += OnCardPlayed;
            _stateManager.OnStartingHandReceived += OnStartingHandReceived;

            _unitsManager = new UnitsManager(_connection, _stateManager);

            _localHandPanel.OnCardPlayed += OnCardRequested;
            _localHandPanel.Init(_connection, _stateManager);

            Debug.Log("post local hand panel init");

            _summary.SetBackButtonHandler(() =>
            {
                _summary.Hide();
                _stateManager.LeaveGame();
            });

            await _localHand.Init(_connection);

            await _opponentHand.Init(_connection);

            Debug.Log("post hand init");

            _unitsManager.OnAfterUnitInstantiated += HandleAfterUnitInstantiated;

            IMatch match = await _connection.Socket.JoinMatchAsync(_connection.BattleConnection.Matched);

            _connection.BattleConnection.MatchId = match.Id;



            if (match.Presences.Count() == 1)
            {
                Debug.Log("count is 1");

                string opponentId = match.Presences.First().UserId;
                _connection.BattleConnection.OpponentId = opponentId;
                _connection.BattleConnection.HostId     = opponentId;
                SetInitialPlayerState();
            }
            else
            {
                Debug.Log("count is 0");
                _connection.BattleConnection.HostId       = _connection.Session.UserId;
                _connection.Socket.ReceivedMatchPresence += HandleOtherPlayerJoin;
            }

            _spellsManager = new SpellsManager(_stateManager, _unitsManager, _connection.BattleConnection.HostId == _connection.Session.UserId);
        }
Ejemplo n.º 3
0
        protected override void Awake()
        {
            _stateManager = new GameStateManager(_connection);
            _stateManager.OnCardRequested        += OnCardRequested;
            _stateManager.OnCardPlayed           += OnCardPlayed;
            _stateManager.OnStartingHandReceived += OnStartingHandReceived;

            _localHandPanel.OnCardPlayed += OnCardRequested;
            _localHandPanel.Init(_connection, _stateManager);

            _summary.SetBackButtonHandler(() =>
            {
                _summary.Hide();
                _stateManager.LeaveGame();
            });

            _localHand.Init(_connection);
            _opponentHand.Init(_connection);

            _unitsManager = new UnitsManager(_connection, _stateManager);
            _unitsManager.OnAfterUnitInstantiated += HandleAfterUnitInstantiated;

            base.Awake();
        }
Ejemplo n.º 4
0
 public void Init(GameStateManager stateManager, UnitsManager unitsManager, bool isHost)
 {
     _stateManager = stateManager;
     _unitsManager = unitsManager;
     _isHost       = isHost;
 }