示例#1
0
        /// <summary>
        /// Loads the menu scene.
        /// </summary>
        /// <returns>A task to be awaited which represents the loading.</returns>
        private async UniTask LoadMenuAsync()
        {
            _menuManager = await LoadManagedSceneAsync <MenuManager>(_menuScene);

            _menuManager.OnStartMatch += LoadMatchAsync;
            _part = GamePart.Menu;
        }
示例#2
0
 public void Init()
 {
     mainData           = Singleton.MainData;
     gamePart           = Singleton.GamePart;
     tableBase          = new PrecacTableBase(mainData.XSize, mainData.YSize);
     problemsAndResults = new Dictionary <ConnectedAreas, SearchForCa>();
     Flip(new List <FlipNode>());
     visualizedData();
 }
示例#3
0
        /// <summary>
        /// Loads the match <see cref="Scene"/> and starts a new <see cref="Match"/> asynchronously.
        /// </summary>
        /// <param name="settings">The settings of the match to be started.</param>
        private async void LoadMatchAsync(MatchSettings settings)
        {
            _menuManager.OnStartMatch -= LoadMatchAsync;
            _matchManager              = await LoadManagedSceneAsync <MatchManager>(_matchScene);

            try
            {
                _part = GamePart.Match;
                await _matchManager.StartMatchAsync(settings);
            }
            catch (OperationCanceledException)
            {
                Debug.Log("Match start was cancelled.");
            }
        }
示例#4
0
文件: AIOptions.cs 项目: AciesNN/cyc
		protected AIOptions(Context context)
		{
			turnsToEnd = Library.Common.TurnsToEnd(context);
			if (turnsToEnd <= 1)
			{
				gamePart = GamePart.End;
				coefficients = new AIEndCoefficients();
			}
			else if (turnsToEnd <= 3)
			{
				gamePart = GamePart.Middle;
				coefficients = new AIMiddleCoefficients();
			}
			else
			{
				gamePart = GamePart.Start;
				coefficients = new AIStartCoefficients();
			}
		}
        public ActionResult List(int?gameId)
        {
            GamePart game = null;

            if (gameId != null)
            {
                game = _gameService.Get(gameId.Value, VersionOptions.Latest);
            }

            if (game == null)
            {
                return(RedirectToAction("ChooseGame"));
            }

            IEnumerable <ObjectivePart> objectives;

            if (game != null)
            {
                objectives = _objectiveService.Get(game, VersionOptions.Latest);
            }
            else
            {
                objectives = _objectiveService.Get(VersionOptions.Latest);
            }

            var list = Services.New.List();

            list.AddRange(objectives.Select(objective => Services.ContentManager.BuildDisplay(objective, "SummaryAdmin")));

            dynamic viewModel = Services.New.ViewModel()
                                .ContentItems(list)
                                .Game(game)
                                .AllGames(_gameService.Get(VersionOptions.Latest));

            // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
            return(View((object)viewModel));
        }
示例#6
0
        protected override DriverResult Display(ActionSubmitPart part, string displayType, dynamic shapeHelper)
        {
            List <DriverResult> results = new List <DriverResult>();

            results.Add(ContentShape("Parts_ActionSubmit_MetaAdmin", () =>
            {
                var objective = _objectiveService.Value.Get(part.Objective.ContentItemRecord.Id, VersionOptions.Latest);

                //var game = _gameService.Value.Get(part.Objective.GamePartRecord.ContentItemRecord.Id, VersionOptions.Latest);
                GamePart game = part.Objective.GamePartRecord != null ? _gameService.Value.Get(part.Objective.GamePartRecord.ContentItemRecord.Id, VersionOptions.Latest) : null;

                return((object)shapeHelper.Parts_ActionSubmit_MetaAdmin(Objective: objective, Game: game));
            }));

            results.Add(ContentShape("Parts_ActionSubmit_StatusAdmin", () =>
            {
                //var objective = _objectiveService.Value.Get(part.Objective.Id, VersionOptions.Latest);
                //var game = _gameService.Value.Get(part.Objective.GamePartRecord.Id, VersionOptions.Latest);

                return(shapeHelper.Parts_ActionSubmit_StatusAdmin(ActionSubmit: part /*, Objective: objective, Game: game */));
            }));

            return(Combined(results.ToArray()));
        }
 public static string GameObjectives(this UrlHelper urlHelper, GamePart gamePart)
 {
     return(urlHelper.Action("List", "ObjectiveAdmin", new { area = "DeSjoerd.Competition", gameId = gamePart.ContentItem.Id }));
 }
