コード例 #1
0
 public TubeRaceWorldObject(PartygameLobbyMmoItem cpItem, Action <GameServerEvent, object> processEvent, OfflineGameServerClient.PartyGameSessionManager partyGameSessionManager, TubeRaceDefinition raceDefinition)
 {
     this.cpItem                  = cpItem;
     this.processEvent            = processEvent;
     this.partyGameSessionManager = partyGameSessionManager;
     this.raceDefinition          = raceDefinition;
     usersInRace                  = new List <long>();
 }
コード例 #2
0
 public void SetInitialData(int gameSessionId, List <PartyGameSessionMessages.TubeRacePlayerResult> results, PartyGameDefinition partyGameDefinition, TubeRaceDefinition tubeRaceDefinition)
 {
     playerResults            = new List <PartyGameSessionMessages.TubeRacePlayerResult>(results);
     this.gameSessionId       = gameSessionId;
     this.partyGameDefinition = partyGameDefinition;
     this.tubeRaceDefinition  = tubeRaceDefinition;
     skinForDefinition(partyGameDefinition);
     changeState(PopupState.Uninitialized);
     CoroutineRunner.Start(loadRowPrefabs(), this, "loadRowPrefabs");
 }
コード例 #3
0
 public TubeRaceGameSession(List <long> usersInRace, PartygameLobbyMmoItem cpItem, Action <GameServerEvent, object> processEvent, OfflineGameServerClient.PartyGameSessionManager partyGameSessionManager, TubeRaceDefinition raceDefinition)
 {
     userScores = new Dictionary <long, int>();
     foreach (long item in usersInRace)
     {
         userScores.Add(item, 0);
     }
     this.cpItem                  = cpItem;
     this.processEvent            = processEvent;
     this.partyGameSessionManager = partyGameSessionManager;
     this.raceDefinition          = raceDefinition;
     timer = new Stopwatch();
 }
コード例 #4
0
        private void startTubeRacingSchedule()
        {
            Dictionary <int, PartyGameLauncherDefinition> dictionary = Service.Get <IGameData>().Get <Dictionary <int, PartyGameLauncherDefinition> >();

            TubeRaceLobby[] array  = UnityEngine.Object.FindObjectsOfType <TubeRaceLobby>();
            TubeRaceLobby[] array2 = array;
            foreach (TubeRaceLobby tubeRaceLobby in array2)
            {
                PartyGameDefinition gameDefinition = tubeRaceLobby.GameDefinition;
                if (!(gameDefinition != null) || !dictionary.TryGetValue(gameDefinition.Id, out var value))
                {
                    continue;
                }
                PartyGameLobbyMmoItemTeamDefinition partyGameLobbyMmoItemTeamDefinition = gameDefinition.LobbyData as PartyGameLobbyMmoItemTeamDefinition;
                if (partyGameLobbyMmoItemTeamDefinition != null)
                {
                    TubeRaceDefinition tubeRaceDefinition = gameDefinition.GameData as TubeRaceDefinition;
                    if (tubeRaceDefinition != null)
                    {
                        coroutines.Add(CoroutineRunner.StartPersistent(triggerTubeRace(partyGameLobbyMmoItemTeamDefinition, gameDefinition.Id, value.EveryXMinutesAfterTheHour, tubeRaceDefinition), this, "triggerTubeRace"));
                    }
                }
            }
        }
コード例 #5
0
        private IEnumerator triggerTubeRace(PartyGameLobbyMmoItemTeamDefinition lobbyData, int templateId, int minutesBetweenLaunches, TubeRaceDefinition raceDefinition)
        {
            while (true)
            {
                yield return(new WaitForSeconds(minutesBetweenLaunches * 60 - lobbyData.LobbyLengthInSeconds));

                PartygameLobbyMmoItem cpItem = new PartygameLobbyMmoItem
                {
                    CreatorId            = -1L,
                    gameTemplateId       = templateId,
                    Id                   = new CPMMOItemId(generateMMOItemId(), CPMMOItemId.CPMMOItemParent.WORLD),
                    playerData           = "{\"Players\":[]}",
                    timeStartedInSeconds = DateTime.UtcNow.GetTimeInSeconds(),
                    timeToLive           = lobbyData.LobbyLengthInSeconds
                };
                processEvent(GameServerEvent.SERVER_ITEM_ADDED, cpItem);
                CPMMOItemPosition position = default(CPMMOItemPosition);
                position.Id       = cpItem.Id;
                position.Position = lobbyData.LobbyLocation;
                processEvent(GameServerEvent.SERVER_ITEM_MOVED, position);
                TubeRaceWorldObject worldObject = new TubeRaceWorldObject(cpItem, processEvent, partyGameSessionManager, raceDefinition);
                worldObjects.Add(worldObject);
                yield return(new WaitForSeconds(lobbyData.LobbyLengthInSeconds));

                worldObject.StartRace();
                worldObjects.Remove(worldObject);
                processEvent(GameServerEvent.SERVER_ITEM_REMOVED, cpItem.Id);
            }
        }