protected override IEnumerator setup()
        {
            yield return(base.setup());

            eventDispatcher = Service.Get <EventDispatcher>();
            Service.Set(SpashScreenCanvas);
            Service.Set(SpashScreenCanvas.gameObject.AddComponent <LoadingController>());
            base.gameObject.AddComponent <KeyChainManager>();
            Service.Set(new GameSettings());
            initDataModel();
            initContentAction();
            yield return(StartTestCoroutine(initSchedulerAction(), this, "initSchedulerAction"));

            initNetworkServices();
            SceneTransitionService sts = base.gameObject.AddComponent <SceneTransitionService>();

            sts.LoadingMode = LoadSceneMode.Additive;
            Service.Set(sts);
            TestZoneDefinition               = ScriptableObject.CreateInstance <ZoneDefinition>();
            TestZoneDefinition.ZoneName      = "EmptySceneForLoadingTests";
            TestZoneDefinition.SceneName     = "EmptySceneForLoadingTests";
            TestZoneDefinition.SceneFilePath = "Assets/Game/Core/Tests/IntegrationTests/ZoneAndSceneTransitionTests/EmptySceneForLoadingTests.unity";
            Manifest zoneManifest = ScriptableObject.CreateInstance <Manifest>();

            zoneManifest.Assets = new ScriptableObject[1] {
                TestZoneDefinition
            };
            zts = base.gameObject.AddComponent <ZoneTransitionService>();
            zts.SetZonesFromManifest(zoneManifest);
            Service.Set(zts);
            yield return(null);
        }
 private void Awake()
 {
     eventDispatcher       = Service.Get <EventDispatcher>();
     zoneTransitionService = Service.Get <ZoneTransitionService>();
     localPlayerHandle     = Service.Get <CPDataEntityCollection>().LocalPlayerHandle;
     gameStateController   = Service.Get <GameStateController>();
 }
Пример #3
0
 private void Awake()
 {
     eventDispatcher       = Service.Get <EventDispatcher>();
     zoneTransitionService = Service.Get <ZoneTransitionService>();
     gameStateController   = Service.Get <GameStateController>();
     questService          = Service.Get <QuestService>();
 }
Пример #4
0
 public ErrorService()
 {
     connectionManager     = Service.Get <ConnectionManager>();
     gameStateController   = Service.Get <GameStateController>();
     promptManager         = Service.Get <PromptManager>();
     sessionManager        = Service.Get <SessionManager>();
     dataEntityCollection  = Service.Get <CPDataEntityCollection>();
     zoneTransitionService = Service.Get <ZoneTransitionService>();
     eventDispatcher       = Service.Get <EventDispatcher>();
     eventDispatcher.AddListener <ApplicationService.Error>(onError);
     eventDispatcher.AddListener <SessionErrorEvents.AccountBannedEvent>(onAccountBannedEvent);
     eventDispatcher.AddListener <SessionErrorEvents.AuthenticationRequiresParentalConsentEvent>(onAuthenticationRequiresParentalConsentEvent);
     eventDispatcher.AddListener <SessionErrorEvents.AuthenticationRevokedEvent>(onAuthenticationRevokedEvent);
     eventDispatcher.AddListener <SessionErrorEvents.AuthenticationUnavailableEvent>(onAuthenticationUnavailableEvent);
     eventDispatcher.AddListener <SessionErrorEvents.SessionTerminated>(onSessionTerminated);
     eventDispatcher.AddListener <SessionErrorEvents.SessionDataCorrupted>(onSessionDataCorrupted);
     eventDispatcher.AddListener <SessionErrorEvents.NoNetworkOnResumeError>(onNoNetworkOnResume);
     eventDispatcher.AddListener <SessionErrorEvents.NoSessionOnResumeError>(onNoSessionOnResume);
     eventDispatcher.AddListener <SessionErrorEvents.RegistrationConfigError>(onRegistrationConfigError);
     eventDispatcher.AddListener <WorldServiceErrors.WorldDisconnectedEvent>(onWorldDisconnected);
     eventDispatcher.AddListener <WorldServiceErrors.WorldNetworkErrorEvent>(onWorldNetworkError);
     eventDispatcher.AddListener <NetworkErrors.NoConnectionError>(onNoConnectionError);
     eventDispatcher.AddListener <NetworkErrors.GeneralError>(onGeneralNetworkError);
     Service.Get <EventDispatcher>().AddListener <LoadingController.TimeoutEvent>(onLoadingScreenTimeout);
     eventDispatcher.AddListener <WorldServiceEvents.SelfRoomJoinedEvent>(onRoomJoined);
     CoroutineRunner.StartPersistent(preloadIcons(), this, "Preload error icons");
 }
    public void ChangeServer(string worldName)
    {
        ZoneTransitionService zoneTransitionService = Service.Get <ZoneTransitionService>();
        PresenceData          component;
        string sceneName = (!dataEntityCollection.TryGetComponent(dataEntityCollection.LocalPlayerHandle, out component)) ? GetZoneToLoad() : component.Room;

        Service.Get <LoadingController>().ClearAllLoadingSystems();
        zoneTransitionService.LoadZone(sceneName, SceneConfig.TransitionSceneName, worldName);
        gameStateMachine.SendEvent(ZoneConnectingEvent);
    }
    public void ReconnectFromHome()
    {
        ZoneTransitionService zoneTransitionService = Service.Get <ZoneTransitionService>();
        string text = zoneTransitionService.CurrentZone.SceneName;

        if (text == null)
        {
            text = GetZoneToLoad();
        }
        zoneTransitionService.LoadZone(text);
    }
    public void ReturnToHome()
    {
        ZoneTransitionService zoneTransitionService = Service.Get <ZoneTransitionService>();

        if (zoneTransitionService.IsTransitioning || zoneTransitionService.IsConnecting)
        {
            Service.Get <ZoneTransitionService>().CancelTransition(SceneConfig.HomeSceneName);
        }
        else
        {
            zoneTransitionService.LoadAsZoneOrScene(SceneConfig.HomeSceneName, SceneConfig.TransitionSceneName);
        }
        gameStateMachine.SendEvent(DefaultEvent);
        networkController.LeaveRoom();
    }