示例#8
0
 public void OnClick(string element)
 {
     if (element == "Cross-Screen/welcome-screen")
     {
         //welcome = false;
     }
     if (element == "Main-Game/market")
     {
         gamePart = GamePart.market;
     }
     if (element == "Main-Game/Flag")
     {
         gamePart = GamePart.faction;
         Console.WriteLine("clicked flag");
     }
     if (element == "Main-Game/boat")
     {
         gamePart = GamePart.harbour;
     }
     if (element == "Main-Game/profile")
     {
         gamePart = GamePart.profile;
         Console.WriteLine("clicked Profile");
     }
     if (element == "Main-Game/wastePlant")
     {
         gamePart = GamePart.waste;
     }
     if (element == "Main-Game/settings")
     {
         gamePart = GamePart.BackMenu;
         Console.WriteLine("clicked Settings");
     }
     if (element == "Main-Game/barracks")
     {
         gamePart = GamePart.barracks;
     }
     if (element == "Main-Menu/done")
     {
         gamePart = GamePart.main;
     }
     if (element == "Main-Game/Foodtruck")
     {
         gamePart = GamePart.resto;
     }
     if (element == "Main-Game/farm")
     {
         gamePart = GamePart.farm;
     }
     if (element == "Back-Menu/close-button")
     {
         gamePart = GamePart.main;
     }
     if (element == "Back-Menu/main-menu")
     {
         gamePart = GamePart.mainMenu;
     }
     if (element == "Back-Menu/settings-button")
     {
         gamePart = GamePart.settings;
     }
 }
        public ActionResult GetListSingleGame(int ID, PagerParameters pagerParameters, string DeviceType = "General", bool Ascending = false)
        {
            if (!_orchardServices.Authorizer.Authorize(Permissions.GameRanking)) //(Permissions.AccessStatistics)) //(StandardPermissions.SiteOwner)) //
            {
                return(new HttpUnauthorizedResult());
            }

            if (pagerParameters.PageSize == null)
            {
                pagerParameters.PageSize = _orchardServices.WorkContext.CurrentSite.PageSize;
            }
            if (pagerParameters.Page == null)
            {
                pagerParameters.Page = 1;
            }


            var      query = _orchardServices.ContentManager.Query();
            var      list  = query.ForPart <GamePart>().Where <GamePartRecord>(x => x.Id == ID).List(); //list all games with the selected ID (should be only one)
            GamePart gp    = list.FirstOrDefault();                                                     //the game for which we want the rankings
            //Assuming there was no issues, gp should never be null. If gp is null, it probably means something happened in the DB, since we
            //read the ID from the DB to create the "caller" page, and the we read again in this method.
            ContentItem Ci     = gp.ContentItem;
            string      titolo = Ci.As <TitlePart>().Title;

            string devString = "General";

            //query to get the ranking out of the db, already sorted and paged, with multiple scores by a same user removed
            if (DeviceType == TipoDispositivo.Apple.ToString())
            {
                devString = TipoDispositivo.Apple.ToString();
            }
            else if (DeviceType == TipoDispositivo.Android.ToString())
            {
                devString = TipoDispositivo.Android.ToString();
            }
            else if (DeviceType == TipoDispositivo.WindowsMobile.ToString())
            {
                devString = TipoDispositivo.WindowsMobile.ToString();
            }
            List <RankingTemplateVM> lRanka = _questionnairesServices.QueryForRanking(ID, devString, pagerParameters.Page.Value, pagerParameters.PageSize.Value, Ascending);

            var    session     = _transactionManager.GetSession();//_sessionLocator.For(typeof(RankingPartRecord));
            string queryString = "SELECT COUNT(DISTINCT Identifier) "
                                 + "FROM Laser.Orchard.Questionnaires.Models.RankingPartRecord as rpr "
                                 + "WHERE rpr.ContentIdentifier=" + ID + " ";

            if (DeviceType == TipoDispositivo.Apple.ToString())
            {
                queryString += "AND rpr.Device = '" + TipoDispositivo.Apple + "' ";
            }
            else if (DeviceType == TipoDispositivo.Android.ToString())
            {
                queryString += "AND rpr.Device = '" + TipoDispositivo.Android + "' ";
            }
            else if (DeviceType == TipoDispositivo.WindowsMobile.ToString())
            {
                queryString += "AND rpr.Device = '" + TipoDispositivo.WindowsMobile + "' ";
            }
            var countQuery = session.CreateQuery(queryString);
            //var asd = countQuery.List(); // countQuery.UniqueResult();
            int scoresCount = (int)(countQuery.UniqueResult <long>());

            //create and initialize pager
            Pager pager      = new Pager(_orchardServices.WorkContext.CurrentSite, pagerParameters);
            var   pagerShape = _orchardServices.New.Pager(pager).TotalItemCount(scoresCount);
            int   listStart  = pager.GetStartIndex();
            int   listEnd    = listStart + ((pager.PageSize > scoresCount) ? scoresCount : pager.PageSize);

            listEnd = listEnd > scoresCount ? scoresCount : listEnd;
            DisplaRankingTemplateVM pageOfScores = new DisplaRankingTemplateVM {
                Title    = titolo,
                GameID   = ID,
                Device   = devString,
                ListRank = lRanka //innerquery
            };

            var model = new DisplayRankingTemplateVMModel();

            model.Pager = pagerShape;
            model.drtvm = pageOfScores;

            return(View((object)model)); //((object)listaAllRank);
        }
示例#10
0
 public void UpdateGame(GameEditorViewModel viewModel, GamePart gamePart)
 {
     gamePart.SortObjectivesByAlphabet = viewModel.SortObjectivesByAlphabet;
     gamePart.UseTinyDisplayType       = viewModel.UseTinyDisplayType;
 }