Beispiel #1
0
        // periodic callback for general game management
        public ActionResult Update()
        {
            // time warp actions
            if (Halloween_Game.Session.CurrentSession.State == Halloween_Game.Session.SessionState.TimeWarp)
            {
                return(TimeWarp());
            }

            // reset
            if (Halloween_Game.Session.CurrentSession.State == Halloween_Game.Session.SessionState.Reset)
            {
                if (Halloween_Game.Session.CurrentSession.TimeSinceLastModified.TotalSeconds > 90)
                {
                    Halloween_Game.Session.StartNewSession();
                }
                return(null);
            }

            // look for any expired tasks
            PlayerTask.ExpireTasks();

            foreach (Team team in Team.GetAll())
            {
                team.StockWarehouse();
            }

            // once every few seconds consider assign new tasks to players - high enough that we never have two of these executing simultaneously
            if (DateTime.Now.Subtract(HGameApp.LastTaskUpdate).TotalSeconds > 10)
            {
                foreach (var player in Player.GetAll())
                {
                    PlayerTask.AssignTaskMaybe(player.id);
                }
                HGameApp.LastTaskUpdate = DateTime.Now;
            }

            Newsfeed.AddNewsfeedItem();

            return(null);
        }