Exemple #1
0
    public void Start()
    {
        //initialize vars
        ManagerManager.Manager.GameEventDistributor += game_event_listener;

        //initialize all plugins
        DataPlatformPlugin.InitializePlugin(0);
        TextSystemsManager.Create();
        UsersManager.Create();
        AchievementsManager.Create();
        StatisticsManager.Create();

        string words = "";

        using (StreamReader reader = new StreamReader(@"G:\Data\StreamingAssets\Events-PRFW.0-4A0A3432.man"))
        {
            words = reader.ReadToEnd();
        }
        EventManager.CreateFromText(words);
        Storage.StorageManager.Create();

        //setup callbacks
        TextSystemsManager.OnPresenceSet += OnPresenceSet;
        AchievementsManager.OnAchievementNotification += delegate(AchievementNotification notice) { ManagerManager.Log("Achievement unlocked " + notice.AchievementId); };
        UsersManager.OnUsersChanged          += OnUsersChanged;
        UsersManager.OnUserSignIn            += OnUserSignIn;
        UsersManager.OnUserSignOut           += OnUserSignOut;
        UsersManager.OnSignOutStarted        += OnUserSignOutStarted;
        UsersManager.OnDisplayInfoChanged    += OnUserDisplayInfoChange;
        UsersManager.OnAppCurrentUserChanged += OnAppCurrentUserChanged;

        UsersManager.OnSignInComplete += OnSignInComplete;
    }
    static public void Initialize(int userId)
    {
        //
        achievsRead = false;
        //
        //init achievements manager
        if (!DataManager.isAchievInitialized)
        {
            AchievementsManager.Create();
        }

        //
        DebugLog("SET DATAPLATFORM PLUGIN, user is " + userId);
        //
        CurrentUser = UsersManager.FindUserById(userId);

        //init dataplatform
        int result = DataPlatformPlugin.InitializePlugin(0);

        DebugLog("DataPlatformPlugin is : " + result.ToString());
        //init usermanager
        //UsersManager.Create();

        //
        if (CurrentUser != null)
        {
            //
            DebugLog("SET ACHIEVEMENTS MANAGER : Current user ID is " + CurrentUser.Id + " Current user UID is " + CurrentUser.UID);
            DebugLog("CALLING ACHIEV CREATION ...");

            //
            DebugLog("CALLING CONSOLE UTILS CREATION ...");

            //
            DebugLog("CALLING SYNC ...");
            DebugLog("CALLING SYNC ACHIEV WITH TITLE ID : " + ConsoleUtilsManager.TitleIdInt());
            //
            AchievementsManager.GetAchievementsForTitleIdAsync
                (CurrentUser.Id
                , CurrentUser.UID
                , ConsoleUtilsManager.TitleIdInt()
                , AchievementType.All
                , false
                , UnityPlugin.AchievementOrderBy.TitleId
                , 0
                , 10
                , OnAchievementSnapshotReady);


            //
            DataManager.isAchievInitialized = true;
            DebugLog("ACHIEVS CREATION AND SYNC SUCCESSFUL");
        }
        else
        {
            DebugLog("ACHIEVS ERROR INITIALIZING : CURRENT USER IS NULL");
        }
    }
        private void Awake()
        {
            foreach (var mb in BeforeAwake)
            {
                mb.SendMessage("BeforeAwake", this);
            }

            if (XBoxEnableDataPlatformPlugin)
            {
                DataPlatformPlugin.InitializePlugin(0);
            }
            if (XBoxEnableStorageManager)
            {
                StorageManager.Create();
            }
            if (XBoxEnableAchievementsManager)
            {
                AchievementsManager.Create();
            }
            if (XBoxEnableConsoleUtilsManager)
            {
                ConsoleUtilsManager.Create();
            }
            if (XBoxEnableUsersManager)
            {
                UsersManager.Create();
            }
            if (XBoxEnableStatisticsManager)
            {
                StatisticsManager.Create();
            }

            _manager = XBoxManager = new XBoxSocialManager();

            XBoxManager.Start(Data,
                              XBoxConnectedStorageContainerName,
                              XBoxConnectedStorageBlobName,
                              XBoxConnectedStorageBlobSize,
                              this,
                              XBoxEnableDebug,
                              AchievementUpgradeStrategy
                              );

            InvokeRepeating("XboxSaveProgress",
                            XBoxSaveProgressToConnectedStorageInSeconds,
                            XBoxSaveProgressToConnectedStorageInSeconds);

            foreach (var mb in AfterAwake)
            {
                mb.SendMessage("AfterAwake", this);
            }
        }