Пример #8
0
    public override IEnumerator PerformFirstPass()
    {
        GameObject              go = Service.Get <GameObject>();
        ManifestContentKey      zoneDefinitionManifestContentKey = StaticGameDataUtils.GetManifestContentKey(typeof(ZoneDefinition));
        AssetRequest <Manifest> assetZoneRequest = Content.LoadAsync(zoneDefinitionManifestContentKey);
        ManifestContentKey      worldDefinitionManifestContentKey = StaticGameDataUtils.GetManifestContentKey(typeof(WorldDefinition));
        AssetRequest <Manifest> assetWorldRequest = Content.LoadAsync(worldDefinitionManifestContentKey);

        yield return(assetZoneRequest);

        yield return(assetWorldRequest);

        ZoneTransitionService service = go.AddComponent <ZoneTransitionService>();

        service.SetIglooSplashScreenKey(IglooSplashScreen);
        service.SetZonesFromManifest(assetZoneRequest.Asset);
        service.SetWorldsFromManifest(assetWorldRequest.Asset);
        Service.Set(service);
    }
    public void ExitAfterBan()
    {
        SessionManager        sessionManager        = Service.Get <SessionManager>();
        ZoneTransitionService zoneTransitionService = Service.Get <ZoneTransitionService>();

        dataEntityCollection.ClearZoneScope();
        sessionManager.DisposeSession();
        GoOffline();
        if (zoneTransitionService.IsTransitioning || zoneTransitionService.IsConnecting)
        {
            Service.Get <ZoneTransitionService>().CancelTransition(SceneConfig.HomeSceneName);
            gameStateMachine.SendEvent(DefaultEvent);
        }
        else
        {
            Service.Get <LoadingController>().ClearAllLoadingSystems();
            ReturnToHome();
        }
    }
    public void ExitWorld(bool logout = false)
    {
        SessionManager        sessionManager        = Service.Get <SessionManager>();
        ZoneTransitionService zoneTransitionService = Service.Get <ZoneTransitionService>();

        if (sessionManager.HasSession)
        {
            if (logout)
            {
                try
                {
                    sessionManager.Logout();
                }
                catch (ObjectDisposedException)
                {
                }
            }
            else
            {
                dataEntityCollection.ClearZoneScope();
                sessionManager.DisposeSession();
            }
        }
        else
        {
            dataEntityCollection.ClearZoneScope();
        }
        if (zoneTransitionService.IsTransitioning || zoneTransitionService.IsConnecting)
        {
            Service.Get <ZoneTransitionService>().CancelTransition(SceneConfig.HomeSceneName);
            GoOffline();
            gameStateMachine.SendEvent(DefaultEvent);
        }
        else
        {
            GoOffline();
            Service.Get <LoadingController>().ClearAllLoadingSystems();
            ReturnToHome();
        }
    }
    public void ReturnToZoneScene(Dictionary <string, object> sceneArgs = null)
    {
        ZoneTransitionService zoneTransitionService = Service.Get <ZoneTransitionService>();

        if (zoneTransitionService.IsInIgloo)
        {
            DataEntityHandle activeHandle = Service.Get <SceneLayoutDataManager>().GetActiveHandle();
            if (dataEntityCollection.TryGetComponent(activeHandle, out SceneOwnerData component))
            {
                if (component.IsOwner)
                {
                    if (dataEntityCollection.TryGetComponent(dataEntityCollection.LocalPlayerHandle, out ProfileData component2))
                    {
                        Service.Get <ZoneTransitionService>().LoadIgloo(component2.ZoneId, Service.Get <Localizer>().Language, SceneStateData.SceneState.Play);
                    }
                    else
                    {
                        returnToZoneSceneError("Could not find local owner ProfileData. Did not join igloo after returning from SceneWithoutZone state.");
                    }
                }
                else
                {
                    eventDispatcher.AddListener <PlayerStateServiceEvents.OtherPlayerDataReceived>(onOwnerPlayerDataReceived);
                    Service.Get <INetworkServicesManager>().PlayerStateService.GetOtherPlayerDataByDisplayName(component.Name);
                }
            }
            else
            {
                returnToZoneSceneError("Could not find igloo OwnerData. Did not join igloo after returning from SceneWithoutZone state.");
            }
        }
        else
        {
            Service.Get <SceneTransitionService>().LoadScene(zoneTransitionService.CurrentZone.SceneName, SceneConfig.TransitionSceneName, sceneArgs);
        }
    }
    public void RetryConnection(string roomName, string worldName = null)
    {
        ZoneTransitionService zoneTransitionService = Service.Get <ZoneTransitionService>();

        zoneTransitionService.LoadZone(zoneTransitionService.CurrentZone, SceneConfig.TransitionSceneName);
    }
