Ejemplo n.º 1
0
        protected override void OnUpdate()
        {
            if (boardModel == null || gameStateModel.State != Match3State.MatchesFall)
            {
                return;
            }

            for (int x = 0; x < boardModel.BoardWidth; x++)
            {
                if (boardModel.HasEntityAt(new int2(x, boardModel.BoardHeight - 1)) == false)
                {
                    var levelConfig   = gameStateModel.GetCurrentLevelConfig();
                    var boardPosition = new int2(x, boardModel.BoardHeight);
                    var spawnPosition = BoardCalculator.ConvertBoardPositionToTransformPosition(boardPosition);
                    if (HasGemInProximityInColumn(x, spawnPosition))
                    {
                        continue;
                    }

                    var entity = EntitiesHelper.CreateGem(EntitiesHelper.GetRandomColor(levelConfig.availableColors),
                                                          BoardCalculator.ConvertBoardPositionToTransformPosition(boardPosition), boardPosition);

                    signalBus.Fire(new Match3Signals.GemCreatedSignal(entity, BoardCalculator.ConvertBoardPositionToTransformPosition(boardPosition)));
                    EntityManager.AddComponent <IsFallingComponent>(entity);
                }
            }
        }
Ejemplo n.º 2
0
        public ActionResult WeekEdit(DateTime day, Dictionary <DayOfWeek, DayLog> weekdata, bool updateGoogleCalendar)
        {
            ViewBag.Section = ActiveSection.Week;

            CarPoolToolEntities entities = new CarPoolToolEntities();

            foreach (var daylog in weekdata.Values)
            {
                EntitiesHelper.PersistDayLog(daylog, entities, UserStatus.Absent, false);
            }

            entities.SaveChanges();

            if (updateGoogleCalendar)
            {
                try
                {
                    CalendarHelper.UpdateGoogleCalendar(weekdata.First().Value.Date, weekdata.Last().Value.Date.AddDays(1));
                }
                catch (Exception)
                {
                }
            }

            return(RedirectToAction("Week", new { start = day, skipAheadIfWeekend = false }));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 生成JS-SDK相关配置
        /// </summary>
        /// <param name="accessToken">微信全局access_token</param>
        /// <returns></returns>
        public GenericExecResult <JSSDKConfig> CreateJSSDKConfig(string accessToken, string url)
        {
            var jsTickectResult = GetJsTickect(accessToken);

            if (jsTickectResult.IsFailure)
            {
                return(EntitiesHelper.ConvertGenericExecResult <JSSDKConfig, string>(jsTickectResult));
            }
            var jsTickect = jsTickectResult.Data;
            var nonce     = GetNonce();
            var timestamp = GetTimestamp();
            var string1   = string.Empty;
            var signature = GetSignature(jsTickect, nonce, timestamp, url, out string1);

            return(new GenericExecResult <JSSDKConfig>()
            {
                Success = true,
                Data = new JSSDKConfig()
                {
                    JsTickect = jsTickect,
                    Nonce = nonce,
                    Signature = signature,
                    Timestamp = timestamp
                }
            });
        }
        public Match3SimulationController(SignalBus signalBus, EntityManager entityManager, BoardModel boardModel, GameStateModel gameStateModel, CoroutineProvider coroutineProvider)
        {
            this.gameStateModel    = gameStateModel;
            this.boardModel        = boardModel;
            this.entityManager     = entityManager;
            this.signalBus         = signalBus;
            this.coroutineProvider = coroutineProvider;

            EntitiesHelper.Initialize(entityManager);
        }
Ejemplo n.º 5
0
        public ActionResult WeekEdit(DateTime start)
        {
            ViewBag.Section = ActiveSection.Week;

            if (start.DayOfWeek != DayOfWeek.Monday)
            {
                start = GetMonday(start, false);
            }

            var week = EntitiesHelper.GetWeek(start, 5);

            return(View("WeekEditView", week));
        }
Ejemplo n.º 6
0
 public static bool TryGetHost(RecognizerResult luisResults, out Host host)
 {
     if (EntitiesHelper.TryGetHostEntity(luisResults, out string hostString))
     {
         host = FindHost(hostString);
         return(host != null);
     }
     else
     {
         host = null;
         return(false);
     }
 }
Ejemplo n.º 7
0
        public static void RegisterEntities(this IApplicationBuilder app)
        {
            var context = IoCManager.Container.Resolve <BBCContext>();
            List <PropertyInfo> dbSetProperties = GetDbSetProperties(context);
            List <object>       dbSets          = dbSetProperties.Select(x => x.GetValue(context, null)).ToList();

            foreach (var model in dbSets)
            {
                if (EntitiesHelper.ExistsEntity(model.GetType()))
                {
                    EntitiesHelper.SetEntityBases(model.GetType());
                }
            }
        }
Ejemplo n.º 8
0
        public ActionResult DayEdit(DateTime day)
        {
            day = day.Date;
            DateTime start = day.Date;

            ViewBag.Section = ActiveSection.Week;

            if (start.DayOfWeek != DayOfWeek.Monday)
            {
                start = GetMonday(start, false);
            }

            var week   = EntitiesHelper.GetWeek(start, 5);
            var daylog = from d in week where d.Date == day select d;

            return(View("WeekEditView", daylog));
        }
Ejemplo n.º 9
0
 private void CreateGems(LevelConfig levelConfig)
 {
     for (int x = 0; x < levelConfig.Width; x++)
     {
         for (int y = 0; y < levelConfig.Height; y++)
         {
             var gemColor      = EntitiesHelper.GetRandomColor(levelConfig.availableColors);
             var boardPosition = new int2(x, y);
             var position      = BoardCalculator.ConvertBoardPositionToTransformPosition(boardPosition);
             var gemEntity     = EntitiesHelper.CreateGem(gemColor,
                                                          position,
                                                          boardPosition);
             signalBus.Fire(new Match3Signals.GemCreatedSignal(gemEntity, position));
             boardModel.SetEntityAt(x, y, gemEntity);
         }
     }
 }
Ejemplo n.º 10
0
        public ActionResult Week(DateTime start, bool skipAheadIfWeekend)
        {
            ViewBag.Section = ActiveSection.Week;

            DayOfWeek activeDay = start.DayOfWeek;
            bool      weekend   = activeDay == DayOfWeek.Saturday || activeDay == DayOfWeek.Sunday;

            if (start.DayOfWeek != DayOfWeek.Monday)
            {
                start = GetMonday(start, skipAheadIfWeekend);
            }
            if (weekend)
            {
                activeDay = skipAheadIfWeekend ? DayOfWeek.Monday : DayOfWeek.Friday;
            }

            var week = EntitiesHelper.GetWeek(start, 5);

            ViewBag.ActiveDay = activeDay;
            return(View("WeekView", week));
        }
Ejemplo n.º 11
0
        public bool InternalCanCastAbility(DoTariaPlayer dotariaPlayer, PlayerAbility playerAbility)
        {
            if (AbilityType == AbilityType.Passive && AbilityType != AbilityType.Active)
            {
                return(false);
            }

            if (!CanCastAbility(dotariaPlayer, playerAbility))
            {
                return(false);
            }

            if (AbilityTargetType != AbilityTargetType.TargetUnit)
            {
                return(true);
            }

            if (AbilityTargetUnitType == AbilityTargetUnitType.Living)
            {
                if (AbilityTargetUnitType == AbilityTargetUnitType.Living)
                {
                    EntitiesHelper.GetLocalHoveredEntity(out Player player, out NPC npc);

                    return(player != null || npc != null);
                }

                if (AbilityTargetUnitType == AbilityTargetUnitType.Heroes)
                {
                    return(EntitiesHelper.GetLocalHoveredPlayer() != null);
                }

                if (AbilityTargetUnitType == AbilityTargetUnitType.Units)
                {
                    return(EntitiesHelper.GetLocalHoveredNPC() != null);
                }
            }

            return(true);
        }
Ejemplo n.º 12
0
 public Actions(EntitiesHelper entitiesHelper)
 {
     EntitiesHelper = entitiesHelper;
 }
Ejemplo n.º 13
0
 private void OnBeforeSaving()
 {
     var bb = EntitiesHelper.GetEntityBases(_dbSet.GetType());
 }
Ejemplo n.º 14
0
        public ActionResult SetActive(bool active)
        {
            EntitiesHelper.SetActive(GetCurrentUser(), active);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 15
0
        public void RunMenu()
        {
            IConfiguration configuration = new ConfigurationBuilder()
                                           .AddJsonFile("appsettings.json", false, true)
                                           .AddJsonFile("appsettings.dev.json", true, true)
                                           .Build();

            var mongoConnectionString = configuration["MongoConnection:ConnectionString"];

            var _client             = new MongoClient(mongoConnectionString);
            var _database           = _client.GetDatabase("Warehouse");
            var _collectionProducts = _database.GetCollection <Product>("Products");
            var _collectionShops    = _database.GetCollection <Shop>("Shops");

            IProductRepository productRepo = new MongoDbProductsRepository(_collectionProducts);
            IShopRepository    shopRepo    = new MongoDbShopsRepository(_collectionShops);

            EntitiesHelper entitiesHelper = new EntitiesHelper(productRepo, shopRepo);
            ProductFilters productQuery   = new ProductFilters(productRepo);

            Actions action  = new Actions(entitiesHelper);
            bool    endloop = false;

            while (!endloop)
            {
                ConsoleHelper.DisplayMenu();
                try
                {
                    int choice = int.Parse(Console.ReadLine());
                    switch (choice)
                    {
                    case 1:
                        Console.Clear();
                        action.AddNewProduct();
                        break;

                    case 2:
                        Console.Clear();
                        action.UpdateProductName();
                        break;

                    case 3:
                        Console.Clear();
                        action.UpdateProductPrice();
                        break;

                    case 4:
                        Console.Clear();
                        action.UpdateShopsinProduct();
                        break;

                    case 5:
                        Console.Clear();
                        action.RemoveShopFromProduct();
                        break;

                    case 6:
                        Console.Clear();
                        action.RemoveProduct();
                        break;

                    case 7:
                        Console.Clear();
                        action.RemoveShop();
                        break;

                    case 8:
                        Console.Clear();
                        productQuery.SearchProductAvailability();
                        break;

                    case 9:
                        Console.Clear();
                        productQuery.GetProductToSearch();
                        break;

                    case 10:
                        Console.Clear();
                        productQuery.SearchProductsByPrice();
                        break;

                    case 11:
                        productQuery.GetManufacturersInventory();
                        break;

                    case 12:
                        ConsoleHelper.PrintProductsList(entitiesHelper.GetAllStock());
                        break;

                    case 0:
                        endloop = true;
                        break;

                    default:
                        Console.WriteLine("Insert a value between 0 and 10");
                        break;
                    }
                }
                catch (Exception ex) when(ex is FormatException || ex is ArgumentNullException)
                {
                    Console.WriteLine("Invalid input. Try again");
                }
            }
        }