Beispiel #1
0
    public void OnTurretDeath(Turret target)
    {
        StopCoroutine(friendlySpawner);
        StopCoroutine(enemySpawner);
        ClearAllUnits();
        dOnGameComplete.Invoke();
        Turret t = turret.GetComponent <Turret>();

        t._inputIsEnabled = false;
    }
 void GameComplete()
 {
     endTime = Time.time;
     playerInputHandler.DisablePlayerInput();
     SaveBestTime();
     OnGameComplete?.Invoke();
 }
Beispiel #3
0
        private void _messageReceiver_FMD_S_GAME_OVER(ClientConnection client, AllegianceInterop.FMD_S_GAME_OVER message)
        {
            // Don't receive any more messages from the client for this strategy.
            ClientConnection.OnAppMessage -= _messageReceiver.OnAppMessage;

            OnGameComplete?.Invoke(this);
        }
Beispiel #4
0
    public Promise UpdateMetches(TournamentObject info)
    {
        return(new Promise((action, exeption) => {
            SetCurrentTournament(info.Id);

            TournamentManager.Instance.GetDetailsTournamentObject(info.TournamentDetails.Id)
            .Then(detail => {
                ApiManager.Instance.Database.GetMatches(Array.ConvertAll(detail.Matches, match => match.Id))
                .Then(matches => {
                    var myMatch = Array.Find(matches, match => match.State.Equals(ChainTypes.MatchState.InProgress) && match.Players.Contains(me.Id));
                    ApiManager.Instance.Database.GetGames(Array.ConvertAll(myMatch.Games, game => game.Id))
                    .Then(games => {
                        var existTournament = IsTournamentExist(myMatch.Tournament);
                        var existMatch = existTournament && myTournaments[myMatch.Tournament].StartedMatches.Contains(myMatch.Id);
                        if (!existTournament)
                        {
                            myTournaments[myMatch.Tournament] = new TournamentContainer(match => OnNewMatch.Invoke(match), match => OnMatchComplete.Invoke(match));
                        }
                        myTournaments[myMatch.Tournament].UpdateTournamentInfo(info, detail);
                        var opponent = Array.Find(myMatch.Players, account => !me.Id.Equals(account));
                        Repository.GetInPromise(opponent, () => ApiManager.Instance.Database.GetAccount(opponent.Id))
                        .Then(account => {
                            if (!existMatch)
                            {
                                myTournaments[myMatch.Tournament]
                                .NewMatch(myMatch, me, account,
                                          (match, game) => OnNewGame.Invoke(match, game),
                                          (match, game) => OnGameComplete.Invoke(match, game),
                                          (match, game) => OnGameExpectedMove.Invoke(match, game));
                            }
                            var completedGames = myTournaments[myMatch.Tournament].CurrentMatch.CompletedGames;
                            foreach (var game in games)
                            {
                                if (!completedGames.ContainsKey(game.Id))
                                {
                                    if (game.State.Equals(ChainTypes.GameState.Complete))
                                    {
                                        (completedGames[game.Id] = new GameContainer(completedGames.Count + 1, game, me, account))
                                        .CheckState();
                                    }
                                    else
                                    {
                                        myTournaments[myMatch.Tournament].CurrentMatch.NewGame(game).CheckState();
                                    }
                                }
                            }
                            action();
                        });
                    });
                });
            });
        }));
    }
Beispiel #5
0
 public GameContainer NewGame(GameObject game)
 {
     if (!currentGame.IsNull() && !currentGame.Id.Equals(game.Id))
     {
         completedGames[currentGame.Id] = currentGame;
     }
     currentGame = new GameContainer(completedGames.Count + 1, game, me, opponent, gameExpectedMove => {
         OnGameExpectedMove.Invoke(this, gameExpectedMove);
     }, completedGame => {
         OnGameComplete.Invoke(this, completedGames[completedGame.Id] = completedGame);
     });
     OnNewGame(this, currentGame);
     return(currentGame);
 }
Beispiel #6
0
    void Repository_OnObjectUpdate(IdObject idObject)
    {
        if (!idObject.SpaceType.Equals(SpaceType.Match))
        {
            return;
        }
        var updatedMatch = idObject as MatchObject;

        if (!updatedMatch.Players.Contains(me.Id))
        {
            return;
        }
        if (updatedMatch.State.Equals(ChainTypes.MatchState.WaitingOnPreviousMatches))
        {
            return;
        }
        Repository.GetInPromise(updatedMatch.Tournament, () => TournamentManager.Instance.LoadTournament(updatedMatch.Tournament.Id)).Then(tournament => {
            Repository.GetInPromise(tournament.TournamentDetails, () => TournamentManager.Instance.GetDetailsTournamentObject(tournament.TournamentDetails.Id)).Then(tournamentDetails => {
                var existTournament = IsTournamentExist(updatedMatch.Tournament);
                var existMatch      = existTournament && myTournaments[updatedMatch.Tournament].StartedMatches.Contains(updatedMatch.Id);
                if (!existTournament)
                {
                    myTournaments[updatedMatch.Tournament] = new TournamentContainer(match => OnNewMatch.Invoke(match), match => OnMatchComplete.Invoke(match));
                }
                myTournaments[updatedMatch.Tournament].UpdateTournamentInfo(tournament, tournamentDetails);
                if (!existMatch && updatedMatch.State.Equals(ChainTypes.MatchState.InProgress))
                {
                    var opponent = Array.Find(updatedMatch.Players, account => !me.Id.Equals(account));
                    Repository.GetInPromise(opponent, () => ApiManager.Instance.Database.GetAccount(opponent.Id)).Then(account => {
                        myTournaments[updatedMatch.Tournament].NewMatch(updatedMatch, me, account,
                                                                        (match, game) => OnNewGame.Invoke(match, game),
                                                                        (match, game) => OnGameComplete.Invoke(match, game),
                                                                        (match, game) => OnGameExpectedMove.Invoke(match, game));
                    });
                }
            });
        });
    }