Пример #13
0
    public void SpawnPlayer(SpawnPlayerParams spawnPlayerParams)
    {
        if (spawnPlayerParams.Zone != null || !string.IsNullOrEmpty(spawnPlayerParams.SceneName))
        {
            bool                  flag                  = false;
            PresenceData          component             = dataEntityCollection.GetComponent <PresenceData>(dataEntityCollection.LocalPlayerHandle);
            ZoneTransitionService zoneTransitionService = Service.Get <ZoneTransitionService>();
            if (spawnPlayerParams.Zone != null)
            {
                ZoneDefinition zoneBySceneName = zoneTransitionService.GetZoneBySceneName(component.Room);
                flag = (zoneBySceneName != null && string.Equals(spawnPlayerParams.Zone.ZoneName, zoneBySceneName.ZoneName));
            }
            else if (!string.IsNullOrEmpty(spawnPlayerParams.SceneName))
            {
                flag = ((!zoneTransitionService.IsInIgloo) ? string.Equals(component.Room, spawnPlayerParams.SceneName) : string.Equals(zoneTransitionService.CurrentZone.SceneName, spawnPlayerParams.SceneName));
            }
            if (!flag)
            {
                if (!dataEntityCollection.TryGetComponent(dataEntityCollection.LocalPlayerHandle, out SpawnData component2))
                {
                    component2 = dataEntityCollection.AddComponent <SpawnData>(dataEntityCollection.LocalPlayerHandle);
                }
                if (spawnPlayerParams.SpawnedAction != null)
                {
                    component2.SpawnedAction = spawnPlayerParams.SpawnedAction;
                }
                component2.Position      = spawnPlayerParams.Position;
                component2.Rotation      = spawnPlayerParams.Rotation;
                component2.PendingReward = spawnPlayerParams.PendingReward;
                if (spawnPlayerParams.Zone != null)
                {
                    zoneTransitionService.LoadZone(spawnPlayerParams.Zone, "Loading");
                }
                else
                {
                    zoneTransitionService.LoadZone(spawnPlayerParams.SceneName, "Loading");
                }
                return;
            }
        }
        if (spawnPlayerParams.PendingReward != null)
        {
            Service.Get <EventDispatcher>().DispatchEvent(new RewardServiceEvents.MyRewardEarned(RewardSource.QUICK_NOTIFICATION, "", spawnPlayerParams.PendingReward));
        }
        if (Vector3.Distance(base.transform.position, spawnPlayerParams.Position) <= 3f)
        {
            if (spawnPlayerParams.SpawnedAction != null)
            {
                executeSpawedAction(spawnPlayerParams.SpawnedAction);
            }
            return;
        }
        LocomotionTracker component3 = base.gameObject.GetComponent <LocomotionTracker>();

        if (component3.IsCurrentControllerOfType <SlideController>())
        {
            component3.SetCurrentController <RunController>();
        }
        else if (spawnPlayerParams.GetOutOfSwimming && component3.IsCurrentControllerOfType <SwimController>())
        {
            Animator component4 = base.gameObject.GetComponent <Animator>();
            component4.SetTrigger(AnimationHashes.Params.SwimToWalk);
            component3.SetCurrentController <RunController>();
        }
        Vector3 zero = Vector3.zero;

        if (spawnPlayerParams.NudgePlayer && component3.IsCurrentControllerOfType <RunController>())
        {
            zero.y = 0.5f;
        }
        base.transform.position = spawnPlayerParams.Position + zero;
        ClubPenguin.Core.SceneRefs.Get <BaseCamera>().Snap();
        if (spawnPlayerParams.NudgePlayer)
        {
            actionOnSpawned = spawnPlayerParams.SpawnedAction;
            CoroutineRunner.Start(LocomotionUtils.nudgePlayer(component3, onNudgePlayerDone), component3.gameObject, "MoveAfterJump");
        }
        else if (spawnPlayerParams.SpawnedAction != null)
        {
            executeSpawedAction(spawnPlayerParams.SpawnedAction);
        }
    }