예제 #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;
    }
        public ActionResult Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new User()
                {
                    UserName = model.UserName, UserRole = _userRolesRepository.GetById(model.UserRole)
                };
                var result = UsersManager.Create(user, model.Password);

                if (result.Succeeded)
                {
                    SignInManager.SignIn(user, false, false);
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    foreach (var error in result.Errors)
                    {
                        ModelState.AddModelError("", error);
                    }
                }
            }

            SelectList roles = new SelectList(_userRolesRepository.GetAll().Where(r => r.Id != 1), "Id", "Name");

            ViewBag.Roles = roles;

            return(View(model));
        }
        public ActionResult Create(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                User user = new User()
                {
                    UserName = model.UserName, UserRole = _userRolesRepository.GetById(model.UserRole)
                };
                IdentityResult result = UsersManager.Create(user, model.Password);

                if (result.Succeeded)
                {
                    return(RedirectToAction("Index", "Account"));
                }
                else
                {
                    foreach (var error in result.Errors)
                    {
                        ModelState.AddModelError("", error);
                    }
                }
            }

            SelectList roles = new SelectList(_userRolesRepository.GetAll(), "Id", "Name");

            ViewBag.Roles = roles;

            return(View(model));
        }
예제 #4
0
        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);
            }
        }