private GameObject SpawnAwardPrefab(AwardTypeEnum awardTypeEnum)
        {
            GameObject prefab;

            switch (awardTypeEnum)
            {
            case AwardTypeEnum.SoftCurrency:
                prefab = GetRegularCurrencyPrefab();
                break;

            case AwardTypeEnum.AccountRating:
                prefab = GetTrophyPrefab();
                break;

            case AwardTypeEnum.HardCurrency:
                prefab = GetPremiumCurrencyPrefab();
                break;

            case AwardTypeEnum.LootboxPoints:
                prefab = GetLootboxPointPrefab();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(awardTypeEnum), awardTypeEnum, null);
            }
            GameObject result = Object.Instantiate(prefab, movingAwardsParentRectTransform, false);

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Converts a AwardTypeEnum value to a corresponding string value
        /// </summary>
        /// <param name="enumValue">The AwardTypeEnum value to convert</param>
        /// <returns>The representative string value</returns>
        public static string ToValue(AwardTypeEnum enumValue)
        {
            switch (enumValue)
            {
            //only valid enum elements can be used
            //this is necessary to avoid errors
            case AwardTypeEnum.DISTANCE_BASED:
            case AwardTypeEnum.FARE_BASED:
                return(stringValues[(int)enumValue]);

            //an invalid enum value was requested
            default:
                return(null);
            }
        }
        public Vector3 GetFinishPoint(AwardTypeEnum awardTypeEnum)
        {
            switch (awardTypeEnum)
            {
            case AwardTypeEnum.SoftCurrency:
                return(softCurrencyFinishPosition);

            case AwardTypeEnum.AccountRating:
                return(trophyFinishPoint.position);

            case AwardTypeEnum.HardCurrency:
                return(hardCurrencyFinishPosition);

            case AwardTypeEnum.LootboxPoints:
                return(smallLootboxFinishPoint.position);

            default:
                throw new ArgumentOutOfRangeException(nameof(awardTypeEnum), awardTypeEnum, null);
            }
        }
Ejemplo n.º 4
0
        private void AddAwardSpawnCommand(AwardTypeEnum awardTypeEnum, int quantity, DateTime spawnStartTime)
        {
            LobbyUiEntity entity = lobbyUiContext.CreateEntity();

            entity.AddCommandToCreateAwardImages(quantity, awardTypeEnum, spawnStartTime);
        }
Ejemplo n.º 5
0
        protected override void Execute(List <LobbyUiEntity> entities)
        {
            const int maxNumberOfImagesPerAwardType = 100;

            foreach (var command in entities.Select(entity => entity.commandToCreateAwardImages))
            {
                AwardTypeEnum awardTypeEnum  = command.awardTypeEnum;
                DateTime      spawnStartTime = command.startSpawnTime;
                int           remainder      = command.quantity;
                int           numberOfImages;

                if (command.quantity > maxNumberOfImagesPerAwardType)
                {
                    numberOfImages = maxNumberOfImagesPerAwardType;
                }
                else
                {
                    numberOfImages = command.quantity;
                }


                int roundedAverageIncrement = (int)Math.Round(((decimal)command.quantity / numberOfImages),
                                                              MidpointRounding.AwayFromZero);
                // log.Debug($"{nameof(roundedAverageIncrement)} {roundedAverageIncrement}");

                int index = 0;
                while (remainder != 0)
                {
                    index++;
                    LobbyUiEntity entity = contextsLobbyUi.CreateEntity();

                    Vector3 spawnPoint  = MovingAwardsUiElementsStorage.Instance().GetStartPoint(awardTypeEnum);
                    Vector3 finishPoint = MovingAwardsUiElementsStorage.Instance().GetFinishPoint(awardTypeEnum);

                    // log.Debug($"finish position {finishPoint.x} {finishPoint.y}");
                    List <ControlPoint> controlPoints = awardTrajectoryFactory
                                                        .Create(index, spawnStartTime, spawnPoint, finishPoint, random, screenHeight);

                    // log.Debug("last control point position "+controlPoints.Last().position.x+" "+controlPoints.Last().position.y);
                    int increment;
                    if (roundedAverageIncrement < remainder)
                    {
                        increment = roundedAverageIncrement;
                    }
                    else
                    {
                        increment = remainder;
                    }
                    IconTrajectory iconTrajectory = new IconTrajectory()
                    {
                        controlPoints            = controlPoints,
                        currentControlPointIndex = 1
                    };
                    entity.AddMovingIcon(increment, iconTrajectory, awardTypeEnum);
                    entity.AddPosition(controlPoints.First().position);
                    entity.AddAlpha(0);
                    entity.AddScale(new Vector3(1, 1, 1));

                    remainder -= increment;
                }
            }
        }