예제 #1
0
        public ActionResult Index()
        {
            if (Request[GlobalConst.ASmallCakeCookieName] != null)
            {
                return(RedirectToAction("Index", new {}));
            }
            var db = new ZkDataContext();

            var result = new IndexResult()
            {
                Spotlight    = SpotlightHandler.GetRandom(),
                Top10Players =
                    db.Accounts.Where(x => x.SpringBattlePlayers.Any(y => y.SpringBattle.StartTime > DateTime.UtcNow.AddMonths(-1))).OrderByDescending(
                        x => x.Elo1v1).Take(10)
            };

            result.LobbyStats = AuthServiceClient.GetLobbyStats();
            result.News       = db.News.Where(x => x.Created < DateTime.UtcNow).OrderByDescending(x => x.Created);
            if (Global.Account != null)
            {
                result.Headlines =
                    db.News.Where(
                        x => x.Created <DateTime.UtcNow && x.HeadlineUntil != null && x.HeadlineUntil> DateTime.UtcNow && (Global.Account.LastNewsRead == null || (x.Created > Global.Account.LastNewsRead))).
                    OrderByDescending(x => x.Created);

                if (result.Headlines.Any())
                {
                    db.Accounts.Single(x => x.AccountID == Global.AccountID).LastNewsRead = DateTime.UtcNow;
                    db.SubmitChanges();
                }
            }
            else
            {
                result.Headlines = new List <News>();
            }


            var accessibleThreads = db.ForumThreads.Where(x => x.RestrictedClanID == null || x.RestrictedClanID == Global.ClanID);

            if (!Global.IsAccountAuthorized)
            {
                result.NewThreads = accessibleThreads.OrderByDescending(x => x.LastPost).Take(10).Select(x => new NewThreadEntry()
                {
                    ForumThread = x
                });
            }
            else
            {
                result.NewThreads = (from t in accessibleThreads
                                     let read = t.ForumThreadLastReads.SingleOrDefault(x => x.AccountID == Global.AccountID)
                                                where read == null || t.LastPost > read.LastRead
                                                orderby t.LastPost descending
                                                select new NewThreadEntry {
                    ForumThread = t, WasRead = read != null, WasWritten = read != null && read.LastPosted != null
                }).
                                    Take(10);
            }

            return(View(result));
        }
예제 #2
0
        /// <summary>
        /// Go to home page; also updates news read dates
        /// </summary>
        public ActionResult Index()
        {
            // TODO: make two separate pages -- one for logged in users, one for not-logged in users
            // logged in users see their user profile
            // non-logged in users see promotional page

            var db = new ZkDataContext();

            if (!Global.IsAccountAuthorized)
            {
                return(View("Splash"));
            }

            // TODO: randomized backgrounds move here
            var result = new IndexResult
            {
                Spotlight         = SpotlightHandler.GetRandom(),
                Top10Players      = RatingSystems.GetRatingSystem(RatingCategory.MatchMaking).GetTopPlayers(10),
                WikiRecentChanges = MediaWikiRecentChanges.LoadRecentChanges(),
                LobbyStats        = MemCache.GetCached("lobby_stats", GetCurrentLobbyStats, 60 * 2),
                News       = db.News.Where(x => x.Created < DateTime.UtcNow).OrderByDescending(x => x.Created),
                Headlines  = GetHeadlines(db),
                NewThreads = GetNewForumThreads(db)
            };

            return(View("HomeIndex", result));
        }
예제 #3
0
 // Start is called before the first frame update
 void Start()
 {
     _spotLightHandler       = this.GetComponent <SpotlightHandler>();
     _chladniTalkBoard       = this.gameObject.AddComponent <FMODUnity.StudioEventEmitter>();
     _chladniTalkBoard.Event = _tutorialSounds[0];
     _chladniTalkBoard.EventInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(chladniSoundEmitter.transform));
     _soundAfterTutorial       = this.gameObject.AddComponent <FMODUnity.StudioEventEmitter>();
     _soundAfterTutorial.Event = GLOB.BackgroundSound;
     _soundAfterTutorial.Stop();
 }
예제 #4
0
        /// <summary>
        /// Go to home page; also updates news read dates
        /// </summary>
        public ActionResult Index()
        {
            var db = new ZkDataContext();


            var result = new IndexResult()
            {
                Spotlight         = SpotlightHandler.GetRandom(),
                Top10Players      = RatingSystems.GetRatingSystem(RatingCategory.MatchMaking).GetTopPlayers(10),
                WikiRecentChanges = MediaWikiRecentChanges.LoadRecentChanges()
            };

            result.LobbyStats = MemCache.GetCached("lobby_stats", GetCurrentLobbyStats, 60 * 2);

            result.News = db.News.Where(x => x.Created < DateTime.UtcNow).OrderByDescending(x => x.Created);
            if (Global.Account != null)
            {
                result.Headlines =
                    db.News.Where(
                        x => x.Created <DateTime.UtcNow && x.HeadlineUntil != null && x.HeadlineUntil> DateTime.UtcNow && !x.ForumThread.ForumThreadLastReads.Any(y => y.AccountID == Global.AccountID && y.LastRead != null)).
                    OrderByDescending(x => x.Created).ToList();

                if (result.Headlines.Any())
                {
                    foreach (var h in result.Headlines)
                    {
                        h.ForumThread.UpdateLastRead(Global.AccountID, false);
                    }

                    db.SaveChanges();
                }
            }
            else
            {
                result.Headlines = new List <News>();
            }


            var accessibleThreads = db.ForumThreads.Where(x => x.RestrictedClanID == null || x.RestrictedClanID == Global.ClanID);

            accessibleThreads = accessibleThreads.Where(x => x.ForumCategory.ForumMode != ForumMode.Archive);
            if (!Global.IsAccountAuthorized)
            {
                result.NewThreads = accessibleThreads.OrderByDescending(x => x.LastPost).Take(10).Select(x => new NewThreadEntry()
                {
                    ForumThread = x
                });
            }
            else
            {
                result.NewThreads = (from t in accessibleThreads
                                     let read = t.ForumThreadLastReads.FirstOrDefault(x => x.AccountID == Global.AccountID)
                                                let readForum = t.ForumCategory.ForumLastReads.FirstOrDefault(x => x.AccountID == Global.AccountID)
                                                                where (read == null || t.LastPost > read.LastRead) && (readForum == null || t.LastPost > readForum.LastRead)
                                                                orderby t.LastPost descending
                                                                select new NewThreadEntry {
                    ForumThread = t, WasRead = read != null, WasWritten = read != null && read.LastPosted != null
                }).
                                    Take(10);
            }



            return(View("HomeIndex", result));
        }